How to convert commands recorded in selenium IDE to Java?

前端 未结 5 2250
遇见更好的自我
遇见更好的自我 2020-12-05 03:00

Is there any application or simple way to convert all the commands recorded by Selenium IDE to Java (Selenium WebDriver)? It would be a lot more ea

5条回答
  •  南方客
    南方客 (楼主)
    2020-12-05 03:08

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

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

    1. Go to Options -> Options...
    2. At "Selenium IDE Options" window: Check the check box for "Enable experimental features" and click OK button
    3. Options -> Format -> Java / JUnit4 / WebDriver
    4. 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 -> Export Test Case As -> Java / JUnit4/ 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.

提交回复
热议问题