@Test public void findByAccessibilityIdFromDriverTest() { assertNotEquals(driver.findElementByAccessibilityId("Graphics").getText(), null); assertEquals(driver.findElementsByAccessibilityId("Graphics").size(), 1); }
/** * Searches for element by accessibility id * * @param using Accessibility ID value to search for * @return Element that matched search criteria */ public WebElement findElementByAccessibilityId(String using) { return this.driver.findElementByAccessibilityId(using); }
@Ignore @Test public void whenIOSHybridAppIsLaunched() { assertTrue(check(serverAppCapabilitiesSupplier, appFileSupplierFunction.apply(webViewApp), (by, aClass) -> { new WebDriverWait(driver, 30) .until(ExpectedConditions.presenceOfElementLocated(id("login"))) .click(); driver.findElementByAccessibilityId("webView").click(); new WebDriverWait(driver, 30) .until(ExpectedConditions .presenceOfElementLocated(AccessibilityId("Webview"))); try { Thread.sleep(10000); } catch (InterruptedException e) { e.printStackTrace(); } driver.getContextHandles().forEach((handle) -> { if (handle.contains("WEBVIEW")) { driver.context(handle); } }); return commonPredicate.test(by, aClass); }, partialLinkText("login"), IOSElement.class)); }
@Test public void scrollingToSubElement() { driver.findElementByAccessibilityId("Views").click(); AndroidElement list = driver.findElement(By.id("android:id/list")); MobileElement radioGroup = list .findElement(MobileBy .AndroidUIAutomator("new UiScrollable(new UiSelector()).scrollIntoView(" + "new UiSelector().text(\"Radio Group\"));")); assertNotNull(radioGroup.getLocation()); }
/** * Presses the up button in the toolbar */ public void navigateUp() { driver.findElementByAccessibilityId("Navigate up").click(); }
/** * * @return the counter text */ public String getCounter() { return driver.findElementByAccessibilityId("Level Display").getText(); } }
public void gameCenterLogin() throws Exception { if (driver.getPageSource().contains("Sign in")) { log("Google Plus sign in shown..."); log(driver.getPageSource()); takeScreenshot("google_plus_sign_in_shown"); while (driver.getPageSource().contains("Sign in")) if (automationName.equalsIgnoreCase("selendroid")) { driver.findElement(By.xpath("//LinearLayout/Button[@text='Sign in']")).click(); } else if (platform.equals(PlatformType.ANDROID)) { driver.findElement(By.xpath("//android.widget.Button[@text='Sign in']")).click(); } else { //we are on ios driver.findElementByAccessibilityId("Sign In").click(); } takeScreenshot("after_clicking_sign_in"); } }
public void cancelGameCenterLogin() throws Exception { log("Check to see if Google Plus Sign in needs to be cancelled.."); if (driver.getPageSource().contains("Choose an account")) { if (automationName.equalsIgnoreCase("selendroid")) { driver.findElement(By.xpath("//LinearLayout/Button[@text='Cancel']")).click(); } else if (platform.equals(PlatformType.ANDROID)) { driver.findElement(By.xpath("//android.widget.Button[@text='Cancel']")).click(); } else { //we are on ios driver.findElementByAccessibilityId("Cancel").click(); } } if (automationName.equalsIgnoreCase("selendroid")) { ImageRecognitionSettings settings = new ImageRecognitionSettings(); settings.setRetries(1); while (findImageOnScreen("native_sign_in_button").isFound()) { tapImageOnScreen("native_sign_in_button", 0.75, 0.5, settings); } } else { if (driver.getPageSource().contains("SIGN IN") || (driver.getPageSource().contains("Sign in")) || (driver.getPageSource().contains("Sign In"))) { log("Google Plus sign in shown..."); takeScreenshot("google_plus_sign_in_shown"); driver.findElement(By.xpath("//android.widget.Button[@text='Cancel']")).click(); takeScreenshot("after_cancel_sign_in"); driver.findElement(By.xpath("//android.widget.Button[@text='Cancel']")).click(); takeScreenshot("after_second_cancel_sign_in"); } } }