Introduction – In this blog post, we will see how to run first test in selenium and what are necessary configuration required for invoking browser.

There are 2 basic configuration to invoke a browser.

First step, download and configure selenium standalone jar.

Visit -https://www.seleniumhq.org/download/ , Refer below screenshot.

Config the downloaded jar file in eclipse project-

Second step – Download ChromeDriver, Download location- http://chromedriver.chromium.org/downloads.

Click on ChromeDriver 2.43, Refer below image

download and unzip it,

Now, Open Selenium project and create a class, select main class radio button like below-

Write below code in and execute the same –

package TestNG_Classes;

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

public class Selenium_FirstStep {

/**
* @param args
*/
public static void main(String[] args)
{
// TODO Auto-generated method stub
WebDriver driver ;

// Config step-Setting up chrome driver path
String exePath = "E:\\chromedriver_win32\\chromedriver.exe";
System.setProperty("webdriver.chrome.driver", exePath);

//Creating chrome driver object
driver=new ChromeDriver();

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

//Opening URL
driver.get("http://www.facebook.com/");

}

}

Summary– Above configuration will setup initial selenium configuration which will help user to use all selenium commands and launch chrome browser.

Similarly firefox and Internet explorer browser can be launched. for launching them their browser exe needs to be downloaded like we did for chrome.

Firefox(Geecko) and Internet explorer, download location-https://www.seleniumhq.org/download/
Please refer below code for setting up IE and Firefoxdriver

Use below code in (chrome browser launch code above) Config step-Setting up chrome driver path inabove sample code for launching chrome, if IE or Firefox execution is required.

//For launching Firefox browser
System.setProperty("webdriver.gecko.driver","path of geckodriver.exe");
WebDriver driver = new FirefoxDriver();

//For launching IE
System.setProperty("webdriver.ie.driver", "D://Seleniumdriver\\IEDriverServer.exe")
//Initialize InternetExplorerDriver Instance.

WebDriver driver = new InternetExplorerDriver();

Few Questions/With answers-

What is a selenium webdriver

Answers- Selenium webdriver is an Interface, using WebDriver object, selenium interface helps in accessing selenium API’s

Which language is supported by Selenium or in how many langauges we can write selenium scripts

Answer- It supported following languages-

1- Java
2- C#
3- Python
4- Perl
5- Javascript

In Next post we will see the next step of selenium learning, on how to enter values in text box and click a button.