Skip to content

Commit

Permalink
Fixed Issue #23: Speedup Search in List Element
Browse files Browse the repository at this point in the history
  • Loading branch information
CosminSontu committed Mar 13, 2024
1 parent 1c3281f commit 650fc55
Show file tree
Hide file tree
Showing 13 changed files with 82 additions and 73 deletions.
12 changes: 6 additions & 6 deletions SpecDrill.Infrastructure/SpecDrill.Infrastructure.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net7.0</TargetFrameworks>
<TargetFrameworks>net8.0</TargetFrameworks>
<Nullable>enable</Nullable>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<PackageIcon>specdrill.png</PackageIcon>
<BuildNumber>554</BuildNumber>
<Version>1.3.0.$(BuildNumber)</Version>
<BuildNumber>4</BuildNumber>
<Version>1.4.0.$(BuildNumber)</Version>
<Description>SpecDrill.Infrastructure</Description>
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
<PackageReleaseNotes>
Expand All @@ -20,8 +20,8 @@
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
<PackageReference Include="NReco.Logging.File" Version="1.1.7" />
<PackageReference Include="System.Text.Json" Version="8.0.0" />
<PackageReference Include="NReco.Logging.File" Version="1.2.0" />
<PackageReference Include="System.Text.Json" Version="8.0.3" />
</ItemGroup>
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
<Exec Command="pwsh ../incver.ps1 -csproj $(ProjectFileName)" />
Expand Down
14 changes: 7 additions & 7 deletions SpecDrill.MsTest/SpecDrill.MsTest.csproj
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<RestoreSources>$(RestoreSources)</RestoreSources>
<TargetFrameworks>net7.0</TargetFrameworks>
<TargetFrameworks>net8.0</TargetFrameworks>
<Nullable>enable</Nullable>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<PackageIcon>specdrill.png</PackageIcon>
<BuildNumber>1160</BuildNumber>
<Version>1.3.0.$(BuildNumber)</Version>
<BuildNumber>4</BuildNumber>
<Version>1.4.0.$(BuildNumber)</Version>
<Description>SpecDrill.MsTest - SpecDrill integration with MsTest </Description>
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
<PackageReleaseNotes>
Expand All @@ -15,9 +15,9 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
<PackageReference Include="MSTest.TestFramework" Version="3.1.1" />
<PackageReference Include="SpecDrill" Version="1.3.0.1287" />
<PackageReference Include="SpecDrill.Secondary.Adapters.WebDriver" Version="[1.3.*,)" />
<PackageReference Include="MSTest.TestFramework" Version="3.2.2" />
<PackageReference Include="SpecDrill" Version="1.4.0.3" />
<PackageReference Include="SpecDrill.Secondary.Adapters.WebDriver" Version="1.4.0.3" />
<None Include="..\LICENSE" Pack="true" PackagePath=".\" />
<None Include="..\specdrill.png" Pack="true" PackagePath=".\" />
<Content Include="..\NuGet\content\*.template.*" Pack="true" PackagePath="content" PackageCopyToOutput="true" CopyToOutputFolder="PreserveNewest" />
Expand Down
14 changes: 7 additions & 7 deletions SpecDrill.NUnit3/SpecDrill.NUnit3.csproj
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<RestoreSources>$(RestoreSources)</RestoreSources>
<TargetFrameworks>net7.0</TargetFrameworks>
<TargetFrameworks>net8.0</TargetFrameworks>
<Nullable>enable</Nullable>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<PackageIcon>specdrill.png</PackageIcon>
<BuildNumber>879</BuildNumber>
<Version>1.3.0.$(BuildNumber)</Version>
<BuildNumber>4</BuildNumber>
<Version>1.4.0.$(BuildNumber)</Version>
<Description>SpecDrill.NUnit - SpecDrill integration with NUnit 3</Description>
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
<OutputType>Library</OutputType>
Expand All @@ -15,9 +15,9 @@
</PackageReleaseNotes>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="NUnit" Version="3.14.0" />
<PackageReference Include="SpecDrill" Version="1.3.0.1287" />
<PackageReference Include="SpecDrill.Secondary.Adapters.WebDriver" Version="[1.3.*,)" />
<PackageReference Include="NUnit" Version="4.1.0" />
<PackageReference Include="SpecDrill" Version="1.4.0.3" />
<PackageReference Include="SpecDrill.Secondary.Adapters.WebDriver" Version="1.4.0.3" />
<None Include="..\LICENSE" Pack="true" PackagePath=".\" />
<None Include="..\specdrill.png" Pack="true" PackagePath=".\" />
<Content Include="..\NuGet\content\*.template.*" Pack="true" PackagePath="content" PackageCopyToOutput="true" CopyToOutputFolder="PreserveNewest" />
Expand Down
16 changes: 8 additions & 8 deletions SpecDrill.Samples.MsTest/SpecDrill.Samples.MsTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@

<PropertyGroup>
<RestoreSources>$(RestoreSources)</RestoreSources>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>


<ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="MSTest.TestAdapter" Version="3.1.1" />
<PackageReference Include="MSTest.TestFramework" Version="3.1.1" />
<PackageReference Include="coverlet.collector" Version="6.0.0">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="MSTest.TestAdapter" Version="3.2.2" />
<PackageReference Include="MSTest.TestFramework" Version="3.2.2" />
<PackageReference Include="coverlet.collector" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Selenium.WebDriver.ChromeDriver" Version="119.0.6045.10500" />
<PackageReference Include="SpecDrill" Version="1.3.0.1287" />
<PackageReference Include="SpecDrill.MsTest" Version="1.3.0.1156" />
<PackageReference Include="Selenium.WebDriver.ChromeDriver" Version="122.0.6261.11100" />
<PackageReference Include="SpecDrill" Version="1.4.0.3" />
<PackageReference Include="SpecDrill.MsTest" Version="1.4.0.3" />
</ItemGroup>


Expand Down
2 changes: 1 addition & 1 deletion SpecDrill.Samples.NUnit/Features/GoogleSearch.feature
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ Scenario: 1.Find wiki entry for searched keyword
Scenario: 2.Find wiki entry for searched keyword
Given I have entered "drill wiki" into Google search
When I press Search button
Then You should get a "Drill" entry in search results
Then You should get a "Fandom" entry in search results
2 changes: 1 addition & 1 deletion SpecDrill.Samples.NUnit/Features/GoogleSearch.feature.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions SpecDrill.Samples.NUnit/SpecDrill.Samples.NUnit3.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>

Expand All @@ -11,15 +11,15 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Allure.NUnit" Version="2.10.0" />
<PackageReference Include="Allure.NUnit" Version="2.11.0" />
<PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="NUnit" Version="3.14.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="NUnit" Version="4.1.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageReference Include="Selenium.WebDriver.ChromeDriver" Version="119.0.6045.10500" />
<PackageReference Include="SpecDrill" Version="1.3.0.1287" />
<PackageReference Include="SpecDrill.NUnit3" Version="1.3.0.875" />
<PackageReference Include="SpecDrill.SpecFlow" Version="1.3.0.970" />
<PackageReference Include="Selenium.WebDriver.ChromeDriver" Version="122.0.6261.11100" />
<PackageReference Include="SpecDrill" Version="1.4.0.3" />
<PackageReference Include="SpecDrill.NUnit3" Version="1.4.0.3" />
<PackageReference Include="SpecDrill.SpecFlow" Version="1.4.0.3" />
<PackageReference Include="SpecFlow" Version="3.9.74" />
<PackageReference Include="SpecFlow.NUnit" Version="3.9.74" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion SpecDrill.Samples.NUnit/specDrillConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"seleniumServerUri": "http://localhost:5555/wd/hub",
"drivers": {
"chrome": {
"path": "%USERPROFILE%\\.nuget\\packages\\selenium.webdriver.chromedriver\\117.0.5938.8800\\driver\\win32", //"C:\\Your Browser Drivers Path"//
"path": "%USERPROFILE%\\.nuget\\packages\\selenium.webdriver.chromedriver\\122.0.6261.11100\\driver\\win32", //"C:\\Your Browser Drivers Path"//
"arguments": [ "--incognito" ] //add , "headless" for headless test run
},
"ie": { "path": "" },
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<RestoreSources>$(RestoreSources)</RestoreSources>
<TargetFrameworks>net7.0</TargetFrameworks>
<TargetFrameworks>net8.0</TargetFrameworks>
<Nullable>enable</Nullable>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<PackageIcon>specdrill.png</PackageIcon>
<BuildNumber>1330</BuildNumber>
<Version>1.3.0.$(BuildNumber)</Version>
<BuildNumber>4</BuildNumber>
<Version>1.4.0.$(BuildNumber)</Version>
<Deterministic>true</Deterministic>
<Description>SpecDrill.SecondaryPorts.Adapters.WebDriver - WebDriver adapter for SpecDrill</Description>
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
Expand All @@ -20,12 +20,12 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Appium.WebDriver" Version="4.4.5" />
<PackageReference Include="Selenium.Support" Version="4.15.0" />
<PackageReference Include="Selenium.WebDriver" Version="4.15.0" />
<PackageReference Include="SpecDrill" Version="1.3.0.1287" />
<PackageReference Include="SpecDrill.Infrastructure" Version="1.3.0.550" />
<PackageReference Include="Selenium.Support" Version="4.18.1" />
<PackageReference Include="Selenium.WebDriver" Version="4.18.1" />
<PackageReference Include="SpecDrill" Version="1.4.0.3" />
<PackageReference Include="SpecDrill.Infrastructure" Version="1.4.0.3" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="8.0.0" />
<PackageReference Include="itext7" Version="8.0.2" />
<PackageReference Include="itext7" Version="8.0.3" />
</ItemGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<WarningLevel>2</WarningLevel>
Expand Down
12 changes: 6 additions & 6 deletions SpecDrill.SpecFlow/SpecDrill.SpecFlow.csproj
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<RestoreSources>$(RestoreSources)</RestoreSources>
<TargetFrameworks>net7.0</TargetFrameworks>
<TargetFrameworks>net8.0</TargetFrameworks>
<Nullable>enable</Nullable>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<PackageIcon>specdrill.png</PackageIcon>
<BuildNumber>974</BuildNumber>
<Version>1.3.0.$(BuildNumber)</Version>
<BuildNumber>4</BuildNumber>
<Version>1.4.0.$(BuildNumber)</Version>
<Description>SpecDrill.SpecFlow - SpecDrill integration with SpecFlow </Description>
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
<PackageReleaseNotes>
Expand All @@ -15,8 +15,8 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
<PackageReference Include="SpecDrill" Version="1.3.0.1287" />
<PackageReference Include="SpecDrill.Secondary.Adapters.WebDriver" Version="[1.3.*,)" />
<PackageReference Include="SpecDrill" Version="1.4.0.3" />
<PackageReference Include="SpecDrill.Secondary.Adapters.WebDriver" Version="1.4.0.3" />
<PackageReference Include="SpecFlow" Version="3.9.74" IncludeAssets="All" />
<None Include="..\LICENSE" Pack="true" PackagePath=".\" />
<None Include="..\specdrill.png" Pack="true" PackagePath=".\" />
Expand Down
18 changes: 9 additions & 9 deletions SpecDrill.Tests/SpecDrill.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<RestoreSources>$(RestoreSources)</RestoreSources>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<IsPackable>false</IsPackable>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down Expand Up @@ -34,29 +34,29 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="coverlet.msbuild" Version="6.0.0">
<PackageReference Include="coverlet.msbuild" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="MSTest.TestAdapter" Version="3.1.1" />
<PackageReference Include="coverlet.collector" Version="6.0.0">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="MSTest.TestAdapter" Version="3.2.2" />
<PackageReference Include="coverlet.collector" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="MSTest.TestFramework" Version="3.1.1" />
<PackageReference Include="NReco.Logging.File" Version="1.1.7" />
<PackageReference Include="MSTest.TestFramework" Version="3.2.2" />
<PackageReference Include="NReco.Logging.File" Version="1.2.0" />
<!--<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.3.1" />-->
<PackageReference Include="Selenium.WebDriver.ChromeDriver" Version="119.0.6045.10500" />
<PackageReference Include="Selenium.WebDriver.ChromeDriver" Version="122.0.6261.11100" />
<!--<PackageReference Include="Selenium.WebDriver.MSEdgeDriver" Version="109.0.1518.61" />-->
<!--<PackageReference Include="SpecDrill.MsTest" Version="[1.1.15.*,)" />
<PackageReference Include="SpecDrill.SpecFlow" Version="[1.1.14.*,)" />-->
<!--<PackageReference Include="SpecFlow" Version="3.9.74" />
<PackageReference Include="SpecFlow.MsTest" Version="3.9.74" />-->
<!--<PackageReference Include="SpecFlow.Tools.MsBuild.Generation" Version="3.9.74" />-->
<PackageReference Include="System.Text.Json" Version="8.0.0" />
<PackageReference Include="System.Text.Json" Version="8.0.3" />
</ItemGroup>

<ItemGroup>
Expand Down
10 changes: 5 additions & 5 deletions SpecDrill/SpecDrill.csproj
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<RestoreSources>$(RestoreSources)</RestoreSources>
<PackageSource>bin\$(Configuration)\Package</PackageSource>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<PackageIcon>specdrill.png</PackageIcon>
<BuildNumber>1291</BuildNumber>
<Version>1.3.0.$(BuildNumber)</Version>
<BuildNumber>4</BuildNumber>
<Version>1.4.0.$(BuildNumber)</Version>
<Description>SpecDrill - An opinionated automated testing framework based on Selenium WebDriver</Description>
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
<PackageReleaseNotes>
Expand All @@ -24,7 +24,7 @@
<ItemGroup>
<!--<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.5.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.5.0" />-->
<PackageReference Include="SpecDrill.Infrastructure" Version="1.3.0.550" />
<PackageReference Include="SpecDrill.Infrastructure" Version="1.4.0.3" />
</ItemGroup>
<ItemGroup>
<Compile Remove="bin\**" />
Expand Down
19 changes: 14 additions & 5 deletions SpecDrill/WebControls/ListElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text.RegularExpressions;

namespace SpecDrill
Expand Down Expand Up @@ -50,11 +51,19 @@ public T GetElementByIndex(int index)

public T GetElementByText(string regex)
{
var elements = this.ToArray();
var match = elements.FirstOrDefault(
item =>
Regex.IsMatch(item.Text, regex, RegexOptions.None, TimeSpan.FromSeconds(30))
);
T? match;
if (this.locator.LocatorType == By.XPath)
{
match = ElementFactory.CreateControl<T>(parent, ElementLocatorFactory.Create(By.XPath, locator.LocatorValue + $"[.//text()[contains(.,'{regex}')]]"));
}
else
{
var elements = this.ToArray();
match = elements.FirstOrDefault(
item =>
Regex.IsMatch(item.Text, regex, RegexOptions.None, TimeSpan.FromSeconds(30))
);
}

if (match == default(T))
throw new Exception($"SpecDrill: No element matching '{regex}' was found!");
Expand Down

0 comments on commit 650fc55

Please sign in to comment.