Write Your first Automation Script Using Selenium

From Previous Blog, we have learnt how to setup your machine for Selenium Script. Now we will work on Eclipse for writing our First Selenium Script

Steps :

  1. Open Eclipse
  2. Go to File Menu—> New—> Java Project

Eclipse3

3. Enter Project Name as “First_selenium_project” and select Finish Option to save project

Eclipse4

4. After Project is saved, we first need to create Class. To create class go to Project Folder

“First_selenium_project”—>src—>right click—>create class

Class2.png

5. Once class is created, Eclipse will look like this

Class3.png

6. After this,we need to import JAR Files to our Project. For this, go to

Project—>Select Properties Option—>Select Java Build Path—>Libraries Tab—>Click Add External JARs

JARs

7. After clicking on “Add External JARs” select Selenium Java Client Driver and add all JAR Files indise and outside “libs” folder. Click OK to save the changes

JARs2.png

 

8.Now you are ready to write your first Code

Copy paste the below  Code and save it and execute it by selecting “Run” option

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.firefox.FirefoxDriver;

public class Main_class

{

public static void main(String[] args)

{

WebDriver driver = new FirefoxDriver();

driver.get(“http://google.com”);

System.out.println(driver.getTitle());

driver.close();

}

}

 

Happy Coding Guys 🙂

Standard

Leave a comment