Creating a Selenium Virtual User Script from a Selenium IDE Recording
- Launch the Firefox browser and then navigate to http://docs.seleniumhq.org/download/.
- Click to download the latest version of Selenium IDE:
- Click Allow to allow the Selenium IDE to be installed.
- Click Restart Now to restart Firefox .
- Launch the Selenium IDE by navigating to Web Developer > Selenium IDE
- 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":
- To convert the Selenium recording into a Java JUnit test case, go to File > Export Test Case As > Java / JUnit 4 / WebDriver:
- 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");
}