Example usage for org.openqa.selenium WebDriver get

List of usage examples for org.openqa.selenium WebDriver get

Introduction

In this page you can find the example usage for org.openqa.selenium WebDriver get.

Prototype

void get(String url);

Source Link

Document

Load a new web page in the current browser window.

Usage

From source file:org.orcid.integration.blackbox.api.v2.rc1.BlackBoxBase.java

License:Open Source License

public static void revokeApplicationsAccess(String... clientIdsParam) {
    // Nothing to remove
    if (clientIdsParam == null) {
        return;//from w ww  .  j a va 2s. c  o m
    }
    List<String> clientIds = new ArrayList<String>();
    for (String clientId : clientIdsParam) {
        if (!PojoUtil.isEmpty(clientId)) {
            clientIds.add(clientId);
        }
    }

    String userName = System.getProperty("org.orcid.web.testUser1.username");
    String password = System.getProperty("org.orcid.web.testUser1.password");
    String baseUrl = "https://localhost:8443/orcid-web";
    if (!PojoUtil.isEmpty(System.getProperty("org.orcid.web.base.url"))) {
        baseUrl = System.getProperty("org.orcid.web.base.url");
    }

    WebDriver webDriver = new FirefoxDriver();

    int timeout = 4;
    webDriver.get(baseUrl + "/userStatus.json?logUserOut=true");
    webDriver.get(baseUrl + "/my-orcid");
    SigninTest.signIn(webDriver, userName, password);

    // Switch to accounts settings page
    By accountSettingsMenuLink = By.id("accountSettingMenuLink");
    (new WebDriverWait(webDriver, timeout))
            .until(ExpectedConditions.presenceOfElementLocated(accountSettingsMenuLink));
    WebElement menuItem = webDriver.findElement(accountSettingsMenuLink);
    menuItem.click();

    try {
        boolean lookAgain = false;
        do {
            // Look for each revoke app button
            By revokeAppBtn = By.id("revokeAppBtn");
            (new WebDriverWait(webDriver, timeout))
                    .until(ExpectedConditions.presenceOfElementLocated(revokeAppBtn));
            List<WebElement> appsToRevoke = webDriver.findElements(revokeAppBtn);
            boolean elementFound = false;
            // Iterate on them and delete the ones created by the specified
            // client id
            for (WebElement appElement : appsToRevoke) {
                String nameAttribute = appElement.getAttribute("name");
                if (clientIds.contains(nameAttribute)) {
                    appElement.click();
                    Thread.sleep(1000);
                    // Wait for the revoke button
                    By confirmRevokeAppBtn = By.id("confirmRevokeAppBtn");
                    (new WebDriverWait(webDriver, timeout))
                            .until(ExpectedConditions.presenceOfElementLocated(confirmRevokeAppBtn));
                    WebElement trash = webDriver.findElement(confirmRevokeAppBtn);
                    trash.click();
                    Thread.sleep(2000);
                    elementFound = true;
                    break;
                }
            }

            if (elementFound) {
                lookAgain = true;
            } else {
                lookAgain = false;
            }
        } while (lookAgain);

    } catch (Exception e) {
        // If it fail is because it couldnt find any other application
    } finally {
        webDriver.get(baseUrl + "/userStatus.json?logUserOut=true");
        webDriver.quit();
    }
}

From source file:org.orcid.integration.blackbox.api.v2.rc2.BlackBoxBase.java

License:Open Source License

public static void revokeApplicationsAccess(String... clientIdsParam) {
    // Nothing to remove
    if (clientIdsParam == null) {
        return;/*from  w w  w  .jav  a  2 s  .  c  o m*/
    }
    List<String> clientIds = new ArrayList<String>();
    for (String clientId : clientIdsParam) {
        if (!PojoUtil.isEmpty(clientId)) {
            clientIds.add(clientId);
        }
    }

    String userName = System.getProperty("org.orcid.web.testUser1.username");
    String password = System.getProperty("org.orcid.web.testUser1.password");
    String baseUrl = "https://localhost:8443/orcid-web";
    if (!PojoUtil.isEmpty(System.getProperty("org.orcid.web.base.url"))) {
        baseUrl = System.getProperty("org.orcid.web.base.url");
    }

    WebDriver webDriver = new FirefoxDriver();

    int timeout = 4;
    webDriver.get(baseUrl + "/userStatus.json?logUserOut=true");
    webDriver.get(baseUrl + "/my-orcid");
    SigninTest.signIn(webDriver, userName, password);

    // Switch to accounts settings page
    By accountSettingsMenuLink = By.id("accountSettingMenuLink");
    (new WebDriverWait(webDriver, timeout))
            .until(ExpectedConditions.presenceOfElementLocated(accountSettingsMenuLink));
    WebElement menuItem = webDriver.findElement(accountSettingsMenuLink);
    menuItem.click();

    try {

        boolean lookAgain = false;

        do {
            // Look for each revoke app button
            By revokeAppBtn = By.id("revokeAppBtn");
            (new WebDriverWait(webDriver, timeout))
                    .until(ExpectedConditions.presenceOfElementLocated(revokeAppBtn));
            List<WebElement> appsToRevoke = webDriver.findElements(revokeAppBtn);
            boolean elementFound = false;
            // Iterate on them and delete the ones created by the specified
            // client id
            for (WebElement appElement : appsToRevoke) {
                String nameAttribute = appElement.getAttribute("name");
                if (clientIds.contains(nameAttribute)) {
                    appElement.click();
                    Thread.sleep(1000);
                    // Wait for the revoke button
                    By confirmRevokeAppBtn = By.id("confirmRevokeAppBtn");
                    (new WebDriverWait(webDriver, timeout))
                            .until(ExpectedConditions.presenceOfElementLocated(confirmRevokeAppBtn));
                    WebElement trash = webDriver.findElement(confirmRevokeAppBtn);
                    trash.click();
                    Thread.sleep(2000);
                    elementFound = true;
                    break;
                }
            }

            if (elementFound) {
                lookAgain = true;
            } else {
                lookAgain = false;
            }

        } while (lookAgain);

    } catch (Exception e) {
        // If it fail is because it couldnt find any other application
    } finally {
        webDriver.get(baseUrl + "/userStatus.json?logUserOut=true");
        webDriver.quit();
    }
}

From source file:org.orcid.integration.blackbox.BlackBoxBase.java

License:Open Source License

public static void revokeApplicationsAccess(String... clientIdsParam) {
    // Nothing to remove
    if (clientIdsParam == null) {
        return;//from  w  w w .j a  v  a  2s .c  o m
    }
    List<String> clientIds = new ArrayList<String>();
    for (String clientId : clientIdsParam) {
        if (!PojoUtil.isEmpty(clientId)) {
            clientIds.add(clientId);
        }
    }

    String userName = System.getProperty("org.orcid.web.testUser1.username");
    String password = System.getProperty("org.orcid.web.testUser1.password");
    String baseUrl = "http://localhost:8080/orcid-web";
    if (!PojoUtil.isEmpty(System.getProperty("org.orcid.web.base.url"))) {
        baseUrl = System.getProperty("org.orcid.web.base.url");
    }

    WebDriver webDriver = new FirefoxDriver();

    int timeout = 4;
    webDriver.get(baseUrl + "/userStatus.json?logUserOut=true");
    webDriver.get(baseUrl + "/my-orcid");
    SigninTest.signIn(webDriver, userName, password);

    // Switch to accounts settings page
    By accountSettingsMenuLink = By.id("accountSettingMenuLink");
    (new WebDriverWait(webDriver, timeout))
            .until(ExpectedConditions.presenceOfElementLocated(accountSettingsMenuLink));
    WebElement menuItem = webDriver.findElement(accountSettingsMenuLink);
    menuItem.click();

    try {

        boolean lookAgain = false;

        do {
            // Look for each revoke app button
            By revokeAppBtn = By.id("revokeAppBtn");
            (new WebDriverWait(webDriver, timeout))
                    .until(ExpectedConditions.presenceOfElementLocated(revokeAppBtn));
            List<WebElement> appsToRevoke = webDriver.findElements(revokeAppBtn);
            boolean elementFound = false;
            // Iterate on them and delete the ones created by the specified
            // client id
            for (WebElement appElement : appsToRevoke) {
                String nameAttribute = appElement.getAttribute("name");
                if (clientIds.contains(nameAttribute)) {
                    appElement.click();
                    Thread.sleep(1000);
                    // Wait for the revoke button
                    By confirmRevokeAppBtn = By.id("confirmRevokeAppBtn");
                    (new WebDriverWait(webDriver, timeout))
                            .until(ExpectedConditions.presenceOfElementLocated(confirmRevokeAppBtn));
                    WebElement trash = webDriver.findElement(confirmRevokeAppBtn);
                    trash.click();
                    Thread.sleep(2000);
                    elementFound = true;
                    break;
                }
            }

            if (elementFound) {
                lookAgain = true;
            } else {
                lookAgain = false;
            }

        } while (lookAgain);

    } catch (Exception e) {
        // If it fail is because it couldnt find any other application
    } finally {
        webDriver.get(baseUrl + "/userStatus.json?logUserOut=true");
        webDriver.quit();
    }
}

From source file:org.polimi.zarathustra.webdriver.WebdriverWorker.java

License:Open Source License

private String getPage(String url, WebDriver driver) {
    driver.get(url);
    String pageSource = driver.getPageSource();
    return pageSource;
}

From source file:org.qe4j.web.OpenWebDriverTest.java

License:Open Source License

@Test
public void findElement() throws IOException {
    Properties properties = getProperties();
    WebDriver driver = new OpenWebDriver(properties);
    driver.get(URL);
    WebElement div = driver.findElement(By.id("html1"));
    Assert.assertEquals(div.getTagName(), "div", "find element");
}

From source file:org.qe4j.web.OpenWebDriverTest.java

License:Open Source License

@Test
public void findElements() throws IOException {
    Properties properties = getProperties();
    WebDriver driver = new OpenWebDriver(properties);
    driver.get(URL);
    List<WebElement> fields = driver.findElements(By.tagName("div"));
    Assert.assertEquals(fields.size(), 2, "found multiple divs");
}

From source file:org.qe4j.web.OpenWebDriverTest.java

License:Open Source License

@Test
public void get() throws IOException {
    Properties properties = getProperties();
    WebDriver driver = new OpenWebDriver(properties);
    driver.get(URL);
}

From source file:org.qe4j.web.OpenWebDriverTest.java

License:Open Source License

@Test
public void getCurrentUrl() throws IOException {
    Properties properties = getProperties();
    WebDriver driver = new OpenWebDriver(properties);
    driver.get(URL);
    Assert.assertEquals(driver.getCurrentUrl(), URL, "current url");
}

From source file:org.qe4j.web.OpenWebDriverTest.java

License:Open Source License

@Test
public void getPageSource() throws IOException {
    Properties properties = getProperties();
    WebDriver driver = new OpenWebDriver(properties);
    driver.get(URL);
    Assert.assertTrue(driver.getPageSource().contains("</div>"), "page source");
}

From source file:org.qe4j.web.OpenWebDriverTest.java

License:Open Source License

@Test
public void getTitle() throws IOException {
    Properties properties = getProperties();
    WebDriver driver = new OpenWebDriver(properties);
    driver.get(URL);
    Assert.assertEquals(driver.getTitle(), URL_TITLE, "title");
}