Selenium

To learn how to run Java Selenium scripts in Perfecto, review the following information.

To run a Selenium WebDriver test with Java in Perfecto, you should:

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

The setup process involves modifying 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 PerfectoLocalSelenium.java and PerfectoSelenium.java

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

Important: This document includes references to third-party products, Eclipse IDE and IntelliJ IDEA. The user interface and usage of third-party products are subject to change without notice. For the latest published information about Eclipse IDE, see https://www.eclipse.org/documentation. For the latest published information about IntelliJ IDEA, see https://www.jetbrains.com/help/idea/getting-started.html.

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/PerfectoJavaSample
  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.