List of usage examples for org.openqa.selenium WebDriver navigate
Navigation navigate();
From source file:com.comcast.magicwand.drivers.AbstractPhoenixDriver.java
License:Apache License
/** * {@inheritDoc}/*from w ww. ja va 2 s . c o m*/ */ public Navigation navigate() { WebDriver driver = this.getDriver(); Navigation navigate = null; if (null != driver) { navigate = driver.navigate(); } return navigate; }
From source file:com.ecofactor.qa.automation.newapp.InfrastructureTest.java
License:Open Source License
/** * Creates the driver.//from w w w. j a v a 2 s .c o m * @return the web driver */ @SuppressWarnings("unused") private WebDriver createDriver() { LogUtil.setLogString("Create New webdriver", true); LogUtil.setLogString("Browser : " + System.getProperty("browser"), true); final WebDriver driver = SeleniumDriverUtil.createBrowserDriver(System.getProperty("browser")); driver.manage().window().maximize(); final String url = mobileConfig.get(ECOFACTOR_URL); LogUtil.setLogString("Load Url: " + url, true); driver.navigate().to(url); smallWait(); return driver; }
From source file:com.ecofactor.qa.automation.newapp.MenuTest.java
License:Open Source License
/** * Creates the driver.//from w ww. j a v a2s. com * @return the web driver */ @SuppressWarnings("unused") private WebDriver createWebDriver() { LogUtil.setLogString("Create New webdriver", true); LogUtil.setLogString("Browser : " + System.getProperty("browser"), true); final WebDriver driver = SeleniumDriverUtil.createBrowserDriver(System.getProperty("browser")); driver.manage().window().maximize(); final String url = mobileConfig.get(MobileConfig.ECOFACTOR_URL); LogUtil.setLogString("Load Url: " + url, true); driver.navigate().to(url); WaitUtil.smallWait(); return driver; }
From source file:com.ecofactor.qa.automation.newapp.ThermostatControlEETest.java
License:Open Source License
/** * Sets the point reason api./* ww w . j a va 2s .c o m*/ * @param userName the user name * @param password the password * @param thermostatId the thermostat id */ @Test(groups = { Groups.SANITY1, Groups.BROWSER, Groups.ANDROID }, dataProvider = "defaultSavingsEnegry", dataProviderClass = CommonsDataProvider.class, priority = 8) public void setPointReasonAPI(final String userName, final String password, Integer thermostatId) { loadPage(userName, password, true); thPageOps.openTstatController(); Assert.assertTrue(thCtrlOpsPage.isPageLoaded(), "Tstat Control Page is not Opened"); Assert.assertTrue(thCtrlUIPage.isSavingsEnergyLinkDisplayed(), "Savings Energy Link is not displayed"); WebDriver driver = null; try { loginPage.setLoggedIn(false); LogUtil.setLogString(LogSection.START, "New Browser verfication starts", true); driver = createWebDriver(); loginPage.setDriver(driver); thPageOps.setDriver(driver); thPageUI.setDriver(driver); thCtrlUIPage.setDriver(driver); loadPage(userName, password, true); thPageOps.openTstatController(); Assert.assertTrue(thCtrlOpsPage.isPageLoaded(), "Tstat Control Page is not Opened"); loginPage.setDriver(null); thCtrlOpsPage.setDriver(driver); String content = thCtrlOpsPage.getEEapi( "https://my-apps-qa.ecofactor.com/ws/v1.0/thermostat/" + thermostatId + "/state", null, 200); LogUtil.setLogString("Json result :" + content, true); JSONObject jsonObj = new JSONObject(content); String setPointReason = jsonObj.get("setpoint_reason").toString(); LogUtil.setLogString("SetPoint reason :" + setPointReason, true); driver.navigate().back(); Assert.assertTrue(setPointReason.equalsIgnoreCase("ee"), "Setpoint Reason is not EE"); thPageOps.setDriver(null); thCtrlOpsPage.setDriver(null); thCtrlUIPage.setDriver(null); thPageUI.setDriver(null); LogUtil.setLogString(LogSection.END, "New Browser verification ends", true); } catch (Exception ex) { ex.printStackTrace(); } finally { loginPage.setDriver(null); thPageOps.setDriver(null); thCtrlOpsPage.setDriver(null); thCtrlUIPage.setDriver(null); thPageUI.setDriver(null); if (driver != null) { LogUtil.setLogString("Quit driver for new browser", true); driver.quit(); } } WaitUtil.mediumWait(); thCtrlOpsPage.closeThermostatControl(); Assert.assertTrue(thPageUI.isUnderSavingsEnergy(), "Savings Energy is not displayed"); }
From source file:com.ecofactor.qa.automation.newapp.ThermostatControlEETest.java
License:Open Source License
/** * Creates the driver.//from ww w . j ava2 s . c o m * @return the web driver */ private WebDriver createWebDriver() { LogUtil.setLogString("Create New webdriver", true); LogUtil.setLogString("Browser : " + System.getProperty("browser"), true); final WebDriver driver = SeleniumDriverUtil.createBrowserDriver(System.getProperty("browser")); driver.manage().window().maximize(); final String url = mobileConfig.get(MobileConfig.ECOFACTOR_URL); LogUtil.setLogString("Load Url: " + url, true); driver.navigate().to(url); WaitUtil.smallWait(); return driver; }
From source file:com.ecofactor.qa.automation.newapp.ThermostatTest.java
License:Open Source License
/** * Creates the driver.//w ww .j av a 2 s.c o m * @return the web driver */ private WebDriver createDriver() { LogUtil.setLogString("Create New webdriver", true); LogUtil.setLogString("Browser : " + System.getProperty("browser"), true); final WebDriver driver = SeleniumDriverUtil.createBrowserDriver(System.getProperty("browser")); driver.manage().window().maximize(); final String url = mobileConfig.get(ECOFACTOR_URL); LogUtil.setLogString("Load Url: " + url, true); driver.navigate().to(url); smallWait(); return driver; }
From source file:com.ecofactor.qa.automation.util.mail.Gmail.java
License:Open Source License
/** * Gets the changed password.//from www . java 2 s . co 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.OutlookMail.java
License:Open Source License
/** * Gets the changed password.//from ww w . ja v a 2 s. co 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.epam.jdi.uitests.mobile.appium.preconditions.IPreconditions.java
License:Open Source License
static void openUri(String uri, WebDriver driver) { //Timer timer = new Timer(1000, 100); driver.navigate().to(getUrlByUri(uri)); /*if (!timer.timeoutPassed()) driver.navigate().to(getUrlByUri(uri));*/ }
From source file:com.gargoylesoftware.htmlunit.HistoryTest.java
License:Apache License
/** * Tests going in history {@link History#back()} with {@code POST} request. * * @throws Exception if an error occurs/*from w ww .ja v a2 s . c o m*/ */ @Test public void post() throws Exception { final Map<String, Class<? extends Servlet>> servlets = new HashMap<>(); servlets.put("/post1", Post1Servlet.class); servlets.put("/post2", Post2Servlet.class); servlets.put("/post3", Post3Servlet.class); startWebServer("./", new String[0], servlets); final WebDriver driver = getWebDriver(); driver.get(URL_FIRST + "post1"); driver.findElement(By.id("mySubmit")).click(); assertEquals(URL_FIRST + "post2", driver.getCurrentUrl()); assertTrue(driver.getPageSource().contains("POST")); assertTrue(driver.getPageSource().contains("para1=value1")); driver.findElement(By.linkText("Go to GET")).click(); assertEquals(URL_FIRST + "post3", driver.getCurrentUrl()); assertTrue(driver.getPageSource().contains("GET")); driver.navigate().back(); assertEquals(URL_FIRST + "post2", driver.getCurrentUrl()); assertTrue(driver.getPageSource().contains("POST")); assertTrue(driver.getPageSource().contains("para1=value1")); }