Tuesday, July 11, 2017

First Selenium Webdriver Script Using Chrome Driver

In this tutorial, I will give a small explanation about the Chrome Web Driver, Through which we will load the webpage in chrome browser.

Before starting with programming you need to download the chrome driver. Driver file you will get it from the selenium official website ( http://www.seleniumhq.org/ ).

Following source code is use to launch the browser page using chrome driver.


package demo;

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

public class SeleniumDemo {

 // variable name
 public static WebDriver driver;

 public static void main(String[] args) {
  // TODO Auto-generated method stub

  System.out.println("Launching the chrome driver  ");
  // Set the chrome driver exe file path
  // Instantiate the chrome driver
  driver = new ChromeDriver();
  // set the browser URL in get() to load the webpage



To run and execute the code in Eclipse IDE, you need to follow the below step:

  • On Eclipse's menu bar, click Run > Run.

Eclipse IDE Console Tab :

Then it will launch the chrome browser and load the page.

Let us know if you have any suggestion and query.

No comments:

Post a Comment