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:UnitTest1.java

@Test
public void hello() {

    String exePath = "C:\\Unit Testing\\Drivers\\chromedriver.exe";
    System.setProperty("webdriver.chrome.driver", exePath);
    WebDriver driver = new ChromeDriver();
    driver.get("http://www.store.demoqa.com");
    System.out.println("Successfully opened the website www.Store.Demoqa.com");
    driver.quit();//  w  w  w.  j  a  v a2s  . c  om

}

From source file:UnitTest1.java

@Test
public void comparisonfbTitle() throws InterruptedException {
    String exePath = "C:\\Unit Testing\\Drivers\\chromedriver.exe";
    System.setProperty("webdriver.chrome.driver", exePath);
    WebDriver driver = new ChromeDriver();

    driver.get("https://www.facebook.com");

    String actualTitle = driver.getTitle();

    assertEquals("Facebook - Log In or Sign Up", actualTitle);

    Thread.sleep(5);/*from w  w w  . j  a v  a2 s .  co m*/
    driver.quit();

}

From source file:UnitTest1.java

@Test
public void comparisonFBloginButton() throws InterruptedException {
    String exePath = "C:\\Unit Testing\\Drivers\\chromedriver.exe";
    System.setProperty("webdriver.chrome.driver", exePath);
    WebDriver driver = new ChromeDriver();

    driver.get("https://www.facebook.com");

    String actualTitle = "u_0_o";

    WebElement test = driver.findElement(By.id("u_0_o"));
    assertEquals(actualTitle, test.getAttribute("id"));
    Thread.sleep(5);//w  ww .ja  va 2 s. c o  m
    driver.quit();

}

From source file:FirefoxDriverDemo.java

public static void main(String[] args) {
    String baseURL = "http://www.google.com";
    WebDriver driver = new FirefoxDriver();
    System.setProperty("webdriver.gecko.driver", "/Users/srijana/Documents/seleniumpractise notes/geckodriver");

    driver.get(baseURL);
}

From source file:GeneralCookieDriver.java

License:Open Source License

public Integer conductTest(Browser browser, boolean privateBrowsing, int[] cookies, int numTrialsPerRun) {
    WebDriver driver = getWebDriver(browser, privateBrowsing);

    if (driver == null) {
        System.err.println("WebDriver could not be found for " + browser + " in "
                + (privateBrowsing ? "private" : "normal") + " mode.");
        return 0;
    }/*from   www .j  a v  a2  s .  c  o m*/

    if (browser.equals(Browser.SAFARI) && privateBrowsing) {
        System.err.println("Pausing for 10 seconds...");
        try {
            Thread.sleep(10000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.err.println("Resuming from pause...");
    }

    for (int c = 0; c < cookies.length; c++) {

        for (int i = 0; i < numTrialsPerRun; i++) {

            driver.get(new String(cookieGeneratorLocation + "?numCookies=" + cookies[c] + "&browser="
                    + browser.toString() + "&mode=" + (privateBrowsing ? "private" : "normal")));

            try {
                new WebDriverWait(driver, 120).until(ExpectedConditions.titleContains("[ResultProvided]"));

            } catch (org.openqa.selenium.UnhandledAlertException e) {
                System.err.println("UnhandledAlertException");
                continue;
            } catch (Exception e) {
                e.printStackTrace();
                continue;
            }

            Integer result = new Integer(driver.getTitle().split(" ")[0]);

            System.out.println(
                    browser.toString() + (privateBrowsing ? ",P," : ",N,") + cookies[c] + "," + result);
        }
    }

    //Close the browser
    driver.quit();

    return 0;
}

From source file:TestWriteanArticle.java

@org.junit.Test
public void positive() throws InterruptedException {
    System.setProperty("webdriver.gecko.driver", "C://Users/Mari/Downloads/geckodriver.exe");
    WebDriver webDriver = new FirefoxDriver();
    String page = "http://www.wikihow.com/Special:CreatePage";
    webDriver.get(page);
    WebElement title = webDriver.findElement(By.id("cp_title_input"));
    title.sendKeys("how to use selenium");
    webDriver.findElement(By.id("cp_title_btn")).click();
    Thread.sleep(10);//ww w  . j av  a 2s.  c  o m

    WebDriverWait wait = new WebDriverWait(webDriver, 50);
    wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("cpr_title_hdr")));
    assertTrue(webDriver.getPageSource().contains("Are any of these topics the same as yours?"));

    webDriver.close();
}

From source file:TestWriteanArticle.java

@org.junit.Test
public void negative() throws InterruptedException {
    System.setProperty("webdriver.gecko.driver", "C://Users/Mari/Downloads/geckodriver.exe");
    WebDriver webDriver = new FirefoxDriver();
    String page = "http://www.wikihow.com/Special:CreatePage";
    webDriver.get(page);
    WebElement title = webDriver.findElement(By.id("cp_title_input"));
    title.sendKeys("how to use wikiHow");
    webDriver.findElement(By.id("cp_title_btn")).click();
    Thread.sleep(10);//from w  w  w  . jav  a 2  s.  c  o m

    WebDriverWait wait = new WebDriverWait(webDriver, 50);
    wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("cpr_title_hdr")));
    assertTrue(webDriver.getPageSource().contains("That article already exists!"));

    webDriver.close();
}

From source file:FindByLinkText.java

public static void main(String[] args) throws Exception {
    String baseURL = "http://demostore.x-cart.com/";
    System.setProperty("webdriver.gecko.driver",
            "/Users/srijana/Documents/seleniumpractise notes/geckodriver 2");
    WebDriver driver = new FirefoxDriver();

    driver.get(baseURL);

    //driver.findElement(By.xpath(".//*[@id='header-area']/div[1]/div/div[4]/div/ul/li[4]/a/span")).click();

    //driver.findElement(By.xpath(".//*[@id='header-area']/div[1]/div/div[4]/div/ul/li[7]/a/span")).click();

    driver.findElement(By.tagName("a")).click();

}

From source file:NewSeleneseIT.java

@Test
public void testSimple() throws Exception {
    // Create a new instance of the Firefox driver
    // Notice that the remainder of the code relies on the interface, 
    // not the implementation.
    System.setProperty("webdriver.gecko.driver", "/home/klaudia/geckodriver");
    WebDriver driver = new FirefoxDriver();

    // And now use this to visit NetBeans
    driver.get("http://www.netbeans.org");
    // Alternatively the same thing can be done like this
    // driver.navigate().to("http://www.netbeans.org");

    // Check the title of the page
    // Wait for the page to load, timeout after 10 seconds
    (new WebDriverWait(driver, 10)).until(new ExpectedCondition<Boolean>() {
        @Override/*w w  w .  j a  va  2  s  .  c  o m*/
        public Boolean apply(WebDriver d) {
            return d.getTitle().contains("NetBeans");
        }
    });

    //Close the browser
    driver.quit();
}

From source file:IdXPATHDemo.java

public static void main(String[] args) {
    String baseURL = "http://www.google.com";
    System.setProperty("webdriver.gecko.driver",
            "/Users/srijana/Documents/seleniumpractise notes/geckodriver 2");
    WebDriver driver = new FirefoxDriver();

    driver.get(baseURL);

    driver.findElement(By.id("lst-ib")).sendKeys("letskodeit");
    driver.findElement(By.xpath("//*[@id='sblsbb']/button")).click();
}