List of usage examples for org.openqa.selenium.support.ui ExpectedConditions elementToBeClickable
public static ExpectedCondition<WebElement> elementToBeClickable(final WebElement element)
From source file:org.apache.archiva.web.test.parent.AbstractArchivaTest.java
License:Apache License
public void deleteUser(String userName, String fullName, String emailAd, boolean validated, boolean locked) { clickLinkWithLocator("menu-users-list-a"); WebDriverWait wait = new WebDriverWait(getWebDriver(), 10); wait.until(ExpectedConditions.elementToBeClickable(By.id("users-grid-delete-" + userName))); assertTextPresent(userName);/*from w w w. j av a 2 s. c o m*/ assertTextPresent(fullName); clickLinkWithLocator("users-grid-delete-" + userName); wait.until(ExpectedConditions.elementToBeClickable(By.id("dialog-confirm-modal-ok"))); clickLinkWithLocator("dialog-confirm-modal-ok"); wait.until(ExpectedConditions.elementToBeClickable(By.id("alert-message-success-close-a"))); assertTextPresent("User " + userName + " deleted."); clickLinkWithLocator("alert-message-success-close-a"); assertElementNotPresent("users-grid-user-id-" + userName); assertTextNotPresent(fullName); }
From source file:org.apache.archiva.web.test.parent.AbstractSeleniumTest.java
License:Apache License
public void submitLoginPage(String username, String password, boolean rememberMe, boolean validUsernamePassword, String assertReturnPage) { logger.info("Activating login form"); // clickLinkWithLocator( "login-link-a", false); WebDriverWait wait = new WebDriverWait(getWebDriver(), 5); WebElement usernameField = wait.until( ExpectedConditions.visibilityOf(getWebDriver().findElement(By.id("user-login-form-username")))); wait = new WebDriverWait(getWebDriver(), 5); WebElement passwordField = wait.until( ExpectedConditions.visibilityOf(getWebDriver().findElement(By.id("user-login-form-password")))); wait = new WebDriverWait(getWebDriver(), 5); WebElement button = wait.until(ExpectedConditions.elementToBeClickable(By.id("modal-login-ok"))); usernameField.sendKeys(username);// w ww. j a va2 s. c om passwordField.sendKeys(password); /* if ( rememberMe ) { checkField( "rememberMe" ); }*/ button.click(); if (validUsernamePassword) { assertUserLoggedIn(username); } /* else { if ( "Login Page".equals( assertReturnPage ) ) { assertLoginPage(); } else { assertPage( assertReturnPage ); } }*/ }
From source file:org.apache.archiva.web.test.parent.AbstractSeleniumTest.java
License:Apache License
public <V> V tryClick(By clickableLocator, Function<? super WebDriver, V> conditions, String message, int attempts, int maxWaitTimeInS) { getWebDriver().manage().window().maximize(); int count = attempts; WebDriverWait wait = new WebDriverWait(getWebDriver(), maxWaitTimeInS); V result = null;//from w ww . j a v a2s . c om Exception ex = null; WebElement el = null; while (count > 0) { try { el = wait.until(ExpectedConditions.elementToBeClickable(clickableLocator)); Actions actions = new Actions(getWebDriver()); actions.moveToElement(el).click().perform(); result = wait.until(conditions); return result; } catch (Exception e) { logger.info("Error: {}, {}, {}", count, e.getClass().getName(), e.getMessage()); if (el != null) { // Elements may be stale and throw an exception, if the location is requested try { Point elLoc = el.getLocation(); logger.info("Location: x={} y={}", elLoc.getX(), elLoc.getY()); } catch (Throwable e2) { logger.info("Could not determine location"); } } ex = e; count--; } try { Thread.currentThread().sleep(500); } catch (InterruptedException e) { // Ignore } } if (ex != null) { Assert.fail(message); } return result; }
From source file:org.apache.archiva.web.test.RepositoryAdminTest.java
License:Apache License
@Test public void testManagedRepository() { // login( getAdminUsername(), getAdminPassword() ); WebDriverWait wait = new WebDriverWait(getWebDriver(), 20); WebElement el;/* w ww .jav a 2s. co m*/ el = wait.until(ExpectedConditions.elementToBeClickable(By.id("menu-repositories-list-a"))); tryClick(el, ExpectedConditions.presenceOfElementLocated(By.id("managed-repositories-view-a")), "Managed Repositories not activated"); el = wait.until( ExpectedConditions.elementToBeClickable(By.xpath("//a[@href='#remote-repositories-content']"))); tryClick(el, ExpectedConditions.visibilityOfElementLocated( By.xpath("//table[@id='remote-repositories-table']//td[contains(text(),'central')]")), "Remote Repositories View not available"); el = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//a[@href='#remote-repository-edit']"))); el = tryClick(el, ExpectedConditions.visibilityOfElementLocated(By.id("remote-repository-save-button")), "Repository Save Button not available"); setFieldValue("id", "myrepoid"); setFieldValue("name", "My repo name"); setFieldValue("url", "http://www.repo.org"); el = wait.until(ExpectedConditions.elementToBeClickable(By.id("remote-repository-save-button"))); Actions actions = new Actions(getWebDriver()); actions.moveToElement(el); actions.perform(); ((JavascriptExecutor) getWebDriver()).executeScript("arguments[0].scrollIntoView();", el); el.click(); el = wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("remote-repositories-view-a"))); ((JavascriptExecutor) getWebDriver()).executeScript("arguments[0].scrollIntoView();", el); tryClick(By.id("menu-proxy-connectors-list-a"), ExpectedConditions .visibilityOfElementLocated(By.id("proxy-connectors-view-tabs-a-network-proxies-grid")), "Network proxies not available", 3, 10); wait.until(ExpectedConditions.textToBePresentInElementLocated(By.id("main-content"), "Proxy Connectors")); // proxy connect wait.until(ExpectedConditions.textToBePresentInElementLocated(By.id("proxy-connectors-view"), "central")); assertTextNotPresent("myrepoid"); el = wait.until(ExpectedConditions.elementToBeClickable(By.id("proxy-connectors-view-tabs-a-edit"))); el.click(); el = wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("proxy-connector-btn-save"))); wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("remote-repository-edit-fieldset"))); // Another hack, don't know why the normal selectValue() does not work here ((JavascriptExecutor) getWebDriver()).executeScript("jQuery('#sourceRepoId').css('display','block')"); Select select = new Select(getWebDriver().findElement(By.xpath(".//select[@id='sourceRepoId']"))); select.selectByVisibleText("internal"); // selectValue( "sourceRepoId", "internal", true ); // Workaround // TODO: Check after upgrade of htmlunit, bootstrap or jquery // TODO: Check whats wrong here ((JavascriptExecutor) getWebDriver()).executeScript("$('#targetRepoId').show();"); // End of Workaround wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("targetRepoId"))); selectValue("targetRepoId", "myrepoid"); el.click(); wait.until( ExpectedConditions.textToBePresentInElementLocated(By.id("user-messages"), "ProxyConnector added")); wait.until(ExpectedConditions.textToBePresentInElementLocated(By.id("proxy-connectors-view"), "central")); wait.until(ExpectedConditions.textToBePresentInElementLocated(By.id("proxy-connectors-view"), "myrepoid")); tryClick(By.xpath("//i[contains(@class,'icon-resize-vertical')]//ancestor::a"), ExpectedConditions.visibilityOfAllElementsLocatedBy(By.id("proxy-connector-edit-order-div")), "Edit order view not visible", 3, 10); // clickLinkWithXPath( "//i[contains(@class,'icon-resize-vertical')]//ancestor::a"); // This is needed here for HTMLUnit Tests. Currently do not know why, wait is not working for the // list entries down // waitPage(); // el = wait.until(ExpectedConditions.presenceOfElementLocated(By.id("proxy-connector-edit-order-div"))); assertTextPresent("internal"); List<WebElement> repos = wait.until(ExpectedConditions .numberOfElementsToBe(By.xpath("//div[@id='proxy-connector-edit-order-div']/div"), 2)); Assert.assertTrue("First repo is myrepo", repos.get(0).getText().contains("myrepoid")); Assert.assertTrue("Second repo is central", repos.get(1).getText().contains("central")); // works until this point /*getSelenium().mouseDown( "xpath=//div[@id='proxy-connector-edit-order-div']/div[1]" ); getSelenium().mouseMove( "xpath=//div[@id='proxy-connector-edit-order-div']/div[2]" ); getSelenium().mouseUp( "xpath=//div[@id='proxy-connector-edit-order-div']/div[last()]" ); Assert.assertTrue( "Second repo is myrepo", getSelenium().getText("xpath=//div[@id='proxy-connector-edit-order-div']/div[2]" ).contains( "myrepoid" )); Assert.assertTrue( "First repo is central", getSelenium().getText("xpath=//div[@id='proxy-connector-edit-order-div']/div[1]" ).contains( "central" )); */ }
From source file:org.apache.archiva.web.test.RolesManagementTest.java
License:Apache License
@Test public void testReadRolesAndUpdateDescription() throws Exception { login(getAdminUsername(), getAdminPassword()); WebDriverWait wait = new WebDriverWait(getWebDriver(), 10); WebElement link = wait.until(ExpectedConditions.elementToBeClickable(By.id("menu-roles-list-a"))); tryClick(link, ExpectedConditions.textToBePresentInElementLocated(By.id("roles-view"), "Archiva System Administrator"), "Roles view not available"); Assert.assertTrue(StringUtils.isEmpty(getText("role-description-Guest"))); clickLinkWithLocator("edit-role-Guest"); wait.until(ExpectedConditions.elementToBeClickable(By.id("role-edit-description-save"))); String desc = "The guest description"; setFieldValue("role-edit-description", desc); clickButtonWithLocator("role-edit-description-save"); wait.until(//w w w . ja va 2 s. co m ExpectedConditions.textToBePresentInElementLocated(By.id("user-messages"), "Role Guest updated.")); clickLinkWithLocator("roles-view-tabs-a-roles-grid"); wait.until(ExpectedConditions.textToBePresentInElementLocated(By.id("role-description-Guest"), desc)); }
From source file:org.apache.syncope.fit.console.reference.ConfigurationITCase.java
License:Apache License
@Test public void createNotification() { seleniumDriver.findElement(By.xpath("//img[@alt=\"Configuration\"]")).click(); wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//div[@id='tabs']"))); seleniumDriver.findElement(By.xpath("//div[@id='tabs']/ul/li[3]/a")).click(); seleniumDriver.findElement(By.xpath("//div[@id='notifications']/a")).click(); wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//iframe"))); seleniumDriver.switchTo().frame(0);/* w w w . j av a2 s. c om*/ wait.until(ExpectedConditions .presenceOfElementLocated(By.xpath("//div[2]/form/div[3]/div/div/div/div/label"))); wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//input[@name='sender:textField']"))); seleniumDriver.findElement(By.name("sender:textField")).sendKeys("test@syncope.it"); seleniumDriver.findElement(By.name("subject:textField")).sendKeys("test@syncope.it"); Select select = new Select( seleniumDriver.findElement(By.xpath("//div[2]/form/div[3]/div/div/div[3]/div[2]/span/select"))); select.selectByVisibleText("UserPlainSchema"); wait.until(ExpectedConditions.presenceOfElementLocated( By.xpath("//div[2]/form/div[3]/div/div/div[4]/div[2]/span/select/option[2]"))); select = new Select( seleniumDriver.findElement(By.xpath("//div[2]/form/div[3]/div/div/div[4]/div[2]/span/select"))); select.selectByVisibleText("fullname"); select = new Select( seleniumDriver.findElement(By.xpath("//div[2]/form/div[3]/div/div/div[5]/div[2]/span/select"))); select.selectByVisibleText("optin"); select = new Select( seleniumDriver.findElement(By.xpath("//div[2]/form/div[3]/div/div/div[6]/div[2]/span/select"))); select.selectByVisibleText("ALL"); seleniumDriver.findElement(By.xpath("//div[2]/form/div[3]/ul/li[3]/a/span")).click(); seleniumDriver.findElement(By.xpath("//div[2]/form/div[3]/ul/li[2]/a/span")).click(); wait.until(ExpectedConditions.presenceOfElementLocated( By.xpath("//select[@name='eventSelection:categoryContainer:type:dropDownChoiceField']" + "/option[text()='PROPAGATION']"))); select = new Select(seleniumDriver.findElement( By.xpath("//select[@name='eventSelection:categoryContainer:type:dropDownChoiceField']"))); select.selectByVisibleText("PROPAGATION"); wait.until(ExpectedConditions.presenceOfElementLocated( By.xpath("//select[@name='eventSelection:categoryContainer:category:dropDownChoiceField']" + "/option[text()='group']"))); select = new Select(seleniumDriver.findElement( By.xpath("//select[@name='eventSelection:categoryContainer:category:dropDownChoiceField']"))); select.selectByVisibleText("group"); wait.until(ExpectedConditions.presenceOfElementLocated( By.xpath("//select[@name='eventSelection:categoryContainer:subcategory:dropDownChoiceField']" + "/option[text()='resource-db-sync']"))); select = new Select(seleniumDriver.findElement( By.xpath("//select[@name='eventSelection:categoryContainer:subcategory:dropDownChoiceField']"))); select.selectByVisibleText("resource-db-sync"); wait.until(ExpectedConditions.presenceOfElementLocated( By.xpath("//input[@name='eventSelection:eventsContainer:eventsPanel:failureGroup']"))); seleniumDriver.findElement(By.xpath("//div[@class='eventSelectionWidzard']/div[2]/div[3]/span/div/input")) .click(); seleniumDriver.findElement(By.xpath("//div[2]/form/div[3]/ul/li[4]/a")).click(); seleniumDriver.findElement(By.xpath("//div[2]/form/div[3]/div[4]/div/div/span/input")).click(); wait.until(ExpectedConditions .elementToBeClickable(By.name("staticRecipients:multiValueContainer:view:0:panel:textField"))); seleniumDriver.findElement(By.name("staticRecipients:multiValueContainer:view:0:panel:textField")) .sendKeys("syncope445@syncope.apache.org"); wait.until(ExpectedConditions .presenceOfElementLocated(By.xpath("//div[2]/form/div[3]/div[4]/div/div[2]/label"))); seleniumDriver.findElement(By.xpath("//div[2]/form/div[4]/input")).click(); seleniumDriver.switchTo().defaultContent(); }
From source file:org.apache.syncope.fit.console.reference.ConfigurationITCase.java
License:Apache License
@Test public void createDisabledNotification() { seleniumDriver.findElement(By.xpath("//img[@alt=\"Configuration\"]")).click(); wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//div[@id='tabs']"))); seleniumDriver.findElement(By.xpath("//div[@id='tabs']/ul/li[3]/a")).click(); seleniumDriver.findElement(By.xpath("//div[@id='notifications']/a")).click(); wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//iframe"))); seleniumDriver.switchTo().frame(0);/*from w w w . j a va 2 s . c o m*/ wait.until(ExpectedConditions .presenceOfElementLocated(By.xpath("//div[2]/form/div[3]/div/div/div/div/label"))); wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//input[@name='sender:textField']"))); seleniumDriver.findElement(By.name("sender:textField")).sendKeys("test@syncope.it"); Select select = new Select( seleniumDriver.findElement(By.xpath("//div[2]/form/div[3]/div/div[1]/div[3]/div[2]/span/select"))); select.selectByVisibleText("UserPlainSchema"); wait.until(ExpectedConditions.presenceOfElementLocated( By.xpath("//div[2]/form/div[3]/div/div/div[4]/div[2]/span/select/option[2]"))); select = new Select( seleniumDriver.findElement(By.xpath("//div[2]/form/div[3]/div/div/div[4]/div[2]/span/select"))); select.selectByVisibleText("fullname"); select = new Select( seleniumDriver.findElement(By.xpath("//div[2]/form/div[3]/div/div/div[5]/div[2]/span/select"))); select.selectByVisibleText("optin"); select = new Select( seleniumDriver.findElement(By.xpath("//div[2]/form/div[3]/div/div/div[6]/div[2]/span/select"))); select.selectByVisibleText("ALL"); // disable notification seleniumDriver.findElement(By.xpath("//div[2]/form/div[3]/div/div/div[7]/div[2]/span/input")).click(); seleniumDriver.findElement(By.xpath("//div[2]/form/div[3]/ul/li[3]/a/span")).click(); seleniumDriver.findElement(By.xpath("//div[2]/form/div[3]/ul/li[2]/a/span")).click(); wait.until(ExpectedConditions.presenceOfElementLocated( By.xpath("//select[@name='eventSelection:categoryContainer:type:dropDownChoiceField']" + "/option[text()='PROPAGATION']"))); select = new Select(seleniumDriver.findElement( By.xpath("//select[@name='eventSelection:categoryContainer:type:dropDownChoiceField']"))); select.selectByVisibleText("PROPAGATION"); wait.until(ExpectedConditions.presenceOfElementLocated( By.xpath("//select[@name='eventSelection:categoryContainer:category:dropDownChoiceField']" + "/option[text()='group']"))); select = new Select(seleniumDriver.findElement( By.xpath("//select[@name='eventSelection:categoryContainer:category:dropDownChoiceField']"))); select.selectByVisibleText("group"); wait.until(ExpectedConditions.presenceOfElementLocated( By.xpath("//select[@name='eventSelection:categoryContainer:subcategory:dropDownChoiceField']" + "/option[text()='resource-db-sync']"))); select = new Select(seleniumDriver.findElement( By.xpath("//select[@name='eventSelection:categoryContainer:subcategory:dropDownChoiceField']"))); select.selectByVisibleText("resource-db-sync"); wait.until(ExpectedConditions.presenceOfElementLocated( By.xpath("//input[@name='eventSelection:eventsContainer:eventsPanel:failureGroup']"))); seleniumDriver.findElement(By.xpath("//div[@class='eventSelectionWidzard']/div[2]/div[3]/span/div/input")) .click(); seleniumDriver.findElement(By.xpath("//div[2]/form/div[3]/ul/li[4]/a/span")).click(); seleniumDriver.findElement(By.xpath("//div[2]/form/div[3]/div[4]/div/div/span/input")).click(); wait.until(ExpectedConditions .elementToBeClickable(By.name("staticRecipients:multiValueContainer:view:0:panel:textField"))); seleniumDriver.findElement(By.name("staticRecipients:multiValueContainer:view:0:panel:textField")) .sendKeys("syncope492@syncope.apache.org"); wait.until(ExpectedConditions .presenceOfElementLocated(By.xpath("//div[2]/form/div[3]/div[4]/div/div[2]/label"))); seleniumDriver.findElement(By.xpath("//div[2]/form/div[4]/input")).click(); seleniumDriver.switchTo().defaultContent(); }
From source file:org.apache.syncope.fit.console.reference.ConfigurationITCase.java
License:Apache License
@Test public void issueSYNCOPE446() { seleniumDriver.findElement(By.xpath("//img[@alt=\"Configuration\"]")).click(); wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//div[@id='tabs']"))); seleniumDriver.findElement(By.xpath("//div[@id='tabs']/ul/li[3]/a")).click(); seleniumDriver.findElement(By.xpath("//div[@id='notifications']/a")).click(); wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//iframe"))); seleniumDriver.switchTo().frame(0);/*from w w w . ja va2 s .c o m*/ wait.until(ExpectedConditions .presenceOfElementLocated(By.xpath("//div[2]/form/div[3]/div/div/div/div/label"))); wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//input[@name='sender:textField']"))); seleniumDriver.findElement(By.name("sender:textField")).sendKeys("syncope446@syncope.it"); seleniumDriver.findElement(By.name("subject:textField")).sendKeys("Test issue Syncope 446"); Select select = new Select( seleniumDriver.findElement(By.xpath("//div[2]/form/div[3]/div/div/div[3]/div[2]/span/select"))); select.selectByVisibleText("UserPlainSchema"); wait.until(ExpectedConditions.presenceOfElementLocated( By.xpath("//div[2]/form/div[3]/div/div/div[4]/div[2]/span/select/option[2]"))); select = new Select( seleniumDriver.findElement(By.xpath("//div[2]/form/div[3]/div/div/div[4]/div[2]/span/select"))); select.selectByVisibleText("email"); select = new Select( seleniumDriver.findElement(By.xpath("//div[2]/form/div[3]/div/div/div[5]/div[2]/span/select"))); select.selectByVisibleText("optin"); select = new Select( seleniumDriver.findElement(By.xpath("//div[2]/form/div[3]/div/div/div[6]/div[2]/span/select"))); select.selectByVisibleText("ALL"); seleniumDriver.findElement(By.xpath("//div[2]/form/div[3]/ul/li[3]/a/span")).click(); seleniumDriver.findElement(By.xpath("//div[2]/form/div[3]/ul/li[2]/a/span")).click(); wait.until(ExpectedConditions.presenceOfElementLocated( By.xpath("//select[@name='eventSelection:categoryContainer:type:dropDownChoiceField']" + "/option[text()='REST']"))); select = new Select(seleniumDriver.findElement( By.xpath("//select[@name='eventSelection:categoryContainer:type:dropDownChoiceField']"))); select.selectByVisibleText("REST"); wait.until(ExpectedConditions.presenceOfElementLocated( By.xpath("//select[@name='eventSelection:categoryContainer:category:dropDownChoiceField']" + "/option[text()='GroupLogic']"))); select = new Select(seleniumDriver.findElement( By.xpath("//select[@name='eventSelection:categoryContainer:category:dropDownChoiceField']"))); select.selectByVisibleText("GroupLogic"); wait.until(ExpectedConditions.presenceOfElementLocated( By.xpath("//input[@name='eventSelection:eventsContainer:eventsPanel:successGroup']"))); seleniumDriver.findElement(By.xpath("//div[@class='eventSelectionWidzard']/div[2]/div[3]/span/div/input")) .click(); seleniumDriver.findElement(By.xpath("//div[2]/form/div[3]/ul/li[3]/a/span")).click(); seleniumDriver.findElement(By.xpath("//div[2]/form/div[3]/div[3]/span/div[4]/div/span/input")).click(); wait.until(ExpectedConditions.presenceOfElementLocated( By.xpath("//select[@name='aboutContainer:groupAbout:searchFormContainer:searchView:0:type']" + "/option[text()='ENTITLEMENT']"))); wait.until(ExpectedConditions.elementToBeClickable( By.xpath("//select[@name='aboutContainer:groupAbout:searchFormContainer:searchView:0:type']"))); select = new Select(seleniumDriver.findElement( By.xpath("//select[@name='aboutContainer:groupAbout:searchFormContainer:searchView:0:type']"))); select.selectByVisibleText("ENTITLEMENT"); wait.until(ExpectedConditions.presenceOfElementLocated( By.xpath("//select[@name='aboutContainer:groupAbout:searchFormContainer:searchView:0:property']" + "/option[text()='GROUP_CREATE']"))); select = new Select(seleniumDriver.findElement( By.xpath("//select[@name='aboutContainer:groupAbout:searchFormContainer:searchView:0:property']"))); select.selectByVisibleText("GROUP_CREATE"); seleniumDriver.findElement(By.xpath("//div[2]/form/div[3]/ul/li[4]/a/span")).click(); seleniumDriver.findElement(By.xpath("//input[@name='recipientsContainer:checkRecipients:checkboxField']")) .click(); wait.until(ExpectedConditions .elementToBeClickable(By.name("staticRecipients:multiValueContainer:view:0:panel:textField"))); seleniumDriver.findElement(By.name("staticRecipients:multiValueContainer:view:0:panel:textField")) .sendKeys("syncope446@syncope.apache.org"); seleniumDriver.findElement(By.xpath("//div[2]/form/div[4]/input")).click(); seleniumDriver.switchTo().defaultContent(); }
From source file:org.cerberus.service.appium.impl.AppiumService.java
License:Open Source License
private WebElement getElement(Session session, Identifier identifier, boolean visible, boolean clickable) { AppiumDriver driver = session.getAppiumDriver(); By locator = this.getBy(identifier); LOG.debug("Waiting for Element : " + identifier.getIdentifier() + "=" + identifier.getLocator()); try {/*from w ww .j a va2 s. c o m*/ WebDriverWait wait = new WebDriverWait(driver, TimeUnit.MILLISECONDS.toSeconds(session.getCerberus_appium_wait_element())); if (visible) { if (clickable) { wait.until(ExpectedConditions.elementToBeClickable(locator)); } else { wait.until(ExpectedConditions.visibilityOfElementLocated(locator)); } } else { wait.until(ExpectedConditions.presenceOfElementLocated(locator)); } } catch (TimeoutException exception) { LOG.fatal("Exception waiting for element :" + exception.toString()); throw new NoSuchElementException(identifier.getIdentifier() + "=" + identifier.getLocator()); } LOG.debug("Finding Element : " + identifier.getIdentifier() + "=" + identifier.getLocator()); return driver.findElement(locator); }
From source file:org.cerberus.service.engine.impl.AppiumService.java
License:Open Source License
private WebElement getElement(Session session, Identifier identifier, boolean visible, boolean clickable) { AppiumDriver driver = session.getAppiumDriver(); By locator = this.getBy(identifier); MyLogger.log(RunTestCaseService.class.getName(), Level.DEBUG, "Waiting for Element : " + identifier.getIdentifier() + "=" + identifier.getLocator()); try {/*from ww w .j a v a2 s . c om*/ WebDriverWait wait = new WebDriverWait(driver, session.getDefaultWait()); if (visible) { if (clickable) { wait.until(ExpectedConditions.elementToBeClickable(locator)); } else { wait.until(ExpectedConditions.visibilityOfElementLocated(locator)); } } else { wait.until(ExpectedConditions.presenceOfElementLocated(locator)); } } catch (TimeoutException exception) { MyLogger.log(RunTestCaseService.class.getName(), Level.FATAL, "Exception waiting for element :" + exception); throw new NoSuchElementException(identifier.getIdentifier() + "=" + identifier.getLocator()); } MyLogger.log(RunTestCaseService.class.getName(), Level.DEBUG, "Finding Element : " + identifier.getIdentifier() + "=" + identifier.getLocator()); return driver.findElement(locator); }