Upload Selenium tests

SRF enables you to upload Web Selenium tests as SRF assets.

For details about supported test types, see Selenium web testing.

Upload your Selenium test

Before uploading a Selenium test to SRF, ensure that you first define the SRF server, port, client ID, and client secret in your test.

Then, do any of the following, as needed:

Applitools

If you want to add Applitools visual testing steps to your test, see Add Applitools code to your Selenium script.

Ruby

If you are uploading a Ruby script to SRF, continue with Prepare a Ruby .zip for upload.

Packaging multiple scripts

To package multiple scripts together, continue with Prepare a Selenium .jar file for upload.

JUnit tests

If your script includes multiple tests in a single JUnit class, SRF runs all tests of the defined class.

If you do not want all of these tests to be run in SRF, comment out the relevant lines as needed before uploading.

When you're done preparing your test, upload Selenium tests to SRF from the SRF SCRIPTS tab. For details, see Basic upload steps.

Back to top

Prepare a Selenium .jar file for upload

Package your Selenium scripts as a .jar archive to upload to SRF.

Do the following:

  1. Make sure you have the following prerequisites before you start:

    Test script

    Ensure that your script can run remotely in SRF. For details, see Run Selenium tests remotely.

    Note: We recommend making a copy of your original script in the same location for reference.

    Maven Make sure you have Maven installed, and that your project is a maven project.
    Descriptor file

    Add a descriptor.json file in your project's resources folder.

    In this file, define the runnableClass value as the path to the class you want to run, including the fully-qualified class name.

    For example, see descriptor.json file with runnableClass example.

  2. In your Selenium script, replace your Client ID and Secret values with the following static code. You can comment out the CLIENT_ID property.

    capabilities.setCapability("SRF_CLIENT_ID", System.getenv("SRF_CLIENT_ID"));
    capabilities.setCapability("SRF_CLIENT_SECRET", System.getenv("SRF_CLIENT_SECRET"));
  3. Add the RemoteWebDriver location as follows:

    RemoteWebDriver driver = new RemoteWebDriver(new URL(System.getenv("SELENIUM_ADDRESS")), capabilities);
  4. Compile your code, including any dependencies, and make sure the hierarchy remains stable.

  5. From your IDE or the command line, run a maven clean install command.

    Your compiled .jar file will be available for upload in your /target folder.

Continue with Basic upload steps to upload your .jar file to SRF.

Back to top

Prepare a Ruby .zip for upload

To upload your Ruby test to SRF, you must first package the test as a .zip file.

Do the following:

  • Include a Rakefile in your zip, including a default task that describes your test. SRF runs the default task when running your uploaded test.

    The Rakefile filename is case-sensitive. For an example, see Rakefile file.

  • Optionally, define parameters in your script to test different features in each test run.

    For example, if you have a parameter named FEATURE_PATH, add the following code to your test:

    t.cucumber_opts = '--format pretty  ".\\' + ENV["FEATURE_PATH"] + '"'

Then, continue with Basic upload steps to upload your .zip file to SRF.

Note: SRF supports specific frameworks out of the box. If your test requires additional components, they must be included in the zip file you upload.

For example, use the --install-dir flag of a gem command to install the component locally.

Back to top

Selenium code samples for upload

Use the following code as samples when preparing Selenium tests for upload.

Sample Ruby .zip file

The following is an example of the contents of a zip file containing a Ruby test ready for upload:

The files in this example include the following code:

For more details, see Prepare a Ruby .zip for upload.

Back to top