Thursday, November 9, 2017

How to convert Selenium IDE tests into Java and other languages

By default, Selenium IDE tests are recorded as HTML format. This HTML test script can be converted to Selenium WebDriver test script in various supported programming languages such as Java, C#, Ruby, Python, Perl, PHP etc.

There are 2 ways to convert a recorded tests in Selenium IDE into Java code:

1st way: To see the Java code directly in Selenium IDE

1. Open Selenium IDE -> Record a test
2. Go to Options menu -> Options...
3. At "Selenium IDE Options" window: Check the check box for "Enable experimental features" and click OK button
4. Options -> Format -> Java / TestNG / WebDriver
5. Click OK button from "JavaScript Application" pop up -> You will see the desired Java source code for your recorded tests

2nd way: By exporting recorded test case(HTML format) into java file:

1. Record your tests in HTML format by using Selenium IDE
2. File menu -> Export Test Case As -> Java / TestNG / WebDriver
3. Save the file (it would be saved as .java)
4. Open the java file you saved in any text editor or IDE such as, Notepad++, Notepad, Wordpad, Eclipse, IntelliJ IDEA etc. (You can see the expected Java Selenium source code)

There is another way to convert Selenium IDE command individually to any language. The following steps for java:

1. Open Firefox -> Open Selenium IDE
2. Record some steps of your test
3. In Selenium IDE: Go to Options | Clipboard Format and select Java / TestNG / WebDriver
4. Right click any command in Selenium IDE you recorded -> Click Copy
5. Paste in any editor (such as NotePad, Wordpad etc. OR any IDE you are using such as eclipse, IntelliJ IDEA)
6. The command will be pasted as Java format

Note: In similar way you can convert individual Selenium IDE command to C#, Python and many more you want.

No comments:

Post a Comment