MAC Unable to initialize driver without MobileCapabilityType.UDID

The following code works fine when run in windows, but fails when connected to Appium Studio running on Mac.

dc.setCapability(“reportDirectory”, "C:\Appium\Reports);
dc.setCapability(“reportFormat”, “xml”);
dc.setCapability(“testName”, “Test123”);
dc.setCapability(“platformName”, “iOS”);
dc.setCapability(“autoDismissAlerts”, true );
driver = new IOSDriver<>( new URL(settings.getConfig().get(“DriverHost”)), dc);

For running on Mac I need to specify the following line and only then it works.
dc.setCapability(MobileCapabilityType. UDID , deviceId);

I have a scenario where I switch to multiple devices, which works fine on windows, but fails on Mac.

Kindly help.

Thanks,

Okay.

How do you switch in between between devices in windows ?

Can you elaborate your requirement ? Is it now possible for you to have 2 driver instances as instance variable?

I am using SeeTestClient library.
driver = new IOSDriver<>( new URL(settings.getConfig().get(“DriverHost”)), dc);
seetest = new SeeTestClient(driver);

I have a scenario, where I perform few steps on one mobile and other steps on other mobile and its back and forth. These steps are in a single test.

I switch device using
seetest.setDevice(deviceId);

By this way I have the entire report in one test.
This works well when I am windows, but the same code doesnt work on Mac. My end goal is that the script should work on Mac systems.

Having 2 driver instances would put me into having multiple report generation.

Okay.

can you paste me the error when you switch on the Mac OS in Appium Studio and also in logs (logs you can get from Help -> Open Logs Folder , check for Appium Studio*.log) ,

After switching device, none of the elements are detected by the script.

I can share the entire log, can you provide your email.

Thanks,

Sorry, I am a little confused here

The first question was that the setup code which you are using fails on Mac …

But the actual problem seems to be elements are not found and you also say that using UDID works …

sorry for the confusion. let me reiterate the problem.

Below setup is in windows. which works fine.

  1. Intialized driver without UDID. Intialized seetesclinet using the driver.
  2. Using seetestclient i set device, perform actions and switch between devices

When I run this on Mac. There are actually 2 problems, 2nd problem is connected to problem 1.

  1. From the above setup, the execution was stuck at the driver initialization. so after adding the UDID with the driver, the driver got initialized. and the seetestclient got initialized as well.
  2. When performing action, scripts works only on the device that was mentioned in UDID. If I switch to other device, test fails to detect elements.

I feel the problem #2 is somewhere connect to #1.

Please let me know if this is clear.

okay. I figured out the issue.
The app on windows is non-instrumented and the app on Mac is instrumented.
When I switch to 2nd device I was going into instrumented mode and the elements were not detected.
Changed the entire elements to instrumented and worked well.

Thanks Kishore for the followup.

Great … I wanted to suggest you the same.