Skip to content

Commit 26719ee

Browse files
committed
docs: add a basic UiScrollable example to the advanced By README
1 parent 26b3ddc commit 26719ee

File tree

1 file changed

+12
-1
lines changed
  • src/main/java/io/appium/java_client/pagefactory

1 file changed

+12
-1
lines changed

src/main/java/io/appium/java_client/pagefactory/README.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@ Here are some ways you could configure a UiSelector in your project:
101101
// Create a selector that looks for the text "Hello World":
102102
@AndroidFindBy(uiAutomator = "new UiSelector().text(\"Hello World\")")
103103

104+
// Create a selector that tries to find an ImageView:
105+
@AndroidFindBy(uiAutomator = "new UiSelector().className(\"android.widget.ImageView\")")
106+
104107
// Create a selector that matches resource ids against a regular expression:
105108
private static final String looksLikeAPage = "page_number_\d*";
106109
@AndroidFindBy(uiAutomator = "new UiSelector().resourceIdMatches(\"" + looksLikeAPage + "\")")
@@ -118,5 +121,13 @@ private static final String looksLikeAPage = "page_number_\d*";
118121
..and here are some that create UiScrollable objects:
119122

120123
```java
121-
// TODO: Provide samples
124+
private static final String ourImageSelector = ".className(\"android.widget.ImageView\")";
125+
private static final String ourListSelector = ".className(\"android.widget.ListView\")";
126+
127+
// Create a scrollable associated with a list (by itself, this doesn't do anything useful...)
128+
@AndroidFindBy(uiAutomator = "new UiScrollable(" + ourListSelector + ")")
129+
130+
// Create a scrollable that scrolls forward along a list until it finds an ImageView:
131+
@AndroidFindBy(uiAutomator = "new UiScrollable(" + ourListSelector + ").scrollIntoView(" + ourImageSelector + ")")
132+
122133
```

0 commit comments

Comments
 (0)