Skip to content

Commit d286e4d

Browse files
committed
fix: describe index behavior in the advanced By README
1 parent d3c22a9 commit d286e4d

File tree

1 file changed

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

1 file changed

+12
-0
lines changed

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,15 @@ to learn more about the general concept.
7474
// Selector for image elements
7575
@iOSXCUITFindBy(iOSClassChain = "**/XCUIElementTypeImage")
7676

77+
// Selector for the first image element on screen
78+
@iOSXCUITFindBy(iOSClassChain = "**/XCUIElementTypeImage[1]")
79+
// Selector for the second image element on screen
80+
@iOSXCUITFindBy(iOSClassChain = "**/XCUIElementTypeImage[2]")
81+
// Selector for the last image element on screen
82+
@iOSXCUITFindBy(iOSClassChain = "**/XCUIElementTypeImage[-1]")
83+
// Selector for the penultimate image element on screen
84+
@iOSXCUITFindBy(iOSClassChain = "**/XCUIElementTypeImage[-2]")
85+
7786
// Selector for every cell with the name 'Foo' (single quote style)
7887
@iOSXCUITFindBy(iOSClassChain = "**/XCUIElementTypeCell[`name == 'Foo'`]")
7988
// Selector for every cell with the name "Foo" (double quote style)
@@ -91,6 +100,9 @@ to learn more about the general concept.
91100
@iOSXCUITFindBy(iOSClassChain = "*")
92101
// Selector that'll match every leaf element on screen (watch out: this can be SLOW)
93102
@iOSXCUITFindBy(iOSClassChain = "**/*")
103+
104+
// You can place an index after a predicate: the following finds the last image element with name 'Foo'
105+
@iOSXCUITFindBy(iOSClassChain = "**/XCUIElementTypeCell[`name == 'Foo'`][-1]")
94106
```
95107

96108
## Android's uiAutomator String

0 commit comments

Comments
 (0)