@@ -104,6 +104,15 @@ public static By AndroidUIAutomator(IUiAutomatorStatementBuilder selector) =>
104
104
/// <returns></returns>
105
105
public static By AndroidDataMatcher ( string selector ) => new ByAndroidDataMatcher ( selector ) ;
106
106
107
+ /// <summary>
108
+ /// This method creates a <see cref="OpenQA.Selenium.By"/> strategy
109
+ /// that searches for elements using Espresso's View Matcher.
110
+ /// <see cref="https://developer.android.com/training/testing/espresso/basics#finding-view"/>
111
+ /// </summary>
112
+ /// <param name="selector">The selector to use in finding the element.</param>
113
+ /// <returns></returns>
114
+ public static By AndroidViewMatcher ( string selector ) => new ByAndroidViewMatcher ( selector ) ;
115
+
107
116
/// <summary>
108
117
/// This method creates a <see cref="OpenQA.Selenium.By"/> strategy
109
118
/// that searches for elements using iOS UI automation.
@@ -232,6 +241,38 @@ public override string ToString() =>
232
241
$ "ByAndroidDataMatcher({ selector } )";
233
242
}
234
243
244
+ /// <summary>
245
+ /// Finds element when the Espresso's View Matcher selector has the specified value.
246
+ /// <see cref="https://developer.android.com/training/testing/espresso/basics#finding-view"/>
247
+ /// </summary>
248
+ public class ByAndroidViewMatcher : MobileBy
249
+ {
250
+ /// <summary>
251
+ /// Initializes a new instance of the <see cref="ByAndroidViewMatcher"/> class.
252
+ /// </summary>
253
+ /// <param name="selector">The selector to use in finding the element.</param>
254
+ public ByAndroidViewMatcher ( string selector ) : base ( selector , MobileSelector . AndroidViewMatcher )
255
+ {
256
+ }
257
+
258
+ public override IWebElement FindElement ( ISearchContext context )
259
+ {
260
+ if ( context is IFindByAndroidViewMatcher < IWebElement > finder )
261
+ return finder . FindElementByAndroidViewMatcher ( selector ) ;
262
+ return base . FindElement ( context ) ;
263
+ }
264
+
265
+ public override ReadOnlyCollection < IWebElement > FindElements ( ISearchContext context )
266
+ {
267
+ if ( context is IFindByAndroidViewMatcher < IWebElement > finder )
268
+ return finder . FindElementsByAndroidViewMatcher ( selector ) . ToList ( ) . AsReadOnly ( ) ;
269
+ return base . FindElements ( context ) ;
270
+ }
271
+
272
+ public override string ToString ( ) =>
273
+ $ "ByAndroidViewMatcher({ selector } )";
274
+ }
275
+
235
276
/// <summary>
236
277
/// Finds element when the Ios UIAutomation selector has the specified value.
237
278
/// <see cref="https://developer.apple.com/library/tvos/documentation/DeveloperTools/Conceptual/InstrumentsUserGuide/UIAutomation.html"/>
0 commit comments