Quick start: Run your first Appium test with Perfecto
If you are already familiar with Appium, use the following quick-start information to run a simple Appium test on Perfecto with minimal setup. If you need more guidance, see the main Appium article.
Prerequisites
Before you get started, make sure you have installed the following:
-
Java 11
-
An IDE of your choice, such as Eclipse or IntelliJ IDEA (consider using IntelliJ IDEA for a better Appium and Maven integration)
-
Android Studio
-
Local Appium Server running at:
http://127.0.0.1
Port: 4723
Additional setup per IDE
Eclipse users should also install:
IntelliJ IDEA users should also install:
-
This plugin is usually bundled with the IDE, but ensure it is enabled.
IntelliJ IDEA versions 7 and later include the TestNG plugin as a built-in plugin.
Optional installations
For source control management, you can install git.
Step 1: Set up desired capabilities
For iOS or Android, specify the relevant desired capabilities. Following is an example in JSON format for running a mobile web test (Safari on iPhone). Replace your_perfecto_security_token
with your actual token from the Perfecto UI (from the menu at the top right, select My Profile > Security Token).
{
"platformName": "iOS",
"browserName": "mobileSafari",
"deviceName": "iPhone.*",
"automationName": "XCUITest",
"securityToken": "your_perfecto_security_token"
}
Step 2: Start a session
The following code example illustrates how to start a session using Appium with Java (TestNG/WebDriver).
import io.appium.java_client.remote.MobileCapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import java.net.URL;
public class PerfectoSafariTest {
public static void main(String[] args) throws Exception {
DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability("platformName", "iOS");
caps.setCapability("browserName", "mobileSafari");
caps.setCapability("deviceName", "iPhone.*"); // regex: any iPhone
caps.setCapability("automationName", "XCUITest");
caps.setCapability("securityToken", "your_perfecto_security_token");
// Replace <cloud> with your actual cloud name (e.g. demo)
URL url = new URL("https://<cloud>.perfectomobile.com/nexperience/perfectomobile/wd/hub");
RemoteWebDriver driver = new RemoteWebDriver(url, caps);
driver.get("https://example.com");
System.out.println("Page Title: " + driver.getTitle());
driver.quit();
}
}
Step 3: Configure optional capabilities for advanced use
Optionally, you can add the following capabilities to align the session with Appium's behavior inside Perfecto. To learn more, see Supported Appium capabilities.
{
"useAppiumForWeb": "true",
"enableAppiumBehavior": "true"
}
Step 4: Review test reports
After running a test, you can view the test results in the Perfecto Report Library, including video, logs, screenshots, and device vitals.