Skip to content

Commit

Permalink
Update to Selenium 4.24.0 (#123)
Browse files Browse the repository at this point in the history
Temporarily add direct reference to Newtonsoft.Json
Stabilize wait for FindElements in the ElementFactory +semver:feature
  • Loading branch information
mialeska authored Aug 30, 2024
1 parent 764517d commit d28171d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,10 @@
<PackageReference Include="DotNetSeleniumExtras.PageObjects" Version="3.11.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.1" />
<PackageReference Include="NLog" Version="5.3.2" />
<PackageReference Include="Selenium.Support" Version="4.23.0" />
<PackageReference Include="Selenium.WebDriver" Version="4.23.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="NLog" Version="5.3.3" />
<PackageReference Include="Selenium.Support" Version="4.24.0" />
<PackageReference Include="Selenium.WebDriver" Version="4.24.0" />
<PackageReference Include="SkiaSharp" Version="2.88.8" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,22 @@ public virtual IList<T> FindElements<T>(By locator, string name = null, ElementS
default:
throw new ArgumentOutOfRangeException($"No such expected value: {expectedCount}");
}

var webElements = ElementFinder.FindElements(locator, state, TimeSpan.Zero, name);
IEnumerable<T> elements = webElements.Select((webElement, index) =>
var elements = new List<T>();
ConditionalWait.WaitFor(() =>
{
var elementIndex = index + 1;
var elementName = $"{name ?? "element"} {elementIndex}";
return elementSupplier(GenerateLocator(locator, webElement, elementIndex), elementName, state);
});
return elements.ToList();
var webElements = ElementFinder.FindElements(locator, state, TimeSpan.Zero, name);
elements = webElements.Select((webElement, index) =>
{
var elementIndex = index + 1;
var elementName = $"{name ?? "element"} {elementIndex}";
return elementSupplier(GenerateLocator(locator, webElement, elementIndex), elementName, state);
}).ToList();
var anyElementsFound = elements.Any();
return expectedCount == ElementsCount.Any || (expectedCount == ElementsCount.Zero && !anyElementsFound) || (expectedCount == ElementsCount.MoreThenZero && anyElementsFound);
}, exceptionsToIgnore: new List<Type> { typeof(StaleElementReferenceException), typeof(JavaScriptException) , typeof(WebDriverTimeoutException)});

return elements;
}

public virtual T GetCustomElement<T>(ElementSupplier<T> elementSupplier, By locator, string name, ElementState state = ElementState.Displayed) where T : IElement
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@
<ItemGroup>
<PackageReference Include="Appium.WebDriver" Version="5.1.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Include="nunit" Version="4.1.0" />
<PackageReference Include="nunit" Version="4.2.1" />
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.0" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit d28171d

Please sign in to comment.