List of usage examples for org.openqa.selenium WebDriver getCurrentUrl
String getCurrentUrl();
From source file:pt.fccn.arquivo.pages.SearchPage.java
License:Open Source License
/** * Create a new SearchPage from navigation * @param driver//from w w w . j a v a 2 s.c o m */ public SearchPage(WebDriver driver, boolean Ispre_prod) { this.driver = driver; // Check that we're on the right page. this.ispre_prod = Ispre_prod; if (!(driver.getCurrentUrl().contains(pageURLCheck))) { throw new IllegalStateException( "This is not the results search page\n URL of current page: " + driver.getCurrentUrl()); } if (ispre_prod) { this.server_name = driver.getCurrentUrl().replace("search.jsp?l=pt&query=fccn", ""); } }
From source file:pt.fccn.arquivo.pages.TermsAndConditionsPage.java
License:Open Source License
/** * Constructs a Terms and conditions./*from w w w. j a va 2 s .c o m*/ * @param driver <code>org.openqa.selenium.WebDriver</code> use for this page */ public TermsAndConditionsPage(WebDriver driver) { this.driver = driver; // Check that we're on the right page. if (!(driver.getTitle().contains(titleTextPT))) { // Alternatively, we could navigate to the login page, perhaps logging out first throw new IllegalStateException("This is not the terms and conditions page\n" + driver.getCurrentUrl() + "" + this.getClass().getName()); } }
From source file:ru.devprom.pages.admin.UserAddNewPage.java
public UserAddNewPage(WebDriver driver) { super(driver); Assert.assertTrue(isElementPresent(By.id("cms_UserPassword"))); FILELOG.debug("Open Add Group page"); FILELOG.debug("Current URL is: " + driver.getCurrentUrl()); }
From source file:ru.stqa.selenium.wrapper.EventFiringWrapperTest.java
License:Apache License
@Test public void canFireEventForGetCurrentUrl() { final WebDriver mockedDriver = mock(WebDriver.class); final WebDriverListener mockedListener = mock(WebDriverListener.class); when(mockedDriver.getCurrentUrl()).thenReturn("http://localhost/"); EventFiringWrapper wrapper = new EventFiringWrapper(mockedDriver); wrapper.addListener(mockedListener); final WebDriver driver = wrapper.getDriver(); assertEquals(driver.getCurrentUrl(), "http://localhost/"); verify(mockedDriver, times(1)).getCurrentUrl(); verify(mockedListener, times(1)).beforeGetCurrentUrl(mockedDriver); verify(mockedListener, times(1)).afterGetCurrentUrl(mockedDriver, "http://localhost/"); }
From source file:stepparsing.StepParsing.java
public static String getRegisteredAccount(WebDriver driver, String login) { String AccEmail = login;//w ww .j a v a 2 s .co m driver.get("https://www.amazon.com"); try { Thread.sleep(1000 * 5); } catch (InterruptedException e) { e.printStackTrace(); } WebElement regDiv = driver.findElement(By.id(("nav-flyout-ya-signin"))); WebElement regAElement = regDiv.findElement(By.tagName("a")); String regLink = regAElement.getAttribute("href"); if (!regLink.contains("https://www.amazon.com")) { regLink = "https://www.amazon.com" + regLink; } driver.get(regLink); try { Thread.sleep(1000 * 5); } catch (InterruptedException e) { e.printStackTrace(); } WebElement newRegAElement = driver.findElement(By.id("createAccountSubmit")); String newRegLink = newRegAElement.getAttribute("href"); if (!newRegLink.contains("https://www.amazon.com")) { regLink = "https://www.amazon.com" + regLink; } driver.get(newRegLink); try { Thread.sleep(1000 * 10); } catch (InterruptedException e) { e.printStackTrace(); } WebElement nameInput = driver.findElement(By.id("ap_customer_name")); nameInput.sendKeys("Petrov"); WebElement emailInput = driver.findElement(By.id("ap_email")); emailInput.sendKeys(AccEmail); WebElement passInput = driver.findElement(By.id("ap_password")); passInput.sendKeys("123456789"); WebElement passCheckInput = driver.findElement(By.id("ap_password_check")); passCheckInput.sendKeys("123456789"); WebElement submitInput = driver.findElement(By.id("continue")); try { Thread.sleep(1000 * 60); } catch (InterruptedException e) { e.printStackTrace(); } submitInput.click(); try { Thread.sleep(1000 * 5); } catch (InterruptedException e) { e.printStackTrace(); } String curURL = driver.getCurrentUrl(); driver.get(curURL); try { Thread.sleep(1000 * 5); } catch (InterruptedException e) { e.printStackTrace(); } if (driver.getPageSource().contains("Petrov")) { WebDriverFactory.dismissDriver(driver); return AccEmail; } else { AccEmail = ""; System.out.println("Registrstion didn't complite!"); } WebDriverFactory.dismissDriver(driver); return AccEmail; }
From source file:testselenium.TestSel.java
public static void regNewAccount() throws InterruptedException { // ? System.setProperty("webdriver.gecko.driver", "C:\\selenium\\geckodriver.exe"); /*// w ww .j a v a2s .c om ProfilesIni profiles = new ProfilesIni(); FirefoxProfile profile = profiles.getProfile("WDS"); profile.setPreference("permissions.default.image", 1); // 2 - , 1 - /*profile.setPreference("network.proxy.type", 1); profile.setPreference("network.proxy.type", "121.122.123.2"); profile.setPreference("network.proxy.type", 8502); */ WebDriver webdr = new FirefoxDriver(); // profile ? default webdr.manage().timeouts().pageLoadTimeout(30, TimeUnit.SECONDS); //? ? webdr.manage().timeouts().setScriptTimeout(30, TimeUnit.SECONDS); //? ? webdr.get("https://www.amazon.com/"); WebElement newAccountElement = webdr.findElement(By.id("nav-flyout-ya-newCust")); WebElement newAccLinkElement = newAccountElement.findElement(By.tagName("a")); // String newAccLink = newAccLinkElement.getAttribute("href"); // ? 44-47 ? ?, ? ?!!! // System.out.println(newAccLink); // ? webdr.get(newAccLink); // ? ? WebElement inputNameField = webdr.findElement(By.id("ap_customer_name")); inputNameField.sendKeys("Ignatenko Alexandr Borodach"); WebElement inputEmailField = webdr.findElement(By.id("ap_email")); inputEmailField.sendKeys("abkj67rfra@gmail.com"); WebElement inputPassField = webdr.findElement(By.id("ap_password")); inputPassField.sendKeys("1234567890"); WebElement inputPassCheckField = webdr.findElement(By.id("ap_password_check")); inputPassCheckField.sendKeys("1234567890"); WebElement regBtn = webdr.findElement(By.id("continue")); regBtn.click(); // ?? "" Thread.sleep(1000 * 7); // ? 20 ? ? ? // ? ? ? ?? click String logginedPageLink = webdr.getCurrentUrl(); webdr.get(logginedPageLink); Thread.sleep(1000 * 60); // ? 20 ? ? ? webdr.quit(); }
From source file:testselenium.TestSel.java
public static String getProveOfLogin(String email, String password) throws InterruptedException { // 86 - 96 ? ? String logginedPage = ""; System.setProperty("webdriver.gecko.driver", "C:\\selenium\\geckodriver.exe"); // ? WebDriver driver = new FirefoxDriver(); // profile ? default driver.manage().timeouts().pageLoadTimeout(30, TimeUnit.SECONDS); //? ? driver.manage().timeouts().setScriptTimeout(30, TimeUnit.SECONDS); //? ? driver.get("https://www.amazon.com/"); WebElement authLinkBtn = driver.findElement(By.id("nav-flyout-ya-signin")); WebElement authLinkElement = authLinkBtn.findElement(By.tagName("a")); String loginLink = authLinkElement.getAttribute("href"); driver.get(loginLink); // ? , WebElement inputEmailField = driver.findElement(By.id("ap_email")); inputEmailField.sendKeys(email);/*from w w w . ja v a 2 s . c o m*/ WebElement inputPassField = driver.findElement(By.id("ap_password")); inputPassField.sendKeys(password); WebElement authBtn = driver.findElement(By.id("signInSubmit")); authBtn.click(); // ?? "" Thread.sleep(1000 * 5); // ? 20 ? ? ? // ? ? ? ?? click String logginedPageLink = driver.getCurrentUrl(); driver.get(logginedPageLink); Thread.sleep(1000 * 10); // ? 20 ? logginedPage = driver.getPageSource(); // logginedPage ? . ? ? ? ?? ? ( Hello? name! return logginedPage; }
From source file:testselenium.TestSel.java
public static String getSearchURL() throws InterruptedException { // ? String searchURL = ""; System.setProperty("webdriver.gecko.driver", "C:\\selenium\\geckodriver.exe"); WebDriver webdrAmazon = new FirefoxDriver(); webdrAmazon.manage().timeouts().pageLoadTimeout(30, TimeUnit.SECONDS); webdrAmazon.manage().timeouts().setScriptTimeout(30, TimeUnit.SECONDS); webdrAmazon.get("https://www.amazon.com/"); WebElement inputField = webdrAmazon.findElement(By.id("twotabsearchtextbox")); inputField.sendKeys("toys"); webdrAmazon.manage().timeouts().pageLoadTimeout(30, TimeUnit.SECONDS); try {//from ww w.j a va2 s . c o m Thread.sleep(1000 * 6); } catch (InterruptedException e) { e.printStackTrace(); webdrAmazon.quit(); getSearchURL(); } // ? 15 ? WebElement searchBtnBlock = webdrAmazon.findElement(By.id("nav-search-submit-text")); searchBtnBlock.click(); try { Thread.sleep(1000 * 5); } catch (InterruptedException e) { e.printStackTrace(); webdrAmazon.quit(); getSearchURL(); } // ? 5 ? String currentURL = webdrAmazon.getCurrentUrl(); webdrAmazon.get(currentURL); WebElement nextPageLink = webdrAmazon.findElement(By.id("pagnNextLink")); String nextPageHREF = nextPageLink.getAttribute("href"); webdrAmazon.get(nextPageHREF); nextPageLink.click(); try { Thread.sleep(1000 * 6); } catch (InterruptedException e) { e.printStackTrace(); webdrAmazon.quit(); getSearchURL(); } // ? 5 ? currentURL = webdrAmazon.getCurrentUrl(); webdrAmazon.get(currentURL); try { Thread.sleep(1000 * 6); } catch (InterruptedException e) { e.printStackTrace(); webdrAmazon.quit(); getSearchURL(); } // ? 5 ? searchURL = webdrAmazon.getCurrentUrl(); try { Thread.sleep(1000 * 3); } catch (InterruptedException e) { e.printStackTrace(); webdrAmazon.quit(); getSearchURL(); } // ? 5 ? webdrAmazon.quit(); return searchURL; }
From source file:utilities.AccountHelper.java
public void bong88Login(WebDriver driver) { String username = "sjk36t300019"; String password = "Qqq111"; String homeUrl = "http://bong88.com"; driver.get(homeUrl);//from w w w .java2s .c o m if (driver.getCurrentUrl().contains("login888")) { List<WebElement> userFields = driver.findElements(By.xpath("//input[@id='txtID']")); List<WebElement> pwdFields = driver.findElements(By.xpath("//input[@id='txtPW']")); List<WebElement> loginBtns = driver .findElements(By.xpath("//div[@class='loginBtnPos']/a[@class='login_btn']")); if (userFields.size() > 0 && pwdFields.size() > 0 && loginBtns.size() > 0 && userFields.size() < 2 && pwdFields.size() < 2 && loginBtns.size() < 2) { userFields.get(0).sendKeys(username); pwdFields.get(0).sendKeys(password); loginBtns.get(0).click(); } else { helper.setLog("Username or Password or Login button not found."); } } else { helper.setLog("User seems to be logged in."); } }
From source file:utils.WebDriverUtils.java
public static String getCurrentUrl(WebDriver webDriver) { return webDriver.getCurrentUrl(); }