How to launch & work with chrome browser using Selenium

Download Chromedriver.exe file.

package webapp;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class ChromeBRLaunch {

public static void main(String[] args) {

System.setProperty(“webdriver.chrome.driver”, “C:\\Users\\pushvas\\Downloads\\selenium 3.0\\chromedriver_win32\\chromedriver.exe”);

WebDriver driver=new ChromeDriver();

// seleniumsuite site
driver.get(“http://www.seleniumsuite.wordpress.com”);

// Maximize browser

driver.manage().window().maximize();

}

}

========================= Way : 2 ==========================================

package webapp;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;

public class IeBRLaunch {

public static void main(String[] args) {

System.setProperty(“webdriver.ie.driver”, “C:\\Users\\Youtility\\Downloads\\selenium 3.0\\IEDriverServer_Win32_3.0.0\\IEDriverServer.exe”);

WebDriver driver=new InternetExplorerDriver();

// seleniumsuite site
driver.navigate().to(“http://www.seleniumsuite.wordpress.com”);

// Maximize browser
driver.manage().window().maximize();

driver.navigate().to(“http://www.seleniumsuite.wordpress.com”);

}

}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s