Trouble to execute parallel test

Hello guys, i´m facing trouble to run parallel tests on different phisical android devices. i´ve tried some solutions from here but wth no success.

  • The Test Suites consist in device 1 calls device 2
  • I don´t why sometimes it executes both at the same intend from appium;
  • If i execute separately it goes fine;
  • Device 1 get lost at the first test case
  • Device 2 get lost at @BeforeClass

I believe it´s something about my driver and settings, but i can´t figure out, I appreciate any help

Here is my driver:

package core;

import io.appium.java_client.MobileElement;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.remote.AndroidMobileCapabilityType;
import io.appium.java_client.remote.MobileCapabilityType;
import io.appium.java_client.remote.MobilePlatform;
import org.openqa.selenium.remote.DesiredCapabilities;

import java.net.MalformedURLException;
import java.net.URL;

public class DriverFactory {

    private static AndroidDriver<MobileElement> driver;

    public static AndroidDriver<MobileElement> getDriver(String device, int porta) throws InterruptedException {
        if (driver == null) {
            createDriver(device, porta);
        }

        return driver;

    }

    private static void createDriver(String device, int port) {


        // OPEN APP
        DesiredCapabilities cap = new DesiredCapabilities();
        cap.setCapability(MobileCapabilityType.PLATFORM_NAME, MobilePlatform.ANDROID);
        cap.setCapability(MobileCapabilityType.DEVICE_NAME, "device");
        cap.setCapability(MobileCapabilityType.UDID, device);
        cap.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, "120");
        cap.setCapability(AndroidMobileCapabilityType.APP_PACKAGE, "package");
        cap.setCapability(AndroidMobileCapabilityType.APP_ACTIVITY, "activity");
        cap.setCapability(AndroidMobileCapabilityType.AUTO_GRANT_PERMISSIONS, "true");


        try {
            driver = new AndroidDriver<>(new URL("http://127.0.0.1:" + port + "/wd/hub"), cap);
        } catch (MalformedURLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }


    }

    public static void killDriver() {
        if (driver != null) {
            driver.quit();
            driver = null;
        }
    }

}

Here´s my xml:

> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
> <suite name="Parallel test" parallel="tests" thread-count="2">
> <test name="Stability_Enviar">
> 	<classes>
> 		<class name="testes.Stability_Enviar"></class>
> 	</classes>
> </test>
> <test name="Stability_Receber">
> 	<classes>
> 		<class name="testes.Stability_Receber"></class>
> 	</classes>
> </test>
> </suite>

DEVICE 1

DEVICE 2

is evil. static means SAME variable = ONE drive = ONE device. remove it.

1 Like

Hello @Aleksei i´ve just rewrote all driver (cleaner way) now it´s working fine… Thanks