Getting Started - Selenium Java

Follow this guide for a basic example of running a test with the Java Selenium bindings. For our example we will run a simple scenario that opens https://www.google.com and takes a screenshot.

Start by signing up and creating a new test case using the New Test Case button on the dashboard or Test Case -> New... in the left side panel.

Enter the test case name (e.g. Selenium Java Demo) and press Next.

Scenario

Select Selenium as the scenario type.

Selenium Scenario

Let's use the following settings:

  1. Bindings: Selenium Java
  2. Framework: None
  3. Source: Create/Edit/Upload *.java Files. See the detailed documentation for all the other options of how we can get our code onto Testable.

Selenium Java Settings

For our main class we will use the example Test.java that is provided automatically and can also be found in the selenium-java-example project.

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeOptions;

import io.testable.selenium.TestableSelenium;

public class Test {

    public static void main(String[] args) throws Exception {
        ChromeOptions options = new ChromeOptions();
        WebDriver driver = TestableSelenium.newWebDriver(options);
        driver.get("https://www.google.com");
        TestableSelenium.takeScreenshot(driver, "HomePage.png");
        driver.close();
    }

}

Our basic examples does the following:

  1. Load the Google homepage in Chrome
  2. Save a screenshot to the output directory monitored by Testable
  3. Closes the driver

And that's it, we've now defined our scenario! To try it out before configuring a load test click the Smoke Test button in the upper right and watch Testable execute the scenario 1 time as 1 user.

Next, click on the Configuration tab or press the Next button at the bottom to move to the next step.

Configuration

Now that we have the scenario for our test case we need to define a few parameters before we can execute our test:

  1. Load Profile: Select Flat to ramp up to a constant number of concurrent users for the test.
  2. Concurrent Users Per Region: Number of users that will execute your Java code in parallel per region selected. Each concurrent user will run java and communicate with a shared local Selenium server on the test runner.
  3. Test Runners: Choose the test runners that will run this test (e.g. on our public shared grid). Each test runner region will simulate the number of concurrent users defined above.
  4. Type: Select Iterations to have each concurrent user execute the Webdriver.io script sequentially a set number of times regardless of how long it takes. Choose Duration if you want each user to continue executing the script for a set amount of time (in minutes).

And that's it! Press Start Test and watch the results start to flow in. See the new configuration guide for full details of all configuration options.

For the sake of this example, let's use the following parameters:

Test Configuration

View Results

Once the test starts executing, Testable will distribute the work out to the selected test runners (e.g. Public Shared Grid in AWS N. Virginia).

Test Results

In each region, the test runners execute your main class as 3 virtual users (i.e. 3 JVMs) for 1 minute.

The results will include screenshots, traces, performance metrics, logging, breakdown by URL, analysis, comparison against previous test runs, and more.

Check out the Selenium Java guide for more details on running your Selenium Java code on the Testable platform.

We also offer integration (Settings -> Integration) with third party tools like New Relic. If you enable integration you can do more in depth analytics on your results there as well.

That's it! Go ahead and try these same steps with your own scripts and feel free to contact us with any questions.