|
1 | 1 | namespace Legerity.Pages |
2 | 2 | { |
3 | 3 | using System; |
4 | | - |
| 4 | + using System.Collections.ObjectModel; |
| 5 | + using System.Linq; |
5 | 6 | using Legerity.Exceptions; |
6 | | - |
| 7 | + using Legerity.Extensions; |
7 | 8 | using OpenQA.Selenium; |
8 | 9 | using OpenQA.Selenium.Appium.Android; |
9 | 10 | using OpenQA.Selenium.Appium.iOS; |
@@ -75,6 +76,66 @@ protected BasePage(TimeSpan? traitTimeout) |
75 | 76 | /// </summary> |
76 | 77 | protected abstract By Trait { get; } |
77 | 78 |
|
| 79 | + /// <summary> |
| 80 | + /// Finds the first element in the page that matches the <see cref="By" /> locator. |
| 81 | + /// </summary> |
| 82 | + /// <param name="locator">The locator to find the element.</param> |
| 83 | + /// <returns>A <see cref="RemoteWebElement"/>.</returns> |
| 84 | + public RemoteWebElement FindElement(By locator) |
| 85 | + { |
| 86 | + return this.App.FindWebElement(locator); |
| 87 | + } |
| 88 | + |
| 89 | + /// <summary> |
| 90 | + /// Finds all the elements in the page that matches the <see cref="By" /> locator. |
| 91 | + /// </summary> |
| 92 | + /// <param name="locator">The locator to find the elements.</param> |
| 93 | + /// <returns>A readonly collection of <see cref="RemoteWebElement"/>.</returns> |
| 94 | + public ReadOnlyCollection<RemoteWebElement> FindElements(By locator) |
| 95 | + { |
| 96 | + return this.App.FindWebElements(locator); |
| 97 | + } |
| 98 | + |
| 99 | + /// <summary> |
| 100 | + /// Finds the first element in the page that matches the specified XPath. |
| 101 | + /// </summary> |
| 102 | + /// <param name="xpath">The XPath to find the element.</param> |
| 103 | + /// <returns>A <see cref="RemoteWebElement"/>.</returns> |
| 104 | + public RemoteWebElement FindElementByXPath(string xpath) |
| 105 | + { |
| 106 | + return this.App.FindElementByXPath(xpath) as RemoteWebElement; |
| 107 | + } |
| 108 | + |
| 109 | + /// <summary> |
| 110 | + /// Finds all the elements in the page that matches the specified XPath. |
| 111 | + /// </summary> |
| 112 | + /// <param name="xpath">The XPath to find the elements.</param> |
| 113 | + /// <returns>A readonly collection of <see cref="RemoteWebElement"/>.</returns> |
| 114 | + public ReadOnlyCollection<RemoteWebElement> FindElementsByXPath(string xpath) |
| 115 | + { |
| 116 | + return this.App.FindElementsByXPath(xpath).Cast<RemoteWebElement>().ToList().AsReadOnly(); |
| 117 | + } |
| 118 | + |
| 119 | + /// <summary> |
| 120 | + /// Finds the first element in the page that matches the specified ID. |
| 121 | + /// </summary> |
| 122 | + /// <param name="id">The ID of the element.</param> |
| 123 | + /// <returns>A <see cref="RemoteWebElement"/>.</returns> |
| 124 | + public RemoteWebElement FindElementById(string id) |
| 125 | + { |
| 126 | + return this.App.FindElementById(id) as RemoteWebElement; |
| 127 | + } |
| 128 | + |
| 129 | + /// <summary> |
| 130 | + /// Finds the first of element in the page that matches the specified name. |
| 131 | + /// </summary> |
| 132 | + /// <param name="name">The name of the element.</param> |
| 133 | + /// <returns>A <see cref="RemoteWebElement"/>.</returns> |
| 134 | + public RemoteWebElement FindElementByName(string name) |
| 135 | + { |
| 136 | + return this.App.FindElementByName(name) as RemoteWebElement; |
| 137 | + } |
| 138 | + |
78 | 139 | /// <summary> |
79 | 140 | /// Determines whether the current page is shown immediately. |
80 | 141 | /// </summary> |
|
0 commit comments