List of usage examples for org.openqa.selenium WebDriver findElement
@Override WebElement findElement(By by);
From source file:com.ecofactor.qa.automation.insite.page.UserManagementImpl.java
License:Open Source License
/** * <p>/*from w w w .j a v a2s. co m*/ * Click Contact Information and send realted values to the New user * </p> * . * @param driver the driver * @param streetAddress1 the street address1 * @param streetAddress2 the street address2 * @param city the city * @param state the state * @param zip the zip * @param country the country * @param mobilePhoneNumber the mobile phone number * @param homePhoneNumber the home phone number * @param fax the fax */ private void sendContactInformation(final WebDriver driver, final String streetAddress1, final String streetAddress2, final String city, final String state, final String zip, final String country, final String mobilePhoneNumber, final String homePhoneNumber, final String fax) { DriverConfig.setLogString("Send Contact information details to the ContactInformation Tab", true); DriverConfig.setLogString("select corresponding tab.", true); clickContactDetailsTab(); DriverConfig.setLogString("check if street addres1 is displayed.", true); isDisplayedById(driver, userConfig.get(STREET_ADDRESS1), MEDIUM_TIMEOUT); DriverConfig.setLogString("Enter street address1 as " + streetAddress1, true); driver.findElement(By.id(userConfig.get(STREET_ADDRESS1))).sendKeys(streetAddress1); DriverConfig.setLogString("Enter street address2 as " + streetAddress2, true); driver.findElement(By.id(userConfig.get(STREET_ADDRESS2))).sendKeys(streetAddress2); DriverConfig.setLogString("Enter city " + city, true); driver.findElement(By.id(userConfig.get(CITY))).sendKeys(city); DriverConfig.setLogString("Enter state " + state, true); driver.findElement(By.id(userConfig.get(STATE))).sendKeys(state); DriverConfig.setLogString("Enter zip " + zip, true); driver.findElement(By.id(userConfig.get(ZIP))).sendKeys(zip); DriverConfig.setLogString("Enter country " + country, true); driver.findElement(By.id(userConfig.get(COUNTRY))).sendKeys(country); DriverConfig.setLogString("Enter mobile no " + mobilePhoneNumber, true); driver.findElement(By.id(userConfig.get(MOBILE_NUM))).sendKeys(mobilePhoneNumber); DriverConfig.setLogString("Enter home phone " + homePhoneNumber, true); driver.findElement(By.id(userConfig.get(PHONE_NUM))).sendKeys(homePhoneNumber); DriverConfig.setLogString("Enter fax " + fax, true); driver.findElement(By.id(userConfig.get(FAX_NUM))).sendKeys(fax); }
From source file:com.ecofactor.qa.automation.insite.page.UserManagementImpl.java
License:Open Source License
/** * <p>/*w w w.j ava 2s . c o m*/ * Click Role tab, and select the available roles. * </p> * @param driver the driver * @param availableRole the available role */ private void sendRoleDetails(final WebDriver driver, final String availableRole) { DriverConfig.setLogString( "Click on Role tab and Send the Role details to the selection, and add it to the pane.", true); isDisplayedById(driver, "roles", SHORT_TIMEOUT); clickRoleTab(); DriverConfig.setLogString("check if available roles element is displayed.", true); isDisplayedById(driver, userConfig.get(AVAILABLE_ROLES), MEDIUM_TIMEOUT); DriverConfig.setLogString("unselect existing selection.", true); removeAllToAvailablePane(driver); final Select select = new Select(driver.findElement(By.id(userConfig.get(AVAILABLE_ROLES)))); select.deselectAll(); DriverConfig.setLogString("select required role " + availableRole, true); if (!availableRole.isEmpty()) { select.selectByVisibleText(availableRole); DriverConfig.setLogString("click on add button.", true); driver.findElement(By.id("add")).click(); } }
From source file:com.ecofactor.qa.automation.insite.page.UserManagementImpl.java
License:Open Source License
/** * <p>//from ww w . j av a 2 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) { 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; } }); }
From source file:com.ecofactor.qa.automation.platform.util.Pageutil.java
License:Open Source License
/** * Gets the element.//w w w .ja va 2 s. co m * @param driver the driver * @param locator the locator * @param timeout the timeout * @return the element */ public static WebElement getElement(final WebDriver driver, final By locator, final CustomTimeout timeout) { try { return new WebDriverWait(driver, timeout.getValue()).until(new ExpectedCondition<WebElement>() { public WebElement apply(final WebDriver driver) { return driver.findElement(locator); } }); } catch (TimeoutException timeOutException) { return null; } }
From source file:com.ecofactor.qa.automation.util.mail.Gmail.java
License:Open Source License
/** * Gets the changed password.//from w w w. j a v a 2 s . c o m * @param url the url * @param emailUserName the email user name * @param emailPassword the email password * @param subject the subject * @param boldIndex the bold index * @param pwdIndex the pwd index * @return the changed password */ public String getChangedPassword(String url, String emailUserName, String emailPassword, String subject, int boldIndex, int pwdIndex) { WebDriver driver = DriverConfig.getDriver(); if (DriverConfig.getDriver() == null) { driverConfig.loadDriver(); driver = DriverConfig.getDriver(); } String tempPassword = null; largeWait(); DriverConfig.setLogString("Load Email portal URL at change password", true); driver.navigate().to(url + "" + emailUserName); largeWait(); boolean session = isDisplayedById(driver, "Passwd", MEDIUM_TIMEOUT); if (session) { DriverConfig.setLogString( "Enter username and password for Email(" + emailUserName + "/" + emailPassword + ")", true); driver.findElement(By.id("Email")).sendKeys(emailUserName); driver.findElement(By.id("Passwd")).sendKeys(emailPassword); mediumWait(); WebElement signInButtonElement = driver.findElement(By.id("signIn")); DriverConfig.setLogString("click Sign In button", true); signInButtonElement.click(); largeWait(); boolean button = isDisplayedById(driver, "no-button", MEDIUM_TIMEOUT); if (button) { WebElement buttonElement = driver.findElement(By.id("no-button")); buttonElement.click(); mediumWait(); } } isDisplayedByCSS(driver, ".aio.UKr6le", MEDIUM_TIMEOUT); DriverConfig.setLogString("Click Inbox.", true); WebElement inboxElement = DriverConfig.getDriver().findElement(By.partialLinkText("Inbox")); inboxElement.click(); largeWait(); DriverConfig.setLogString("Click Subject of Email.", true); WebElement webElement = driver.findElement(By.cssSelector(".ae4.UI.UJ")); List<WebElement> tagElement = webElement.findElements(By.tagName(TAG_BOLD)); WebElement firstElement = tagElement.get(0); if (firstElement != null && firstElement.isDisplayed() && firstElement.getText().equalsIgnoreCase(subject)) { firstElement.click(); largeWait(); } DriverConfig.setLogString("Get temporary Password/activation link from Email.", true); if (boldIndex == 1) { WebElement divBodyElement = driver.findElement(By.xpath("//*[contains(@class,'adO')]")); if (pwdIndex == 1) { WebElement pwdElement = divBodyElement.findElements(By.tagName(TAG_STRONG)).get(0); tempPassword = pwdElement.getText(); DriverConfig.setLogString("Temporary password got from email " + tempPassword, true); } else { WebElement pwdElement = divBodyElement.findElements(By.tagName(TAG_ANCHOR)).get(0); tempPassword = pwdElement.getText(); DriverConfig.setLogString("Activation link got from email " + tempPassword, true); } } else if (boldIndex == 0) { DriverConfig.setLogString("Header Tag", true); WebElement divBodyElement = driver.findElement(By.className("gs")); List<WebElement> headerElement = divBodyElement.findElements(By.tagName("strong")); for (WebElement webelement : headerElement) { if (webelement.isDisplayed()) { tempPassword = webelement.getText(); DriverConfig.setLogString("Temporary password got from email " + tempPassword, true); } } } mediumWait(); deleteFirstMail(driver); DriverConfig.setLogString("Click user for Signout option", true); boolean value = isDisplayedById(DriverConfig.getDriver(), "gbgs4dn", MEDIUM_TIMEOUT); DriverConfig.setLogString("User name displayed for sign out : " + value, true); if (value) { driver.findElement(By.id("gbgs4dn")).click(); } else { WebElement signOutElement = DriverConfig.getDriver().findElement(By.partialLinkText(emailUserName)); signOutElement.click(); } smallWait(); DriverConfig.setLogString("Click Signout", true); driver.findElement(By.id("gb_71")).click(); mediumWait(); mediumWait(); return tempPassword; }
From source file:com.ecofactor.qa.automation.util.mail.Gmail.java
License:Open Source License
/** * Delete first mail./*from w w w . ja v a 2 s .c o m*/ * @param driver the driver */ public void deleteFirstMail(WebDriver driver) { DriverConfig.setLogString("Delete First Mail", true); DriverConfig.setLogString("Click Inbox", true); WebElement inboxElement = DriverConfig.getDriver().findElement(By.partialLinkText("Inbox")); inboxElement.click(); mediumWait(); DriverConfig.setLogString("Click Subject of Email.", true); boolean subjectDisplayed = isDisplayedByCSS(driver, ".ae4.UI.UJ", MEDIUM_TIMEOUT); if (subjectDisplayed) { WebElement webElement1 = driver.findElement(By.cssSelector(".ae4.UI.UJ")); if (!webElement1.getText().contains("No new mail")) { WebElement firstElement2 = null; if (webElement1 != null && webElement1.findElements(By.tagName(TAG_BOLD)) != null && webElement1.findElements(By.tagName(TAG_BOLD)).size() > 0) { firstElement2 = webElement1.findElements(By.tagName(TAG_BOLD)).get(0); } else { firstElement2 = webElement1.findElements(By.cssSelector("td.yX.xY")).get(0); } if (firstElement2 != null && firstElement2.isDisplayed()) { firstElement2.click(); mediumWait(); DriverConfig.setLogString("Delete the Email", true); if (driver.findElements(By.cssSelector("div.ar9.T-I-J3.J-J5-Ji")) != null && driver.findElements(By.cssSelector("div.ar9.T-I-J3.J-J5-Ji")).size() == 2) { DriverConfig.setLogString("Click delete old mails", true); WebElement webElement2 = driver.findElements(By.cssSelector("div.ar9.T-I-J3.J-J5-Ji")) .get(1); webElement2.click(); } else { DriverConfig.setLogString("Click delete old mails", true); smallWait(); WebElement webElement2 = driver.findElements(By.cssSelector("div.ar9.T-I-J3.J-J5-Ji")) .get(1); webElement2.click(); } smallWait(); } } } }
From source file:com.ecofactor.qa.automation.util.mail.GmailForNewUser.java
License:Open Source License
/** * Delete first mail.//w w w.j av a2s . c o m * @param driver the driver */ public void deleteFirstMail(WebDriver driver) { DriverConfig.setLogString("Delete First Mail", true); DriverConfig.setLogString("Click Inbox", true); WebElement inboxElement = driver.findElement(By.partialLinkText("Inbox")); inboxElement.click(); mediumWait(); DriverConfig.setLogString("Click Subject of Email.", true); // boolean subjectDisplayed=isDisplayedByTagName(driver, TAG_BOLD, MEDIUM_TIMEOUT); boolean subjectDisplayed = isDisplayedByCSS(driver, ".ae4.UI.UJ", MEDIUM_TIMEOUT); if (subjectDisplayed) { WebElement webElement1 = driver.findElement(By.cssSelector(".ae4.UI.UJ")); // WebElement webElement1 = driver.findElement(By.xpath(".//*[span]")); if (!webElement1.getText().contains("No new mail")) { WebElement firstElement2 = null; if (webElement1 != null && webElement1.findElements(By.tagName(TAG_BOLD)) != null && webElement1.findElements(By.tagName(TAG_BOLD)).size() > 0) { firstElement2 = webElement1.findElements(By.tagName(TAG_BOLD)).get(0); } else { firstElement2 = webElement1.findElements(By.cssSelector("td.yX.xY")).get(0); } if (firstElement2 != null && firstElement2.isDisplayed()) { firstElement2.click(); mediumWait(); DriverConfig.setLogString("Delete the Email", true); if (driver.findElements(By.cssSelector("div.ar9.T-I-J3.J-J5-Ji")) != null && driver.findElements(By.cssSelector("div.ar9.T-I-J3.J-J5-Ji")).size() == 2) { DriverConfig.setLogString("Click delete old mails", true); WebElement webElement2 = driver.findElements(By.cssSelector("div.ar9.T-I-J3.J-J5-Ji")) .get(1); webElement2.click(); } else { DriverConfig.setLogString("Click delete old mails", true); smallWait(); WebElement webElement2 = driver.findElements(By.cssSelector("div.ar9.T-I-J3.J-J5-Ji")) .get(1); webElement2.click(); } smallWait(); } } } }
From source file:com.ecofactor.qa.automation.util.mail.OutlookMail.java
License:Open Source License
/** * Gets the changed password.//from w ww .j av a 2s . c o m * @param driver the driver * @param url the url * @param emailUserName the email user name * @param emailPassword the email password * @param subject the subject * @param boldIndex the bold index * @return the changed password */ public String getChangedPassword(String url, String emailUserName, String emailPassword, String subject, int boldIndex) { WebDriver driver = driverConfig.getDriver(); DriverConfig.setLogString("Load Email portal URL.", true); driver.navigate().to(url); largeWait(); DriverConfig.setLogString("Enter Username/Password for Email.", true); driver.findElement(By.id("cred_userid_inputtext")).sendKeys(emailUserName); driver.findElement(By.id("cred_password_inputtext")).sendKeys(emailPassword); smallWait(); DriverConfig.setLogString("Click Login.", true); WebElement signInButtonElement = driver.findElement(By.cssSelector("#cred_sign_in_button")); DriverConfig.setLogString("send keys to login", true); signInButtonElement.sendKeys(Keys.RETURN); largeWait(); DriverConfig.setLogString("click btn", true); signInButtonElement.click(); largeWait(); DriverConfig.setLogString("Click Inbox.", true); WebElement outLookMenu = retrieveElementByTagText(driver, TAG_SPAN, "Outlook"); if (outLookMenu != null && outLookMenu.isDisplayed()) { outLookMenu.click(); mediumWait(); } DriverConfig.setLogString("Click Subject of Email.", true); List<WebElement> subElements = retrieveElementsByTagText(driver, TAG_SPAN, subject); if (subElements.size() > 0) { subElements.get(0).click(); mediumWait(); } largeWait(); DriverConfig.setLogString("Get temporary Password from Email.", true); WebElement divBodyElement = driver.findElement(By.id("Item.MessagePartBody")); mediumWait(); WebElement pwdElement = divBodyElement.findElements(By.tagName(TAG_BOLD)).get(boldIndex); String tempPassword = pwdElement.getText(); DriverConfig.setLogString("Temporary password got from email " + tempPassword, true); DriverConfig.setLogString("Click user for Signout option", true); WebElement menuElement = retrieveElementByAttributeValue(driver, TAG_BUTTON, ATTR_CLASS, "button _hl_2 _hl_e"); menuElement.click(); smallWait(); DriverConfig.setLogString("Click Signout", true); WebElement signOut = retrieveElementByTagText(driver, TAG_SPAN, "sign out", MEDIUM_TIMEOUT); signOut.click(); smallWait(); return tempPassword; }
From source file:com.ecofactor.qa.automation.util.PageUtil.java
License:Open Source License
/** * Utility to check weather the particular field is displayed or not. * @param driver the driver/* ww w . j a v a2s.c om*/ * @param fieldname the fieldname * @param timeOut the time out * @return boolean */ public static boolean isDisplayedById(final WebDriver driver, final String fieldname, final int timeOut) { boolean isLoaded = false; try { isLoaded = (new WebDriverWait(driver, timeOut)).until(new ExpectedCondition<Boolean>() { public Boolean apply(WebDriver d) { WebElement element = d.findElement(By.id(fieldname)); return element.isDisplayed(); } }); } catch (TimeoutException te) { isLoaded = false; } return isLoaded; }
From source file:com.ecofactor.qa.automation.util.PageUtil.java
License:Open Source License
/** * Sets the value./*from w w w . j a va 2 s.c o m*/ * @param driver the driver * @param id the id * @param value the value */ public static void setValue(WebDriver driver, String id, String value) { if (isDisplayedById(driver, id, 10)) { WebElement input = driver.findElement(By.id(id)); input.clear(); input.sendKeys(value); } }