selenium-webdriver

Using Selenium Webdriver with Java

Introduction#

Selenium webdriver is web automation framework which allows you to test your web application against different web browsers. Unlike Selenium IDE, webdriver allows you to develop your own test cases in programming language of your choice. It supports Java, .Net, PHP, Python, Perl, Ruby.

Opening browser window with specific URL using Selenium Webdriver in Java

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

class test_webdriver{
    public static void main(String[] args) {
       WebDriver driver = new FirefoxDriver();
       driver.get("https://stackoverflow.com/");
       driver.close();
    }
}

Opening a browser window with to() method

Opening a browser with to() method.

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
class navigateWithTo{
    public static void main(String[] args) {
       WebDriver driver = new FirefoxDriver();
       driver.navigate().to("https://www.example.com");
       driver.close();
    }
}

This modified text is an extract of the original Stack Overflow Documentation created by the contributors and released under CC BY-SA 3.0 This website is not affiliated with Stack Overflow