Creating a Selenium Virtual User Script from a Selenium IDE Recording

Selenium IDE is a Firefox extension that provides an IDE for Selenium. It allows you to record and playback Selenium scripts, and to export the recorded scripts as Java JUnit 4 WebDriver scripts. It is then a simple matter to convert the JUnit java code into an Eggplant Performance Selenium script. The instructions below will guide you through the process of installing Selenium IDE, recording a simple script, and then converting that script into an Eggplant Performance Selenium script.

  1. Launch the Firefox browser and then navigate to http://docs.seleniumhq.org/download/.
  2. Click to download the latest version of Selenium IDE:
  3.  

  4. Click Allow to allow the Selenium IDE to be installed.
  5. Click Restart Now to restart Firefox .
  6. Launch the Selenium IDE by navigating to Web Developer > Selenium IDE
  7. When Selenium IDE starts, it automatically begins recording your actions within Firefox. The example below shows a recording where we navigated to https://www.google.co.uk/ and entered a search for "testplant":

     

  8. To convert the Selenium recording into a Java JUnit test case, go to File > Export Test Case As > Java / JUnit 4 / WebDriver:

     

  9. Choose a location to save the java source code file. The java code can then be copied and pasted into an Eggplant Performance Selenium script with only very minor changes. For example, the JUnit test case for our simple Google search looks like this:

    import org.openqa.selenium.By;

    ...

    @Test

    public void testGoogleSearch() throws Exception

    {

    driver.get(baseUrl + "/");

    driver.findElement(By.id("lst-ib")).clear();

    driver.findElement(By.id("lst-ib")).sendKeys("testplant");

    }

    Within an Eggplant Performance Selenium script this would become:

    import org.openqa.selenium.By;

    ...

    @Override

    public void script() throws Exception

    {

    getWebDriver().get("https://www.google.co.uk/");

    getWebDriver().findElement(By.id("lst-ib")).clear();

    getWebDriver().findElement(By.id("lst-ib")).sendKeys("testplant");

    }

 

This topic was last updated on August 31, 2021, at 05:41:51 PM.

Eggplant icon Eggplantsoftware.com | Documentation Home | User Forums | Support | Copyright © 2022 Eggplant