Unable to click Setting button after RunAppInBackgroun - iOS - Appum 2.0.0-beta.66

Device: iOS
Appium: Appum 2.0.0-beta.66

I’m able to minimize app using the code below, but I’m unable to find or click the Setting icon.

I’m trying to programmatically disable the GPS on iOS device.

iosdriver.runAppInBackground(Duration.ofSeconds(-1));
try {Thread.sleep(1000);}catch (Exception e) {}
Boolean isFoundElement;
isFoundElement = iosdriver.findElement(By.id(“Settings”)).isDisplayed();

Thank for any information you can provide.

just take page source to see elements.

The Appium Inspector show that the object exists.

There seems to be a issue using iosdriver once you put the current app in the background.

I’ve tried many combinations of Object identification and nothing finds the settings control.

Make sure the correct active application is selected and no race condition happens.
Check https://appiumpro.com/editions/109-working-with-ipados-multitasking-split-view to learn more about the active application concept.
Use explicit timers to avoid race conditions

Has this be depreciated?
iosdriver.runAppInBackground(Duration.ofSeconds(-1));

Even if I remove this step and manual hide the application appium is still unable to find the Settings icon.

I got it to work.

iosdriver.findElement(By.xpath("(//XCUIElementTypeIcon[@name=“Settings”])[2]")).click();

as you see there 2 elements with name “Settings” and you tap in last code on second one.