If you have missed the previous post then you can have a look at here .
Now we are ready to start our first script in Webdriver using Eclipse .Open your Eclipse and follow the below steps
1.Create new Java Project
2.Add the Webdriver Jar files to the created Project
3.Create a new Package under Java Project
4.Create a Java class file under the Package
5.Write the code in the Java class file and run it.
1. Create a new Java project
Goto File >> New >>Java Project
We will get a popup which will prompt us to provide the project name.
Give the project name say "ExploreWebDriver" then click on Finish button.
2.Add the Webdriver Jar files to the created Project
Right click on created project then goto
Build Path>>Configure Build Path >>Select Libraries tab>>Add External jars
Which will open a folder search prompt , goto the locations where you have downloaded WebDriver jar files and add them .Then click on "Ok" button
You need to add below jar files.If you don't have these files downloaded on your computer then you can download them from the below pages :
http://seleniumhq.org/download/
http://code.google.com/p/selenium/downloads/list
You can also download all jars from my shared location
https://docs.google.com/folder/d/0B00rtzEfza2uZnRBZnNVWHFVNjA/edit
3.Create a new Package under Java Project
Goto creatd project i.e. "ExploreWebDriver" and expand it.Now we will see a separate folder named "src". Right Click on it and then Goto
New>>Package>>Give the name of package in the "package creation" popup. Say "learning" is the name of the Package.Now click on finish button.
Copy the below code and paste it in the created Java class file.
Here is how your Eclipse project hierarchy looks like :
Now we are ready to start our first script in Webdriver using Eclipse .Open your Eclipse and follow the below steps
1.Create new Java Project
2.Add the Webdriver Jar files to the created Project
3.Create a new Package under Java Project
4.Create a Java class file under the Package
5.Write the code in the Java class file and run it.
1. Create a new Java project
Goto File >> New >>Java Project
We will get a popup which will prompt us to provide the project name.
Give the project name say "ExploreWebDriver" then click on Finish button.
2.Add the Webdriver Jar files to the created Project
Right click on created project then goto
Build Path>>Configure Build Path >>Select Libraries tab>>Add External jars
Which will open a folder search prompt , goto the locations where you have downloaded WebDriver jar files and add them .Then click on "Ok" button
You need to add below jar files.If you don't have these files downloaded on your computer then you can download them from the below pages :
http://seleniumhq.org/download/
http://code.google.com/p/selenium/downloads/list
You can also download all jars from my shared location
https://docs.google.com/folder/d/0B00rtzEfza2uZnRBZnNVWHFVNjA/edit
- a.selenium-java-2.32.0-srcs.jar
- b.selenium-java-2.32.0.jar
- c.selenium-server-standalone-2.32.0.jar
3.Create a new Package under Java Project
Goto creatd project i.e. "ExploreWebDriver" and expand it.Now we will see a separate folder named "src". Right Click on it and then Goto
New>>Package>>Give the name of package in the "package creation" popup. Say "learning" is the name of the Package.Now click on finish button.
4.Create a Java class file under the Package
Right click on the created package i.e "Learing" and then goto
New>>Class>>we will get "New Java Class" popup. Enter the name of the class say "GoogleSearch" and click on Finish.
5.Write the code in the Java class file and run it.
Copy the below code and paste it in the created Java class file.
- package learning;
- import org.openqa.selenium.WebDriver;
- import org.openqa.selenium.firefox.FirefoxDriver;
- public class GoogleSearch {
- public static void main(String args[]){
- WebDriver driver=new FirefoxDriver();
- System.out.println("Loading Google search page");
- driver.get("http://google.com");
- System.out.println("Google search page loaded fine");
- }
- }
Here is how your Eclipse project hierarchy looks like :
Now Click run .
Script will run successfully and a new firefox window will be opened with the Google.com .
No comments:
Post a Comment