diff --git a/Aquality.Selenium/Aquality.Selenium.sln b/Aquality.Selenium/Aquality.Selenium.sln index 15de1139..06e31b1f 100644 --- a/Aquality.Selenium/Aquality.Selenium.sln +++ b/Aquality.Selenium/Aquality.Selenium.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.29009.5 +# Visual Studio Version 17 +VisualStudioVersion = 17.8.34309.116 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{43453468-EBA2-4800-B6CA-765FA722BA61}" EndProject @@ -11,6 +11,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Aquality.Selenium.Tests", " EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{999ED05C-B034-45A1-8F11-2B519C308250}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aquality.Selenium.Images", "src\Aquality.Selenium.Images\Aquality.Selenium.Images.csproj", "{72EB3821-6AB9-465C-9B88-D878D677C754}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -25,6 +27,10 @@ Global {856AE8E1-31EF-49A1-B6EB-C72BF12432F8}.Debug|Any CPU.Build.0 = Debug|Any CPU {856AE8E1-31EF-49A1-B6EB-C72BF12432F8}.Release|Any CPU.ActiveCfg = Release|Any CPU {856AE8E1-31EF-49A1-B6EB-C72BF12432F8}.Release|Any CPU.Build.0 = Release|Any CPU + {72EB3821-6AB9-465C-9B88-D878D677C754}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {72EB3821-6AB9-465C-9B88-D878D677C754}.Debug|Any CPU.Build.0 = Debug|Any CPU + {72EB3821-6AB9-465C-9B88-D878D677C754}.Release|Any CPU.ActiveCfg = Release|Any CPU + {72EB3821-6AB9-465C-9B88-D878D677C754}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -32,6 +38,7 @@ Global GlobalSection(NestedProjects) = preSolution {B0E3FDB8-CF47-40D2-AC0E-FB12F66D1F26} = {43453468-EBA2-4800-B6CA-765FA722BA61} {856AE8E1-31EF-49A1-B6EB-C72BF12432F8} = {999ED05C-B034-45A1-8F11-2B519C308250} + {72EB3821-6AB9-465C-9B88-D878D677C754} = {43453468-EBA2-4800-B6CA-765FA722BA61} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {0AC8C847-FF57-4A72-8E22-F0947E17DFAF} diff --git a/Aquality.Selenium/src/Aquality.Selenium.Images/Aquality.Selenium.Images.csproj b/Aquality.Selenium/src/Aquality.Selenium.Images/Aquality.Selenium.Images.csproj new file mode 100644 index 00000000..cd243240 --- /dev/null +++ b/Aquality.Selenium/src/Aquality.Selenium.Images/Aquality.Selenium.Images.csproj @@ -0,0 +1,50 @@ + + + + netstandard2.0 + false + true + aquality automation committers + aquality automation + Support classes to work with Images in Aquality.Selenium, such as ByImage locator + Support classes to work with Images in Aquality.Selenium, such as ByImage locator + + https://github.com/aquality-automation/aquality-selenium-dotnet + git + selenium webdriver browser automation image locator + LICENSE + README.md + Copyright 2024 Aquality Automation + true + + + + Aquality.Selenium.Images.xml + 1591 + + + + + + + + True + + + + + + True + + + + + + + + + + + + + diff --git a/Aquality.Selenium/src/Aquality.Selenium.Images/Aquality.Selenium.Images.xml b/Aquality.Selenium/src/Aquality.Selenium.Images/Aquality.Selenium.Images.xml new file mode 100644 index 00000000..77146b23 --- /dev/null +++ b/Aquality.Selenium/src/Aquality.Selenium.Images/Aquality.Selenium.Images.xml @@ -0,0 +1,58 @@ + + + + Aquality.Selenium.Images + + + + + Locator to search elements by image. + Takes screenshot and finds match using openCV. + Then finds elements by coordinates using JavaScript. + + + + + Constructor accepting image file. + + Image file to locate element by. + + + + Constructor accepting image bytes. + + Image bytes to locate element by. + + + + Threshold of image similarity. + Should be a float between 0 and 1, where 1 means 100% match, and 0.5 means 50% match. + + + + + Gets a single element on point (find by center coordinates, then select closest to matchLocation). + + Location of the upper-left point of the element. + Search context. + If the searchContext is Locatable (like WebElement), will adjust coordinates to be absolute coordinates. + The closest found element. + + + + Calculates distance from element to matching point. + + Matching point. + Target element. + Distance in pixels. + + + + Takes screenshot from searchContext if supported, or from browser. + Performs screenshot scaling if devicePixelRatio != 1. + + Search context for element location. + Captured screenshot as Mat object. + + + diff --git a/Aquality.Selenium/src/Aquality.Selenium/Elements/Interfaces/ByImage.cs b/Aquality.Selenium/src/Aquality.Selenium.Images/Locators/ByImage.cs similarity index 99% rename from Aquality.Selenium/src/Aquality.Selenium/Elements/Interfaces/ByImage.cs rename to Aquality.Selenium/src/Aquality.Selenium.Images/Locators/ByImage.cs index 170e487f..f2516de8 100644 --- a/Aquality.Selenium/src/Aquality.Selenium/Elements/Interfaces/ByImage.cs +++ b/Aquality.Selenium/src/Aquality.Selenium.Images/Locators/ByImage.cs @@ -8,7 +8,7 @@ using System.IO; using System.Linq; -namespace Aquality.Selenium.Elements.Interfaces +namespace Aquality.Selenium.Images.Locators { /// /// Locator to search elements by image. diff --git a/Aquality.Selenium/src/Aquality.Selenium/Aquality.Selenium.csproj b/Aquality.Selenium/src/Aquality.Selenium/Aquality.Selenium.csproj index 8ae7a48d..dc436fb0 100644 --- a/Aquality.Selenium/src/Aquality.Selenium/Aquality.Selenium.csproj +++ b/Aquality.Selenium/src/Aquality.Selenium/Aquality.Selenium.csproj @@ -14,6 +14,7 @@ git selenium webdriver browser automation LICENSE + README.md Copyright 2024 Aquality Automation true @@ -41,6 +42,10 @@ True + + True + + @@ -86,14 +91,8 @@ - - + - - - - - diff --git a/Aquality.Selenium/src/Aquality.Selenium/Aquality.Selenium.xml b/Aquality.Selenium/src/Aquality.Selenium/Aquality.Selenium.xml index 0c89c3ce..96c38792 100644 --- a/Aquality.Selenium/src/Aquality.Selenium/Aquality.Selenium.xml +++ b/Aquality.Selenium/src/Aquality.Selenium/Aquality.Selenium.xml @@ -1920,56 +1920,6 @@ Possible element hightlight states (on/off). - - - Locator to search elements by image. - Takes screenshot and finds match using openCV. - Then finds elements by coordinates using JavaScript. - - - - - Constructor accepting image file. - - Image file to locate element by. - - - - Constructor accepting image bytes. - - Image bytes to locate element by. - - - - Threshold of image similarity. - Should be a float between 0 and 1, where 1 means 100% match, and 0.5 means 50% match. - - - - - Gets a single element on point (find by center coordinates, then select closest to matchLocation). - - Location of the upper-left point of the element. - Search context. - If the searchContext is Locatable (like WebElement), will adjust coordinates to be absolute coordinates. - The closest found element. - - - - Calculates distance from element to matching point. - - Matching point. - Target element. - Distance in pixels. - - - - Takes screenshot from searchContext if supported, or from browser. - Performs screenshot scaling if devicePixelRatio != 1. - - Search context for element location. - Captured screenshot as Mat object. - Describes behavior of Button UI element. diff --git a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Aquality.Selenium.Tests.csproj b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Aquality.Selenium.Tests.csproj index ecd0b4c9..27765f0e 100644 --- a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Aquality.Selenium.Tests.csproj +++ b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Aquality.Selenium.Tests.csproj @@ -34,10 +34,11 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + + diff --git a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/DevToolsEmulationTests.cs b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/DevToolsEmulationTests.cs index fee2c299..a81d2cc2 100644 --- a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/DevToolsEmulationTests.cs +++ b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/DevToolsEmulationTests.cs @@ -59,11 +59,11 @@ public void Should_BePossibleTo_SetAndClearDeviceMetricsOverride_WithVersionSpec { void setAction(long width, long height, bool isMobile, double scaleFactor) { - var parameters = new OpenQA.Selenium.DevTools.V128.Emulation.SetDeviceMetricsOverrideCommandSettings + var parameters = new OpenQA.Selenium.DevTools.V129.Emulation.SetDeviceMetricsOverrideCommandSettings { - DisplayFeature = new OpenQA.Selenium.DevTools.V128.Emulation.DisplayFeature + DisplayFeature = new OpenQA.Selenium.DevTools.V129.Emulation.DisplayFeature { - Orientation = OpenQA.Selenium.DevTools.V128.Emulation.DisplayFeatureOrientationValues.Horizontal + Orientation = OpenQA.Selenium.DevTools.V129.Emulation.DisplayFeatureOrientationValues.Horizontal }, Width = width, Height = height, diff --git a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/ImageLocatorTests.cs b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/ImageLocatorTests.cs index adfe3c83..f5b59eea 100644 --- a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/ImageLocatorTests.cs +++ b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/ImageLocatorTests.cs @@ -1,5 +1,6 @@ using Aquality.Selenium.Browsers; using Aquality.Selenium.Elements.Interfaces; +using Aquality.Selenium.Images.Locators; using Aquality.Selenium.Tests.Integration.TestApp.TheInternet.Forms; using NUnit.Framework; using OpenQA.Selenium; diff --git a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/TestApp/Browser/ChromeDownloadsForm.cs b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/TestApp/Browser/ChromeDownloadsForm.cs index b370d487..faa4255f 100644 --- a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/TestApp/Browser/ChromeDownloadsForm.cs +++ b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/TestApp/Browser/ChromeDownloadsForm.cs @@ -10,7 +10,7 @@ internal class ChromeDownloadsForm : Form { private const string Address = "chrome://downloads/"; - public static By NestedShadowRootLocator => By.Id("moreActionsMenu"); + public static By NestedShadowRootLocator => By.CssSelector("cr-toolbar"); public ILabel DownloadsToolbarLabel => FormElement.FindElementInShadowRoot(By.CssSelector("downloads-toolbar"), "Downloads toolbar"); public IList DivElementLabels => FormElement.FindElementsInShadowRoot(By.CssSelector("div"), "div"); public IList MainContainerLabels => FormElement.FindElementsInShadowRoot(By.Id("mainContainer"), "main container"); diff --git a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/TestApp/TheInternet/Forms/BrokenImagesForm.cs b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/TestApp/TheInternet/Forms/BrokenImagesForm.cs index f716a521..f8789f08 100644 --- a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/TestApp/TheInternet/Forms/BrokenImagesForm.cs +++ b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/TestApp/TheInternet/Forms/BrokenImagesForm.cs @@ -3,6 +3,7 @@ using System.IO; using System; using System.Collections.Generic; +using Aquality.Selenium.Images.Locators; namespace Aquality.Selenium.Tests.Integration.TestApp.TheInternet.Forms { diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 38ce301a..2af6c9ad 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -80,7 +80,7 @@ stages: useConfigFile: true configFilePath: 'GitVersion.yml' - - script: dotnet pack Aquality.Selenium\src\Aquality.Selenium\Aquality.Selenium.csproj -c $(buildConfiguration) -p:Version=$(GitVersion.NuGetVersion) -o $(Build.ArtifactStagingDirectory) + - script: dotnet pack Aquality.Selenium\Aquality.Selenium.sln -c $(buildConfiguration) -p:Version=$(GitVersion.NuGetVersion) -o $(Build.ArtifactStagingDirectory) displayName: 'Pack to NuGet package' - task: GitHubRelease@0