To start selenium scripting with Eclipse, you need to first install Java Development Kit (JDK) Download and Install Java
Installing eclipse is very easy, First download eclipse . The downloaded file should be a .zip file. Place it in a folder and ensure that you have full read and write permissions. Try to create a shortcut of the eclipse executable file.
You can check in Eclipse from Window->Preferences options, if java is installed and configured successfully on Eclipse. You can also check the java version from command prompt, enter '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 Eclipse Editor
Now we will start creating our first program in selenium using java from Eclipse Editor
1.Create new Java Project
[From top menu file->New->Project/Java Project and enter the project name]
[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]
[Give any name to the package]
3.Create a new Java class file under the Package
[Give a name to the class]
[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]
[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 the script in the Java and execute it.
Please find the below example program to open Google in Firefox browser
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class OpenGoogle {
public static void main(String args[]){
WebDriver driver=new FirefoxDriver();
System.out.println("Hello Google...");
driver.get("http://google.com");
}
}
Comments
Post a Comment