List of usage examples for org.openqa.selenium.support.ui ExpectedConditions visibilityOf
public static ExpectedCondition<WebElement> visibilityOf(final WebElement element)
From source file:org.wso2.iot.integration.ui.pages.uesr.UserListingPage.java
License:Open Source License
/** * Performs the delete user action./*from w w w .j a va2 s . co m*/ * @return After deleting a user, returns back to the user listing page. */ public UserListingPage deleteUser() throws IOException, InterruptedException { WebElement deleteBtn = driver .findElement(By.xpath(uiElementMapper.getElement("iot.admin.deleteUser.btn.xpath"))); WebDriverWait wait = new WebDriverWait(driver, UIUtils.webDriverTimeOut); wait.until(ExpectedConditions.visibilityOf(deleteBtn)); deleteBtn.click(); WebElement deleteConfirmationBtn = driver .findElement(By.xpath(uiElementMapper.getElement("iot.admin.deleteUser.yes.link.xpath"))); wait.until(ExpectedConditions.visibilityOf(deleteConfirmationBtn)); deleteConfirmationBtn.click(); Thread.sleep(UIUtils.threadTimeout); WebElement deleteSuccessBtn = driver .findElement(By.xpath(uiElementMapper.getElement("iot.admin.deleteUser.success.link.xpath"))); deleteSuccessBtn.click(); return new UserListingPage(driver); }
From source file:org.xmlium.test.web.commons.xml.XMLTestSteps.java
License:LGPL
protected void processStep(StepType step) throws Exception { WebElement element = null;//w w w .j a v a 2 s. c o m Alert a = null; if (step.getScrollX() != null && step.getScrollY() != null) { JavascriptExecutor js = (JavascriptExecutor) getSuite().getDriver(); js.executeScript("window.scrollTo(" + step.getScrollX() + ", " + step.getScrollY() + ");"); } if (step.isBack() != null && step.isBack()) { getSuite().getDriver().navigate().back(); } if (step.isForward() != null && step.isForward()) { getSuite().getDriver().navigate().forward(); } Element e = null; if (step.getLoad() != null && step.getLoad().getKey() != null) { e = store.get(step.getLoad().getKey()); element = findElement(e.getFinds()); } if (step.getElement() != null) { if (step.getElement().getFinds() != null) { e = step.getElement(); checkStore(e); element = checkWaitFor(e); if (element == null && step.getElement().isCheckNullElement()) { return; } checkStoreValue(e, element); checkSetValue(e, element); checkSendKeys(e, element); checkClick(e, element); checkChangeState(e); checkText(e, element); checkMoveX(e, element); } } if (step.getSwitchTo() != null) { Object to = switchTo(step.getSwitchTo()); if (to instanceof Alert) { a = (Alert) to; if (step.getSwitchTo().getAlert() != null && step.getSwitchTo().getAlert().isAccept()) { a.accept(); } } else { a = null; } } if (step.getSelect() != null) { org.xmlium.testsuite.Select stepSelect = step.getSelect(); if (element != null && stepSelect.getSelectBy().getByIndex() != null) { Index index = stepSelect.getSelectBy().getByIndex(); SelectData selectData = new SelectData(); initSelectIndexes(element, index, selectData); if (selectData.selectIndex >= 0) { Select select = new Select(element); List<WebElement> options = select.getOptions(); WebElement option = options.get(selectData.selectIndex); option.click(); } else { throw new RuntimeException("selectedIndex=" + selectData.selectIndex); } } else { if (element == null) { element = findElement(step.getSelect().getFinds()); } if (element != null) { Select select = new Select(element); if (step.getSelect().getSelectBy() != null) { selectBy(select, step.getSelect().getSelectBy()); } } } } if (step.getPrettySelect() != null) { PrettySelect stepSelect = step.getPrettySelect(); if (element == null) { if (stepSelect.getFinds() != null) { element = findElement(stepSelect.getFinds()); } } if (element != null && stepSelect.getSelectBy() != null) { SelectData selectData = new SelectData(); Select select = null; select = new Select(element); Index index = null; if (stepSelect.getSelectBy().getByIndex() != null) { index = stepSelect.getSelectBy().getByIndex(); initSelectIndexes(element, index, selectData); } else if (stepSelect.getSelectBy().getByVisibleText() != null) { List<WebElement> elems = select.getOptions(); getOptionIndexBuVisibleText(stepSelect.getSelectBy().getByVisibleText(), elems, selectData); } if (selectData.selectIndex >= 0) { WebElement arrowArea = null; WebElement scrollArea = null; if (stepSelect.getSelectBy().getArrowArea() != null) { arrowArea = findElement(stepSelect.getSelectBy().getArrowArea()); } else { throw new RuntimeException("arrowArea not defined in xml"); } if (arrowArea != null) { arrowArea.click(); if (stepSelect.getSelectBy().getScrollArea() != null) { Finds scrollAreaFinds = stepSelect.getSelectBy().getScrollArea(); if (scrollAreaFinds.getFind() != null) { scrollArea = findElement(scrollAreaFinds.getFind()); } else if (scrollAreaFinds.getWaitFor() != null) { scrollArea = waitFor(scrollAreaFinds.getWaitFor()); } if (scrollArea == null) { if (scrollAreaFinds.getFind() != null || scrollAreaFinds.getWaitFor() != null) { String text = ""; if (scrollAreaFinds.getFind() != null && scrollAreaFinds.getFind().getByXPath() != null) { text = unformatValue(scrollAreaFinds.getFind().isUnformat(), scrollAreaFinds.getFind().getByXPath().getValue()); } else if (scrollAreaFinds.getWaitFor() != null && scrollAreaFinds.getWaitFor().getByXPath() != null) { text = unformatValue(scrollAreaFinds.getWaitFor().isUnformat(), scrollAreaFinds.getWaitFor().getByXPath().getValue()); } throw new RuntimeException("scrollArea not found: " + text); } else { throw new RuntimeException("scrollArea not defined in xml"); } } } if (index.isFirst() != null || index.isLast() != null) { Actions actions = new Actions(getSuite().getDriver()); String text = null; if (index.isFirst() != null && index.isFirst()) { actions.keyDown(Keys.CONTROL).sendKeys(Keys.HOME).perform(); } else if (index.isLast() != null && index.isLast()) { actions.keyDown(Keys.CONTROL).sendKeys(Keys.END).perform(); } if (index.isFirst() != null && index.isFirst()) { text = select.getOptions().get(0).getText(); } else if (index.isLast() != null && index.isLast()) { text = select.getOptions().get(select.getOptions().size() - 1).getText(); } if (stepSelect.getSelectBy().getOptionsTag() != null) { Find f = new Find(); ByXPath xPath = new ByXPath(); if (text != null && !text.isEmpty()) { xPath.setValue("//" + stepSelect.getSelectBy().getOptionsTag() + "[contains(@class, '" + stepSelect.getSelectBy().getOptionsClasses() + "') and text()='" + text + "']"); } else { xPath.setValue("(//" + stepSelect.getSelectBy().getOptionsTag() + "[contains(@class, '" + stepSelect.getSelectBy().getOptionsClasses() + "')])[" + Integer.toString(selectData.selectIndex + 1) + "]"); } f.setByXPath(xPath); WebElement optionElemnt = findElement(f); WebDriverWait wait = new WebDriverWait(getSuite().getDriver(), 30); wait.until(ExpectedConditions.elementToBeClickable(optionElemnt)); optionElemnt.click(); } } else { if (selectData.selectIndex < 0 || selectData.selectIndex >= select.getOptions().size()) { throw new RuntimeException("selectIndex: " + selectData.selectIndex + ", options.size: " + select.getOptions().size()); } WebElement option = select.getOptions().get(selectData.selectIndex); String text = option.getText(); if (text == null || text.isEmpty()) { logger.debug("text is null or empty: " + option); text = null; } if (stepSelect.getSelectBy().getOptionsTag() != null) { Find f = new Find(); ByXPath xPath = new ByXPath(); if (text != null) { xPath.setValue("//" + stepSelect.getSelectBy().getOptionsTag() + "[contains(@class, '" + stepSelect.getSelectBy().getOptionsClasses() + "') and text()='" + text + "']"); } else { xPath.setValue("(//" + stepSelect.getSelectBy().getOptionsTag() + "[contains(@class, '" + stepSelect.getSelectBy().getOptionsClasses() + "')])[" + Integer.toString(selectData.selectIndex + 1) + "]"); } f.setByXPath(xPath); WebElement optionElemnt = findElement(f); Coordinates coordinate = ((Locatable) optionElemnt).getCoordinates(); coordinate.onPage(); coordinate.inViewPort(); WebDriverWait wait = new WebDriverWait(getSuite().getDriver(), 30); wait.until(ExpectedConditions.elementToBeClickable(optionElemnt)); optionElemnt.click(); } } } else { throw new RuntimeException("can't click the arrow"); } } else if (stepSelect.getSelectBy().getByVisibleText() != null) { WebElement arrowArea = null; WebElement scrollArea = null; if (stepSelect.getSelectBy().getArrowArea() != null) { arrowArea = findElement(stepSelect.getSelectBy().getArrowArea()); } else { throw new RuntimeException("arrowArea not defined in xml"); } if (arrowArea != null) { arrowArea.click(); String scrollAreaXPath = null; if (stepSelect.getSelectBy().getScrollArea() != null) { Finds scrollAreaFinds = stepSelect.getSelectBy().getScrollArea(); if (scrollAreaFinds.getFind() != null) { scrollArea = findElement(scrollAreaFinds.getFind()); } else if (scrollAreaFinds.getWaitFor() != null) { scrollArea = waitFor(scrollAreaFinds.getWaitFor()); } if (scrollAreaXPath == null) { if (scrollAreaFinds.getFind() != null || scrollAreaFinds.getWaitFor() != null) { if (scrollAreaFinds.getFind() != null && scrollAreaFinds.getFind().getByXPath() != null) { scrollAreaXPath = unformatValue(scrollAreaFinds.getFind().isUnformat(), scrollAreaFinds.getFind().getByXPath().getValue()); } else if (scrollAreaFinds.getWaitFor() != null && scrollAreaFinds.getWaitFor().getByXPath() != null) { scrollAreaXPath = unformatValue(scrollAreaFinds.getWaitFor().isUnformat(), scrollAreaFinds.getWaitFor().getByXPath().getValue()); } // throw new RuntimeException("scrollArea // not found: " + text); } else { throw new RuntimeException("scrollArea not defined in xml"); } } } Actions actions = new Actions(getSuite().getDriver()); String text = null; // actions.keyDown(Keys.CONTROL).sendKeys(Keys.HOME).perform(); WebDriverWait wait = new WebDriverWait(getSuite().getDriver(), 30); wait.until(ExpectedConditions.elementToBeClickable(scrollArea)); actions.moveToElement(scrollArea).build().perform(); text = stepSelect.getSelectBy().getByVisibleText(); logger.debug("text: " + text); if (stepSelect.getSelectBy().getOptionsTag() != null) { Find f = new Find(); ByXPath xPath = new ByXPath(); if (text != null) { xPath.setValue(scrollAreaXPath + "/descendant::" + stepSelect.getSelectBy().getOptionsTag() + "[contains(@class, '" + stepSelect.getSelectBy().getOptionsClasses() + "') and text()='" + text + "']"); } else { xPath.setValue("(//" + stepSelect.getSelectBy().getOptionsTag() + "[contains(@class, '" + stepSelect.getSelectBy().getOptionsClasses() + "')])[" + Integer.toString(selectData.selectIndex + 1) + "]"); } f.setByXPath(xPath); logger.debug("xPath: " + xPath); WebElement optionElemnt = findElement(f); Coordinates coordinate = ((Locatable) optionElemnt).getCoordinates(); coordinate.onPage(); coordinate.inViewPort(); wait = new WebDriverWait(getSuite().getDriver(), 30); wait.until(ExpectedConditions.visibilityOf(optionElemnt)); actions.moveToElement(optionElemnt).click().build().perform(); } } } else { throw new RuntimeException("selectedIndex=" + selectData.selectIndex); } } else { if (element == null) { element = findElement(step.getPrettySelect().getFinds()); } if (element != null) { Select select = new Select(element); if (step.getPrettySelect().getSelectBy() != null) { selectBy(select, step.getPrettySelect().getSelectBy()); } } } } if (step.getSleepAfter() != null) { long sleep = step.getSleepAfter().longValue(); try { Thread.sleep(sleep); } catch (Exception e2) { // TODO: handle exception } } }
From source file:pageObjectRepository.registerPageFactory1.java
public void clickContinue() { //WebElement element = (new WebDriverWait(driver, 10).until(ExpectedConditions.presenceOfElementLocated((By) GD_Continue_Button))); WebDriverWait wait = new WebDriverWait(driver, 10); wait.until(ExpectedConditions.visibilityOf(GD_popup_Close_btn)); GD_Continue_Button.click();/* w w w.java 2s . c o m*/ log.info("Clicked on Continue button"); }
From source file:Pages.Walkin_Reservation_Lease.Leasing_ContactInfoPage.java
public void clk_ActiveDutyMilitaryNoRadioBtn(WebDriver driver) { WebDriverWait wait = new WebDriverWait(driver, 60); wait.until(ExpectedConditions.visibilityOf(clk_ActiveDutyMilitaryNoRadioBtn)).click(); }
From source file:Pages.Walkin_Reservation_Lease.Leasing_ContactInfoPage.java
public void clk_ActiveDutyMilitaryYesRadioBtn(WebDriver driver) { WebDriverWait wait = new WebDriverWait(driver, 60); wait.until(ExpectedConditions.visibilityOf(clk_ActiveDutyMilitaryYesRadioBtn)).click(); }
From source file:renascere.Renascere.java
License:Open Source License
/** * @Description Method that find an object by a BY. *///from w ww.j a va2 s .co m public static WebElement findObject(By byObject, WebDriver driver, object osScope) { WebElement wElement; try { WebDriverWait waitForElement = new WebDriverWait(driver, Global.gTimeOut); waitForElement.until(ExpectedConditions.presenceOfElementLocated(byObject)); wElement = driver.findElement(byObject); waitForElement.until(ExpectedConditions.visibilityOf(wElement)); if (osScope.equals(object.CLICKABLE)) { waitForElement.until(ExpectedConditions.elementToBeClickable(wElement)); } if (!osScope.equals(object.PRESENT)) { logMessage(result.PASS, "Element (" + byObject + ") found."); } pauseExecution(Global.fTimeQSecond); return wElement; } catch (Exception e) { if (!osScope.equals(object.VISIBLE)) { logMessage(result.FAIL, "Element (" + byObject + ") not found!"); } return null; } }
From source file:ru.devprom.pages.admin.UserAddNewPage.java
public UsersListPage createUser(User user) { (new WebDriverWait(driver, waiting)).until(ExpectedConditions.visibilityOf(usernameLongEdit)); usernameLongEdit.sendKeys(user.getUsernameLong()); emailEdit.sendKeys(user.getEmail()); usernameEdit.sendKeys(user.getUsername()); passEdit.sendKeys(user.getPass());/*from ww w . ja v a 2 s . co m*/ passrepeatEdit.sendKeys(user.getPass()); if (user.isAdmin) isAdminCheckBox.click(); licenseReqsCheckbox.click(); licenseDevCheckbox.click(); licenseDocsCheckbox.click(); licenseQACheckbox.click(); submitDialog(createBtn); (new WebDriverWait(driver, waiting)).until(ExpectedConditions .presenceOfElementLocated(By.xpath("//td[@id='email' and contains(.,'" + user.getEmail() + "')]"))); return new UsersListPage(driver); }
From source file:ru.devprom.pages.admin.UserAddNewPage.java
public UsersListPage createUserFull(User user) { (new WebDriverWait(driver, waiting)).until(ExpectedConditions.visibilityOf(usernameLongEdit)); usernameLongEdit.sendKeys(user.getUsernameLong()); emailEdit.sendKeys(user.getEmail()); usernameEdit.sendKeys(user.getUsername()); passEdit.sendKeys(user.getPass());//from ww w . j a v a 2 s . c o m passrepeatEdit.sendKeys(user.getPass()); if (user.isAdmin) isAdminCheckBox.click(); licenseReqsCheckbox.click(); licenseDevCheckbox.click(); licenseDocsCheckbox.click(); licenseQACheckbox.click(); for (String group : user.getGroups()) { (new WebDriverWait(driver, waiting)).until(ExpectedConditions.visibilityOf(addGroupLink)); addGroupLink.click(); groupsList.clear(); groupsList.sendKeys(group); autocompleteSelect(group); addGroupBtn.click(); } if (user.getLanguage() == Lang.english) { languageSelect.click(); englishSelect.click(); } submitDialog(driver.findElement(By.id("cms_UserSubmitBtn"))); (new WebDriverWait(driver, waiting)).until(ExpectedConditions .presenceOfElementLocated(By.xpath("//td[@id='email' and contains(.,'" + user.getEmail() + "')]"))); return new UsersListPage(driver); }
From source file:ru.devprom.pages.admin.UserAddNewPage.java
public void createFirstUser(User user) { (new WebDriverWait(driver, waiting)).until(ExpectedConditions.visibilityOf(usernameLongEdit)); usernameLongEdit.sendKeys(user.getUsernameLong()); emailEdit.sendKeys(user.getEmail()); usernameEdit.sendKeys(user.getUsername()); passEdit.sendKeys(user.getPass());//from www . j av a2 s. com passrepeatEdit.sendKeys(user.getPass()); if (user.isAdmin) isAdminCheckBox.click(); licenseReqsCheckbox.click(); licenseDevCheckbox.click(); licenseDocsCheckbox.click(); licenseQACheckbox.click(); submitDialog(createBtn); }
From source file:ru.devprom.pages.kanban.KanbanBuildsPage.java
public KanbanNewBuildPage clickNewBuild() { (new WebDriverWait(driver, waiting)).until(ExpectedConditions.visibilityOf(addBuild)); addBuild.click();/* w w w . jav a2 s.c o m*/ return new KanbanNewBuildPage(driver); }