Before you get started, make sure you have installed the following:
The starting point is
LocalSelenium.java, a short Java script with Maven dependencies. The
pom.xml file is institutional here because it holds all configurations and dependencies. In its initial state, the file is very simple.
Note: We have simplified the script intentionally. It only serves the purpose of showing you how to connect to Perfecto.
The script accesses the Perfecto website and verifies the title.
To get started:
libsfolder of the project and update the
LocalSelenium.javaproject as TestNG Test.
In this step, we update the
pom.xml file with the required Perfecto dependencies and modify the script from Step 1 to add in security information, the Perfecto cloud name, driver details, Smart Reporting information, and test data. We also want to make sure that the script exits gracefully.
The updated script is called
PerfectoSelenium.java. The following procedure walks you through the configuration.
Expand a step to view its content.
Copy the dependencies in the
Generate your security token through the Perfecto UI. Then search for the following line in
Alternatively, you can pass the token as a Maven property, as follows:
Use capabilities to select a device from the Perfecto lab. You can be as generic or specific as needed. In our script, we have only included the
You can use the Manual Testing view in the Perfecto UI to generate a code snippet with device-specific capabilities that you can then copy-paste into your script.
To generate capabilities (for mobile or web devices) through the Perfecto UI:
As part of creating an instance of the RemoteWebDriver, you need to supply the URL of your Perfecto cloud. As part of creating an instance of the RemoteWebDriver, you need to supply the URL of your Perfecto cloud. Search for the following line in
The general structure of the URL string is as follows:
Here is the respective line from our sample script:
To get the most out of running your test in Perfecto, you need to create an instance of the Smart Reporting client (
In Utils.java, we show how to use the
In addition to supplying the driver link, the context supports optional settings, such as adding:
Replace the existing code after the
In our example, the test is separated into logical groupings of actions as logical steps. Each step is labeled and appears in the Execution Report together with the component actions. The beginning of each logical step is indicated with the
To close Smart Reporting and the driver, supply an indication of the final outcome of the test in an
In our example, the
Last, make sure to close and quit the
Also in this section: