1

I recorded a script using Selenium IDE and exported it in Java. Now when I want to run it on webDriver, a pop-up box is displayed-

enter image description here

when I select an option and click on ok "Build failed" message is displayed. I do not have any idea how to resolve this as I am a beginner in selenium.

2
  • The title of this post is misleading. The problem you're talking about is how to run a script, not how to perform a script conversion.
    – User253489
    Commented Jul 1, 2017 at 18:57
  • 1
    Made a title that reflects the contents better Commented Jul 21, 2017 at 9:57

2 Answers 2

1

In Eclipse you need to get the junit.jar and add it to your build path (if you exported using the junit option). To add it to the buildpath:

  1. Create a 'lib' folder in your project
  2. Copy the .jar file into the lib folder
  3. Right-click the .jar and select "Add to Build Path"

You should then be able to run as a JUnit test.

1

A solution for how to run a WebDriver Java script in E̲c̲l̲i̲p̲s̲e̲ ̲N̲e̲o̲n̲.̲3 that's exported from a S̲e̲l̲e̲n̲i̲u̲m̲ ̲I̲D̲E̲ ̲2̲.̲9̲.̲1 test case is provided below. This approach covers all 3 options for creating such a script from a test case with this Selenium IDE version; the 3 choices are as follows:

Option 1: Java / JUnit 4 / WebDriver

Option 2: Java / TestNG / WebDriver

Option 3: Java / JUnit 4 / WebDriver Backed

enter image description here

Here's the solution:

1. Ensure you have F̲i̲r̲e̲f̲o̲x̲ ̲4̲7̲.̲0̲.̲1 installed on your machine.

2. In Eclipse:

a. Under File, select New > Java Project.

enter image description here

b. Enter a project name in the Project name: text box, then click the Next > button.

enter image description here

c. Click the Libraries tab.

enter image description here

d. Add the following to the build path of your project:
-Each JAR that's in t̲h̲i̲s̲ ̲f̲i̲l̲e̲
-T̲h̲i̲s̲ ̲f̲i̲l̲e̲ (if Option 3 was used)

To add JARs to this path, click the Add External JARs... button, then (in the JAR Selection window that pops up as a result) select the JARs and click the Open button.

enter image description here

enter image description here

e. Click the Finish button.

enter image description here

You're now done creating a Java project.

f. Expand the Java project by clicking the plus symbol that's beside it in the Package Explorer pane (in this pane, every entry with a plus sign next to it can be expanded through that sign being clicked).

enter image description here

g. Right click the src folder that appears below the project, then select New > Package.

enter image description here

h. Enter a package name in the Name: text box, then click the Finish button.

enter image description here

You're now done creating a package that's in the src folder.

i. In the Package Explorer pane, right click the package you just created. Select New > Class.

enter image description here

j. In the Name: text box, enter the name (excluding the .java extension) of the .java file that was created as a result of exporting the Selenium IDE test case in question, then click the Finish button.

enter image description here

You're now done creating a class that's in the package.

k. Copy all the lines (except for the first two) of the aforementioned .java file that was generated with Selenium IDE. Paste them over lines 3-6 of the class file you finished creating during Step j (let's call this file x).

l. Save x.

m. If Option 2 was used and TestNG is not installed in Eclipse, carry out the following instructions:

-Select Help > Install New Software...

enter image description here

-In the resulting Install window, click the Add... button.

enter image description here

-In the Add Repository window that pops up, enter a name in the Name: text box and http://beust.com/eclipse/ in the Location: text box, then click the OK button.

enter image description here

-In the Install window, check the TestNG checkbox in the list of available software then click Next > twice.

enter image description here

enter image description here

-Select I accept the terms of the license agreement then click the Finish button.

enter image description here

(TestNG will now be installed)

-In case you get a security warning, click the OK button.

enter image description here

-Once the installation is complete, click Yes in the Software Updates window.

enter image description here

(Eclipse will now restart)

n. To run the WebDriver script, right click x in the Package Explorer pane, then hover over Run As, then click:

-JUnit Test for Options 1 and 3

enter image description here

-TestNG Test for Option 2

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.