Export Selenium Test from IDE to Eclipse|
First Selenium WebDriver Program in Java | Eclipse, WebDriver, JUnit 4
By the end of WebDriver Tutorial you will be able to write
your first Selenium WebDriver Script in Java. We will export the Selenium IDE
recorded script and can use it with any other IDE like Eclipse.
Now, record the sequence you want to automate using Selenium IDE.
To learn more about how Record | Play
and Modify script in Selenium IDE please read my post 'Record | Play | Modify script in Selenium IDE'.
Export Test case from
Selenium IDE to Eclipse in Java and JUnit:
I have used login sequence to Gmail as an example in this post.
I have used login sequence to Gmail as an example in this post.
- Now once you have recorded the steps/sequence, you will
observe few Commands with their Targets/ Values in Selenium IDE Table Tab.
- From Menu click on File
> Export Test Case As… > select
Java/ JUnit 4 / WebDriver
- Save that file as .java
Import script in
Eclipse: (Eclipse| WebDriver | JUnit 4)
If you don't have your Eclipse environment ready then please
refer my post 'Configure Selenium WebDriver, Java and Eclipse'
- Launch eclipse.
- Right click on ‘Project
name’ > Select ‘Import’
- Select ‘File System’
and click ‘Next’
- ‘From directory’
> click on ‘Browse’ and provide
the location of the saved script .java file.
- Into Folder >
click on ‘Browse’ and select ‘src’ folder of the project.
- Click Finish.
Fix Errors and Warnings in script:
Fix Error:
- After importing the .java file you will see an error appearing in the code at 1st line. (as com.example.tests package doesn't exists)
- Mouse over the error or click on ‘x’ icon in 'red' > it will open suggestion to fix it.
- Select option to move the *.java to the given package. (You can select other option too)
Fix Warnings:
- Mouse over on the warnings or click on Warning icons > it will open suggestion to fix unused imports, methods and values.
Finally code will look like this: (Eclipse| WebDriver | JUnit 4)
Hello Shivraj ,
ReplyDeleteThe Article on Export Selenium Test from IDE to Eclipse is nice. It give detail information about it .Thanks for Sharing the information Selenium Web Driver. Software Testing Company