List of usage examples for org.openqa.selenium.support.ui WebDriverWait WebDriverWait
public WebDriverWait(WebDriver driver, Duration timeout)
From source file:com.easytox.automation.steps.LabClientImpl.java
@When("^Enter all the information in the Physician screen and click Submit$") public void enter_all_the_information() { Physician.physicianUserName = StringUtils.generateRandom(); selectOption(Physician.LAB_CLIENT_LOCATOR, LocatorType.ID, Physician.LAB_CLIENT); enterData(Physician.USER_NAME_LOCATOR, Physician.physicianUserName, LocatorType.NAME); enterData(Physician.PASSWORD_LOCATOR, Physician.PASSWORD, LocatorType.NAME); enterData(Physician.FIRST_NAME_LOCATOR, Physician.FIRST_NAME, LocatorType.NAME); enterData(Physician.LAST_NAME_LOCATOR, Physician.LAST_NAME, LocatorType.NAME); enterData(Physician.MIDDLE_NAME_LOCATOR, Physician.MIDDLE_NAME, LocatorType.NAME); enterData(Physician.MEDICAL_DEGREE_LOCATOR, Physician.MEDICAL_DEGREE, LocatorType.NAME); enterData(Physician.PHONE_NUMBER_LOCATOR, Physician.PHONE_NUMBER, LocatorType.NAME); enterData(Physician.EMAIL_ADDRESS_LOCATOR, Physician.EMAIL_ADDRESS, LocatorType.NAME); enterData(Physician.SALUTATION_LOCATOR, Physician.SALUTATION, LocatorType.NAME); enterData(Physician.FIRST_NAME_LOCATOR, Physician.FIRST_NAME, LocatorType.NAME); enterData(Physician.MEDICARE_NUMBER_LOCATOR, Physician.MEDICARE_NUMBER, LocatorType.NAME); enterData(Physician.MEDICAID_NUMBER_LOCATOR, Physician.MEDICAID_NUMBER, LocatorType.NAME); enterData(Physician.UPIN_NUMBER_LOCATOR, Physician.UPIN_NUMBER, LocatorType.NAME); enterData(Physician.STATE_LICENCE_LOCATOR, Physician.STATE_LICENCE, LocatorType.NAME); enterData(Physician.NPI_LOCATOR, Physician.NPI, LocatorType.NAME); selectOption(Physician.COMPOUND_PROFILE_LOCATOR, LocatorType.ID, Physician.COMPOUND_PROFILE); WebElement plusButton = MyWebDriverUtils.findElement(driver, Physician.PLUS_ONE_ICON_LOCATOR, LocatorType.CSS);/*from www . ja v a 2 s. co m*/ WebDriverWait wait = new WebDriverWait(driver, TIME_OUT_IN_SECONDS); boolean flag = MyWebDriverUtils.waitInvisibilityOfElement(wait, CONTAINER_LOCATOR, LocatorType.ID); if (flag) { checkAndClick(plusButton); } else { Assert.fail("flag is false!"); } wait.until(ExpectedConditions.visibilityOfElementLocated(By.id(Physician.LOCATION_LOCATOR))); selectOption(Physician.LOCATION_LOCATOR, LocatorType.ID, Physician.LOCATION); WebElement el = MyWebDriverUtils.findElement(driver, Physician.CHECKBOX_ONE_LOCATOR, LocatorType.CSS); checkAndClick(el); plusButton = MyWebDriverUtils.findElement(driver, Physician.PLUS_TWO_ICON_LOCATOR, LocatorType.CSS); checkAndClick(plusButton); el = MyWebDriverUtils.findElement(driver, Physician.CHECKBOX_TWO_LOCATOR, LocatorType.CSS); checkAndClick(el); WebElement submit = MyWebDriverUtils.findElement(driver, Physician.SUBMIT_LOCATOR, LocatorType.CSS); checkAndClick(submit); }
From source file:com.easytox.automation.steps.LabClientImpl.java
@When("^Click on 'v' down arrow icon on (.*)$") public void click_on_v_down_arrow_icon(String column) { String locator = chooseLocator(column); if (locator != null) { WebElement el = MyWebDriverUtils.findElement(driver, locator, LocatorType.CSS); WebDriverWait wait = new WebDriverWait(driver, TIME_OUT_IN_SECONDS); boolean flag = MyWebDriverUtils.waitInvisibilityOfElement(wait, CONTAINER_LOCATOR, LocatorType.ID); if (flag) { checkAndClick(el);/*from ww w .j a va 2s.c o m*/ } else { Assert.fail("flag is false!"); } } }
From source file:com.easytox.automation.steps.LabClientImpl.java
@When("^Click on Up arrow icon on (.*)$") public void click_on_up_arrow_icon(String column) { WebElement el = MyWebDriverUtils.findElement(driver, SORT_ASCENDING_LOCATOR, LocatorType.CSS); WebDriverWait wait = new WebDriverWait(driver, TIME_OUT_IN_SECONDS); boolean flag = MyWebDriverUtils.waitInvisibilityOfElement(wait, CONTAINER_LOCATOR, LocatorType.ID); if (flag) {/* ww w. j a v a 2 s . c om*/ checkAndClick(el); } else { Assert.fail("flag is false!"); } }
From source file:com.easytox.automation.steps.LabClientImpl.java
@When("^Navigate back and forth by selecting page numbers (.*)$") public void navigate_button(String button) { int i;//from w w w. ja v a 2 s . c om if (button.equals("Next") || button.equals("Prev")) { i = 3; } else { i = Integer.parseInt(button) + 2; } WebElement el = MyWebDriverUtils.findElement(driver, "#example_paginate > ul > li:nth-child(" + i + ") > a", LocatorType.CSS); WebDriverWait wait = new WebDriverWait(driver, TIME_OUT_IN_SECONDS); boolean flag = MyWebDriverUtils.waitInvisibilityOfElement(wait, CONTAINER_LOCATOR, LocatorType.ID); if (flag) { checkAndClick(el); } else { Assert.fail("flag is false!"); } String locator = chooseButtonLocator(button); if (locator != null) { el = MyWebDriverUtils.findElement(driver, locator, LocatorType.CSS); wait = new WebDriverWait(driver, TIME_OUT_IN_SECONDS); flag = MyWebDriverUtils.waitInvisibilityOfElement(wait, CONTAINER_LOCATOR, LocatorType.ID); if (flag) { checkAndClick(el); } else { Assert.fail("flag is false!"); } } navigateButton = button; }
From source file:com.ecofactor.qa.automation.insite.page.PartnerManagementImpl.java
License:Open Source License
/** * <p>// w w w . j a v a2 s . c o m * Remove all values from the assigned panel to the available panel and verify there is no value * in the assigned pane. * </p> * @param driver the driver */ private void removeAllToAvailablePane(final WebDriver driver) { LogUtil.setLogString("Remome all values from the assigned Pane and moving to available pane", true); final Select select = new Select(driver.findElement(By.id(partnerConfig.get(ASSIGNED_PARTNER_TYPE)))); final List<WebElement> optionsList = select.getOptions(); for (final WebElement webElement : optionsList) { select.selectByVisibleText(webElement.getText()); driver.findElement(By.id(REMOVE_ASSIGNED_ROLE)).click(); } final List<WebElement> optionsList2 = select.getOptions(); (new WebDriverWait(driver, SHORT_TIMEOUT)).until(new ExpectedCondition<Boolean>() { public Boolean apply(WebDriver d) { boolean outcome = false; outcome = optionsList2.size() == 0 ? true : false; return outcome; } }); }
From source file:com.ecofactor.qa.automation.insite.page.RoleManagementImpl.java
License:Open Source License
/** * Change away date value./*from w w w . j a v a 2s. co m*/ * @param linkTextValue the link text value * @see com.ecofactor.qa.automation.insite.page.RoleManagement#changeAwayDateValue(java.lang.String) */ @Override public void changeAwayDateValue(final String linkTextValue) { DriverConfig.setLogString("Change current date to : " + linkTextValue, true); (new WebDriverWait(DriverConfig.getDriver(), SHORT_TIMEOUT)).until(new ExpectedCondition<Boolean>() { public Boolean apply(WebDriver d) { final List<WebElement> elementList = DriverConfig.getDriver() .findElements(By.linkText(linkTextValue)); for (final WebElement webElement : elementList) { if (webElement.isDisplayed()) { webElement.click(); } } return true; } }); tinyWait(); clickDone(); }
From source file:com.ecofactor.qa.automation.insite.page.RoleManagementImpl.java
License:Open Source License
/** * <p>//from ww w .ja va 2s .c om * Click on Save button and wait for alert to be popped.The verify the page is redirected * properly. * </p> * @param driver the driver * @param roleName the role name */ private void saveAndVerifyRole(final WebDriver driver, final String roleName) { DriverConfig.setLogString( "Click on save link and verify the alert is popped, finally check the page is re-directed properly.", true); final WebElement saveElement = retrieveElementByLinkText(driver, "Save", SHORT_TIMEOUT); saveElement.click(); (new WebDriverWait(driver, LONG_TIMEOUT + LONG_TIMEOUT)).until(ExpectedConditions.alertIsPresent()); DriverConfig.setLogString("click ok on alert message.", true); logger.info("click ok on alert message."); DriverConfig.setLogString("Alert Message :" + driver.switchTo().alert().getText(), true); waitUntil(FIVE_SECS); driver.switchTo().alert().accept(); /* * retrieveElementByLinkText(driver, "First", SHORT_TIMEOUT); Assert.assertEquals(true, * driver.getCurrentUrl().contains("roles.html"), "Url doesn't contains roles.html"); */ smallWait(); logger.info("find role name element is displayed."); DriverConfig.setLogString("find role name element is displayed.", true); isDisplayedById(driver, roleConfig.get(ROLE_NAME), SHORT_TIMEOUT); DriverConfig.setLogString("Enter role name as " + roleName, true); driver.findElement(By.id(roleConfig.get(ROLE_NAME))).sendKeys(roleName); DriverConfig.setLogString("check if find button is displayed & click it.", true); final WebElement findButtonElement = retrieveElementByAttributeValue(driver, TAG_INPUT, ATTR_VALUE, roleConfig.get(FIND_BUTTON)); findButtonElement.click(); DriverConfig.setLogString("check if search result is displayed.", true); confirmSearchResultValue(driver, roleName); }
From source file:com.ecofactor.qa.automation.insite.page.UserManagementImpl.java
License:Open Source License
/** * <p>/*from ww w. ja v a 2 s . com*/ * Click on save button and verify the required mesaage is displayed in the alert. And check the * page is recirected to properly. * </p> */ public void saveUsermanagement() { smallWait(); DriverConfig.setLogString("Click Save and Verify the page is redirected properly.", true); final WebElement saveElement = retrieveElementByLinkText(DriverConfig.getDriver(), "Save", SHORT_TIMEOUT); saveElement.click(); (new WebDriverWait(DriverConfig.getDriver(), LONG_TIMEOUT + LONG_TIMEOUT)) .until(ExpectedConditions.alertIsPresent()); DriverConfig.setLogString("check user created message displayed.", true); // commented to close alert. // assertEquals(true, // DriverConfig.getDriver().switchTo().alert().getText().equalsIgnoreCase(userConfig.get(USER_SAVED_ALERT_MSG)), // "User created message is not available"); logger.info("click ok on alert message.", true); // fix to close the invalid alert message issue closeAlert(DriverConfig.getDriver()); retrieveElementByLinkText(DriverConfig.getDriver(), "First", MEDIUM_TIMEOUT); DriverConfig.setLogString("check if user management page is displayed after user creation.", true); assertEquals(true, DriverConfig.getDriver().getCurrentUrl().contains("usermgmt.html"), "Url is different"); }
From source file:com.ecofactor.qa.automation.insite.page.UserManagementImpl.java
License:Open Source License
/** * <p>/*from w w w . ja va 2 s . c o m*/ * Send Account details for the New User * </p> * . * @param driver the driver * @param firstName the first name * @param lastName the last name * @param emailAddress the email address * @param accountUserName the account user name * @param activeUser the active user * @param partnerType the partner type * @param partner the partner */ private void sendAccountDetails(final WebDriver driver, final String firstName, final String lastName, final String emailAddress, final String accountUserName, final String activeUser, final String partnerType, final String partner) { DriverConfig.setLogString("Click on Account Pane and send account details to the required fields.", true); logger.info("check accout details tab is displayed."); clickAccountDetailsTab(); isDisplayedById(driver, userConfig.get(FIRST_NAME), MEDIUM_TIMEOUT); DriverConfig.setLogString("Enter first name as " + firstName, true); driver.findElement(By.id(userConfig.get(FIRST_NAME))).sendKeys(firstName); DriverConfig.setLogString("Enter last name as " + lastName, true); driver.findElement(By.id(userConfig.get(LAST_NAME))).sendKeys(lastName); DriverConfig.setLogString("Enter email address " + emailAddress, true); driver.findElement(By.id(userConfig.get(EMAIL_FIELD))).sendKeys(emailAddress); DriverConfig.setLogString("Enter user name " + accountUserName, true); driver.findElement(By.id(userConfig.get(ACCESS_LOGIN))).sendKeys(accountUserName); DriverConfig.setLogString("select user status ", true); final Select select1 = new Select(driver.findElement(By.id(userConfig.get(USER_STATUS)))); select1.selectByVisibleText(activeUser); /* * Select select2 = new Select(driver.findElement(By.id(userConfig.get(PARTNER_TYPE)))); * select2.selectByVisibleText(partnerType); */ DriverConfig.setLogString("check partner element displayed.", true); final boolean partnerElement = isDisplayedById(driver, userConfig.get(PARTNER_ID), MEDIUM_TIMEOUT); (new WebDriverWait(driver, SHORT_TIMEOUT)).until(new ExpectedCondition<Boolean>() { public Boolean apply(WebDriver d) { boolean outcome = false; outcome = !d.getPageSource().contains(userConfig.get(DEFAULT_PARTNER_ID)) ? true : false; return outcome; } }); if (!partnerElement) { final WebElement partnerText = driver .findElement(By.xpath("//td[contains(text(),'Partner')]/following-sibling::td")); DriverConfig.setLogString("Default Partner :" + partnerText.getText(), true); } if (!partner.isEmpty()) { final Select select3 = new Select(driver.findElement(By.id(userConfig.get(PARTNER_ID)))); select3.selectByVisibleText(partner); } }
From source file:com.ecofactor.qa.automation.insite.page.UserManagementImpl.java
License:Open Source License
/** * <p>/*from w w w .j a v a 2s . c om*/ * Remove all values from the assigned panel to the available panel and verify there is no value * in the assigned pane. * </p> * @param driver the driver */ private void removeAllToAvailablePane(final WebDriver driver) { DriverConfig.setLogString("Remome all values from the assigned Pane and moving to available pane", true); final Select select = new Select(driver.findElement(By.id(userConfig.get(ASSIGNED_ROLES)))); final List<WebElement> optionsList = select.getOptions(); for (final WebElement webElement : optionsList) { select.selectByVisibleText(webElement.getText()); driver.findElement(By.id("remove")).click(); } final List<WebElement> optionsList2 = select.getOptions(); (new WebDriverWait(driver, SHORT_TIMEOUT)).until(new ExpectedCondition<Boolean>() { public Boolean apply(WebDriver d) { boolean outcome = false; outcome = optionsList2.size() == 0 ? true : false; return outcome; } }); }