Last active
August 10, 2022 21:51
-
-
Save wswebcreation/f82b47c0c76a0d8d4c50ce3747120fa0 to your computer and use it in GitHub Desktop.
Preferred Native Appium Selectors for WebdriverIO
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The `~` tells WebdriverIO that it needs to look for an accessibiltyID | |
// Android: `content description` | |
// iOS: `accessibility id` | |
$('~accessibiltyID').click(); | |
// -ios predicate string | |
const loginButton = 'type == \'XCUIElementTypeOther\' && name CONTAINS \'test-LOGIN\''; | |
$(`-ios predicate string:${ loginButton }`).click(); | |
// -ios class chain, to make complex selectors | |
const classChainSwagItem = '**/XCUIElementTypeOther[`name CONTAINS "test-Item"`]/**/XCUIElementTypeOther[`name CONTAINS "Sauce Labs Bike Light" AND name CONTAINS "ADD TO CART"`]/**/XCUIElementTypeOther[`name == "test-ADD TO CART"`]'; | |
$(`-ios class chain:${ classChainSwagItem }`).click(); | |
// -android uiautomator | |
const androidButton = 'new UiSelector().text("Cancel").className("android.widget.Button")'; | |
$(`android=${androidButton}`).click(); | |
// className for iOS | |
$('UIATextField').click(); | |
// className for Android | |
$('android.widget.DatePicker').click(); | |
// XPATH | |
const xpathSwagItem = '//XCUIElementTypeStaticText[contains(@value,"Sauce Labs Bike Light")]//ancestor::*[@name="test-Item"]//*[@name="test-ADD TO CART"]'; | |
$(xpathSwagItem).click(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment