Last active
January 20, 2020 19:10
-
-
Save sauceaaron/5bc1d365569e8bdaa829ec666ab9c84e to your computer and use it in GitHub Desktop.
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
import java.net.MalformedURLException; | |
import java.net.URL; | |
public class FindByText | |
{ | |
URL url = new URL("https://ondemand.saucelabs.com/wd/hub"); | |
DesiredCapabilities capabilities = new DesiredCapabilities(); | |
//... set capabilities; | |
@Test | |
public void findByTextWithIOSPredicateString() | |
{ | |
IOSDriver<MobileElement> driver = new IOSDriver<>(url, capabilities); | |
String IOSLocator = "value contains 'whatever'"; | |
ios.findElement(MobileBy.iOSNsPredicateString(IOSLocator)); | |
} | |
@Test | |
public void findByTextWithAndroidUIAutomation() | |
{ | |
AndroidDriver<MobileElement> driver = new AndroidDriver<>(url, capabilities); | |
String AndroidLocator = "new UiSelector().textContains(\"whatever\")"; | |
android.findElement(MobileBy.AndroidUIAutomator(AndroidLocator)); | |
} | |
@Test | |
public void findByTextWithXPath() | |
{ | |
AppiumDriver<MobileElement> driver = new AppiumDriver<>(url, capabilities); | |
String XPathLocator = "//*[contains(text(), \"whatever\"]"; | |
driver.findElement(MobileBy.xpath(XPathLocator)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment