Page tree
Skip to end of metadata
Go to start of metadata

Description

In order to connect several reports, users can use the multiTestId test property. It available for Grid tests.



In the generated report you can swap between related tests by clicking the 'Device' field at the top left of the report.





            

     


After clicking a list of devices is presented with their names.

Examples


Appium
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.AndroidElement;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInfo;
import org.openqa.selenium.remote.DesiredCapabilities;

import java.net.URL;
import java.util.UUID;

public class AppiumExample {
    private final static String host = "<Cloud URL>";
    private final static String accessKey = "<Your Access Key>";
    private static String multiLink = String.valueOf(UUID.randomUUID());
    private String reportDirectory = "reports";
    private String reportFormat = "xml";
    private String firstDeviceTestName = "Multi Device Test- Device 1";
    private String secondDeviceTestName = "Multi Device Test- Device 2";
    AndroidDriver<AndroidElement> driver1;
    AndroidDriver<AndroidElement> driver2;

    public DesiredCapabilities mustHaveCapabilitiesForMultiDeviceReport(String testName){
        DesiredCapabilities dc = new DesiredCapabilities();
        dc.setCapability("reportDirectory", reportDirectory);
        dc.setCapability("reportFormat", reportFormat);
        dc.setCapability("testName", testName);
        dc.setCapability("accessKey", accessKey);
        dc.setCapability("multiTestId", multiLink);// This line makes the connection
        return dc;
    }

    @BeforeEach
    public void beforeEach(TestInfo testInfo) throws Exception {
        driver1 = new AndroidDriver<>(new URL(host + "/wd/hub"), getCapabilitiesForDevice1());
        driver2 = new AndroidDriver<>(new URL(host + "/wd/hub"), getCapabilitiesForDevice2());

    }
    @Test
    public void firstDevice() {
        // Your test logic....
    }

    @AfterEach
    public void afterEach(TestInfo testInfo) {
        driver1.quit();
        driver2.quit();
    }

    public DesiredCapabilities getCapabilitiesForDevice1() {
        DesiredCapabilities dc = mustHaveCapabilitiesForMultiDeviceReport(firstDeviceTestName);
		dc.setCapability("newCommandTimeout", 120000);


        //.... additional capabilities....
        return dc;
    }
    public DesiredCapabilities getCapabilitiesForDevice2() {
        DesiredCapabilities dc = mustHaveCapabilitiesForMultiDeviceReport(secondDeviceTestName);
		dc.setCapability("newCommandTimeout", 120000);


        //.... additional capabilities....
        return dc;
    }
}
Seetest
import com.experitest.client.Client;
import com.experitest.client.GridClient;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import java.util.UUID;


public class STAExample {
    private final static String host = "<Cloud URL>";
    private final static String accessKey = "<Your Access Key>";
    private static String multiLink = String.valueOf(UUID.randomUUID());
    private String reportDirectory = "reports";
    private String reportFormat = "xml";
    private String firstDeviceTestName = "Multi Device Test- Device 1";
    private String secondDeviceTestName = "Multi Device Test- Device 2";
    protected Client client1;
    protected Client client2;

    @BeforeEach
    public void beforeEach() {
        GridClient grid1 = new GridClient(accessKey, host);
        GridClient grid2 = new GridClient(accessKey, host);
        client1 = grid1.lockDeviceForExecution(firstDeviceTestName, "", 10, 50000);
        client2 = grid2.lockDeviceForExecution(secondDeviceTestName, "", 10, 50000);
		client1.setProperty("controller.idle.timeout",""+120000 );
		client2.setProperty("controller.idle.timeout",""+120000 );
        client1.setReporter(reportFormat, reportDirectory, firstDeviceTestName);
        client2.setReporter(reportFormat, reportDirectory, secondDeviceTestName);
        client1.addTestProperty("multiTestId",multiLink);
        client2.addTestProperty("multiTestId",multiLink);


    }
    @Test
    public void test(){
        //Your test logic

    }

    @AfterEach
    public void afterEach(){
        client1.generateReport(false);
        client2.generateReport(false);
        client1.releaseClient();
        client2.releaseClient();
    }
}



  • No labels