Two ios Devices per Test Case issue

I am trying to create a testcase that uses two devices in the same test. The multi-device capability is very important to us. In this case, the devices are ios_simulator and ios_physical device (iphone 6+). I am using Studio version 10.9.66.

I’ve created 2 ios drivers. When the second driver is created, it looks as if it has a negative impact on the first. The screen goes dark on the physical device. The only commentary fed back to my code is:

"java.lang.AssertionError: session not created (Failed to create session) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 9.54 seconds
"

Need help understanding what is going on here, and a solution.

thanks
Walter

Hi Walter,

Since you are creating two iOS drivers, I suspect that they conflict in some way. Perhaps the second driver is trying to lock a device that has already been fetched by the first driver. Are you running the test in two threads, one for each device?

Can you share with us the test script so we can better understand the issue you are facing?

Hi Nivi;

I am creating the 2 IOS drivers on a single thread. As mentioned above, one driver is for the ios emulator, the other for a physical device (I assume this configuration is okay). If I run them separately all works fine, but together there is an issue. It is clear that there is some form of conflict but since each driver is targeting a different device, I am not sure where the conflict might be ? Would there be something in the Appium Studio logs that would be helpful ?

Below I show the code snippets that create the two devices. The CreateDevice class is called twice to create the 2 driver objects.

try {
device0 = SelectDeviceEnum.DEV_0.setDeviceType(DeviceTypeOptionsEnum.IOS_PHYSICAL);
device1 =SelectDeviceEnum.DEV_1.setDeviceType(DeviceTypeOptionsEnum.IOS_SIMULATOR);

  try( CreateDevice dev0 = new CreateDevice(device0)){
    CreateDevice dev1 = new CreateDevice(device1);
    :
    : 

}

Within CreateDevice():

private void buildIosPhysicalDriver(String iosBundleID) throws MalformedURLException {
DesiredCapabilities dc = new DesiredCapabilities();
dc.setCapability(MobileCapabilityType.UDID, “de26b951ae4075f8ee712fa73b22f65ba182c2d7”);
dc.setCapability(IOSMobileCapabilityType.BUNDLE_ID, iosBundleID);
dc.setCapability(IOSMobileCapabilityType.LAUNCH_TIMEOUT, 30000); //30 seconds
dc.setCapability(“instrumentApp”, true);
IOSDriver iosDriver = new IOSDriver(new URL(appiumServerURL), dc);
setDriver(iosDriver);

private void buildIosSimulatorDriver(String iosBundleID) throws MalformedURLException {
DesiredCapabilities dc = new DesiredCapabilities();
dc.setCapability(SeeTestCapabilityType.DEVICE_QUERY, “@os=‘ios’ and @emulator=‘true’”);
dc.setCapability(SeeTestCapabilityType.INSTRUMENT_APP, true);
dc.setCapability(IOSMobileCapabilityType.BUNDLE_ID, iosBundleID);
IOSDriver iosDriver = new IOSDriver(new URL(appiumServerURL), dc);
setDriver(iosDriver);
}

Look forward to your feedback !

If there is sample code that demonstrates how to create 2 drivers that operate concurrently, I’d like to see it.

thanks
walter

I think I figured this one out. It may have had nothing to do with the code. Seems that the app tries to connect to a wifi network as soon as it comes up. On the simulator, it was using the wifi of my laptop. With the physical device, it is relying on the device being connected to the wifi, and the device wasn’t.

I have turned on device wifi, and rerun the code and all looks good. More testing to be done. Important to note that the drivers are on the same thread. This should be the simplest case. Later on, they will be on different threads better taxing the appium server.

This is on studio 10.66. I am still having issues with studio 11.2.23 that deal with getting a session going with a physical device. This issue has its own forum thread.

Hi Walter,

You are correct in that two drivers can live in the same thread. I consulted Tom about your case and he confirmed that. I’m happy to hear that you managed to find the cause of the issue, I was about to try and recreate the issue and then have one of our QA look into it.

Regarding the other issue, I will look into it right away.