Wednesday 6 May 2015

Selenium webdriver API using Eclipse



To start selenium web driver API scripting with Eclipse editor, make sure you have to install Java on your system.

You can get the java information in Eclipse from Window->Preferences options, if java is installed and configured successfully on Eclipse or not.

You can also check the java version from command prompt(cmd), by entering ‘java -version' which will display the java version installed on your machine.

Now we will start creating our first program in selenium using java from ADT/Spring Eclipse Editor
1. Create New Java Project
(From Top Menu file->New->Project/Java Project and enter the project name)
2. Create a new Package under Project
(Give any name to the package)
3. Create a new Java class file under the Package
(Give a name to the class)
4. Next add the selenium server Jar files to the Project. Download Selenium Server
(Right click on the Project Name, Mouse over on Build Path and select 'Configure Build Path', Select Libraries tab, Click on Add External Jars and select the selenium server jar from your local machine)
5. Write your first test script in the Java and execute it.
Please find the below example program to open below site in Firefox browser

import org.openqa.selenium.WebDriver;  
import org.openqa.selenium.firefox.FirefoxDriver;  
public class openselenumnBlog {  
public static void main(String args[]){  
   WebDriver driver=new FirefoxDriver();  
   System.out.println("Hello Automation Tester...");  
   driver.get("http://silenumnmisc.blogspot.com");    
   }  
    } 

No comments:

Post a Comment