Selenium

How to run your Java Selenium script in Perfecto

This section provides instructions on how to run Selenium WebDriver tests with Java in Perfecto. It assumes that you:

  • Are familiar with Selenium
  • Have existing tests to work with
  • Are a novice user of Perfecto

To run your tests in Perfecto, you need to modify your existing scripts to include:

  • What driver you want to use
  • Where your Perfecto instance is located 
  • Who you are
  • What devices you want to work on

We provide two versions of the same script to help you understand how you can modify your existing scripts to run them in Perfecto: LocalSelenium.java and PerfectoSelenium.java

Note:

For information on running the final script, see the README.md file included with the sample project.

Prerequisites

Before you get started, make sure you have installed the following:

1 | Get started

As a starting point, we will look at LocalSelenium.java. This is an example of a simple Selenium script that opens the www.perfecto.io website and verifies the title on the page.

The pom.xml file in the PerfectoSampleProject contains many additional dependencies. Your project pom.xml file may look different.

To run the sample project: 

  1. Access the sample project in GitHub: https://github.com/PerfectoMobileSA/PerfectoSampleProject
  2. Clone the project locally, to the location of your choice, or download the project as a ZIP file (in this case, you need to extract the .zip file before using the project).
  3. Open the project in the IDE of your choice (for example, IntelliJ Idea).
  4. Run the LocalSelenium.java test as TestNG Test.

2 | Configure the script for Perfecto

In this step, we will look into the changes that you need to perform to be able to run the same test on Perfecto.

You will need to update the pom.xml file with the Perfecto dependencies and add security information, the Perfecto cloud name, driver details, Smart Reporting information, and test data. The updated script example is called PerfectoSelenium.java. You can find it in the same sample project that we downloaded in 1 | Get started.

The following procedure walks you through the configuration.

Expand a step to view its content.