diff --git a/src/Legerity.Core/Extensions/PageExtensions.cs b/src/Legerity.Core/Extensions/PageExtensions.cs index e71268d0..576d6bf7 100644 --- a/src/Legerity.Core/Extensions/PageExtensions.cs +++ b/src/Legerity.Core/Extensions/PageExtensions.cs @@ -1,8 +1,10 @@ namespace Legerity.Extensions { using System; + using System.Collections.ObjectModel; using Legerity.Pages; using OpenQA.Selenium; + using OpenQA.Selenium.Remote; using OpenQA.Selenium.Support.UI; /// diff --git a/src/Legerity.Core/Pages/BasePage.cs b/src/Legerity.Core/Pages/BasePage.cs index 48d42236..74f0cb8b 100644 --- a/src/Legerity.Core/Pages/BasePage.cs +++ b/src/Legerity.Core/Pages/BasePage.cs @@ -1,9 +1,10 @@ namespace Legerity.Pages { using System; - + using System.Collections.ObjectModel; + using System.Linq; using Legerity.Exceptions; - + using Legerity.Extensions; using OpenQA.Selenium; using OpenQA.Selenium.Appium.Android; using OpenQA.Selenium.Appium.iOS; @@ -75,6 +76,66 @@ protected BasePage(TimeSpan? traitTimeout) /// protected abstract By Trait { get; } + /// + /// Finds the first element in the page that matches the locator. + /// + /// The locator to find the element. + /// A . + public RemoteWebElement FindElement(By locator) + { + return this.App.FindWebElement(locator); + } + + /// + /// Finds all the elements in the page that matches the locator. + /// + /// The locator to find the elements. + /// A readonly collection of . + public ReadOnlyCollection FindElements(By locator) + { + return this.App.FindWebElements(locator); + } + + /// + /// Finds the first element in the page that matches the specified XPath. + /// + /// The XPath to find the element. + /// A . + public RemoteWebElement FindElementByXPath(string xpath) + { + return this.App.FindElementByXPath(xpath) as RemoteWebElement; + } + + /// + /// Finds all the elements in the page that matches the specified XPath. + /// + /// The XPath to find the elements. + /// A readonly collection of . + public ReadOnlyCollection FindElementsByXPath(string xpath) + { + return this.App.FindElementsByXPath(xpath).Cast().ToList().AsReadOnly(); + } + + /// + /// Finds the first element in the page that matches the specified ID. + /// + /// The ID of the element. + /// A . + public RemoteWebElement FindElementById(string id) + { + return this.App.FindElementById(id) as RemoteWebElement; + } + + /// + /// Finds the first of element in the page that matches the specified name. + /// + /// The name of the element. + /// A . + public RemoteWebElement FindElementByName(string name) + { + return this.App.FindElementByName(name) as RemoteWebElement; + } + /// /// Determines whether the current page is shown immediately. ///