Unable to go to IOS settings app with real device

Hello

In my App am trying to scan a QR code which redirects me to web view and enter credentials give me Pin.

Here when ever am scanning the QR code instead of going to WebView it is giving me pin or error message. looks like data is taking from cache
so am trying to clear browser history by switching to settings app.
am using
capability.setCapability(“bundleId”, “com.apple.Preferences”);
driver = new IOSDriver(url, capability);

or
driver.activateApp(“com.apple.Preferences”);

nothing is working

Appium Version 1.21
IOS: real device (14.6)

Might be worthwhile to try backgrounding your test app:

https://appium.io/docs/en/commands/device/app/background-app/

And then just navigating to iOS Settings or whatever. You could then navigate back to your app and click on it to open back up. Use ‘-1’ to background infinitely, but then when you open it back up everything should work as before.

Thankyou @wreed am able to open setting app and do clear history.
But when I scan QR code from App it still not going WebView what else I can do I used clearsystemfiles capability but still the same.

Ok, you are expecting the browser to open when you scan the QR code, but that’s not happening? What is happening? What does the log say?

yes it should open safari and ask me login info then go to native app to give me Pin. Here as soon as I scan QR code it is directly taking me to request Pin page from App. definitely it is taking data from cache .
when I include useNewWDA capability then it is redirecting me to WebView but here for every automation script wad is installing creating session and some times it hang.

I’ve definitely had trouble clicking external links from within the app. I try to avoid this if at all possible.

Is QR code the only way to get the pin? If not, you might want to put this particular workflow on hold until you can figure out what is going on. As I mentioned above, the log may tell more about what’s happening.

As per functionality that is only way. :expressionless:appium-server-logs.txt (81.8 KB)

Log indicates a bad xpath:

[debug] e[35m[W3C (5bdcbd2b)]e[39m Calling AppiumDriver.findElements() with args: [“xpath”,“//[@id=‘otherTileText’]“,“5bdcbd2b-5c6a-4f65-a798-cd182c2df793”]
[debug] e[35m[XCUITest]e[39m Executing command ‘findElements’
[debug] e[35m[BaseDriver]e[39m Valid locator strategies for this request: xpath, id, name, class name, -ios predicate string, -ios class chain, accessibility id, css selector
[debug] e[35m[BaseDriver]e[39m Waiting up to 0 ms for condition
[debug] e[35m[WD Proxy]e[39m Matched ‘/elements’ to command name ‘findElements’
[debug] e[35m[WD Proxy]e[39m Proxying [POST /elements] to [POST http://127.0.0.1:8100/session/0B68B72C-26F8-4A0C-A688-055E56F635CD/elements] with body: {“using”:“xpath”,“value”:”//
[@id=‘otherTileText’]”}[debug] e[35m[WD Proxy]e[39m Got response with status 200: {“value”:,“sessionId”:“0B68B72C-26F8-4A0C-A688-055E56F635CD”}
[debug] e[35m[W3C (5bdcbd2b)]e[39m Responding to client with driver.findElements() result:
[info] e[35m[HTTP]e[39m e[37m<-- POST /wd/hub/session/5bdcbd2b-5c6a-4f65-a798-cd182c2df793/elements e[39me[32m200e[39m e[90m344 ms - 12e[39m
[info] e[35m[HTTP]e[39m e[90me[39m[info] e[35m[HTTP]e[39m e[37m–>e[39m e[37mPOSTe[39m e[37m/wd/hub/session/5bdcbd2b-5c6a-4f65-a798-cd182c2df793/elemente[39m
[info] e[35m[HTTP]e[39m e[90m{“using”:“xpath”,“value”:“//[@id=‘i0116’]“}e[39m
[debug] e[35m[W3C (5bdcbd2b)]e[39m Calling AppiumDriver.findElement() with args: [“xpath”,”//
[@id=‘i0116’]”,“5bdcbd2b-5c6a-4f65-a798-cd182c2df793”]
[debug] e[35m[XCUITest]e[39m Executing command ‘findElement’
[debug] e[35m[BaseDriver]e[39m Valid locator strategies for this request: xpath, id, name, class name, -ios predicate string, -ios class chain, accessibility id, css selector
[debug] e[35m[BaseDriver]e[39m Waiting up to 0 ms for condition
[debug] e[35m[WD Proxy]e[39m Matched ‘/element’ to command name ‘findElement’
[debug] e[35m[WD Proxy]e[39m Proxying [POST /element] to [POST http://127.0.0.1:8100/session/0B68B72C-26F8-4A0C-A688-055E56F635CD/element] with body: {“using”:“xpath”,“value”:“//[@id=‘i0116’]"}[info] e[35m[WD Proxy]e[39m Got response with status 404: {“value”:{“error”:“no such element”,“message”:"unable to find an element using ‘xpath’, value '//[@id=‘i0116’]'”,“traceback”:"(\n\t0 WebDriverAgentLib 0x0000000102e6ba4c FBNoSuchElementErrorResponseForRequest + 288\n\t1 WebDriverAgentLib 0x0000000102e6b850 +[FBFindElementCommands handleFindElement:] + 336\n\t2 WebDriverAgentLib 0x0000000102e341f8 -[FBRoute_TargetAction mountRequest:intoResponse:] + 180\n\t3 WebDriverAgentLib 0x0000000102e16208 __37-[FBWebServer registerRouteHandlers:]_block_invoke + 420\n\t4 WebDriverAgentLib 0x0000000102e536fc -[RoutingHTTPServer handleRoute:withRequest:response:] + 164\n\t5 WebDriverAgentLib 0x0000000102e540c0 __72-[RoutingHTTPServer routeMethod:withPath:parameters:request:connection:]_block_invoke + 64\n\t6 libdispatch.dylib 0x00000001a8eb781c DAF30062-4C85-3B92-B159-50602A0C9D97 + 18460\n\t7 libdispatch.dylib 0…
[debug] e[35m[W3C]e[39m Matched W3C error code ‘no such element’ to NoSuchElementError
[debug] e[35m[W3C (5bdcbd2b)]e[39m Encountered internal error running command: NoSuchElementError: An element could not be located on the page using the given search parameters.

I can add tag name in the Xpath but Appium driver is not going into webpage itself microsoftpage. Do I need to change any values or additional capabilities . This is the core functionality of the App

Yeah, I think you are right. It’s probably failing when leaving the app itself. At this point I think you should talk to developers and let them know the problem you are facing. Since this is the debug version anyway, maybe they can help generate this pin by a different method. You can background the app and move around the OS, but clicking on an external link is problematic. I would ask for a debug menu that has an item to generate the pin.

manually when we clear history from settings app we were able to switch to web view upon QR code scan . This is happening with automation. Inspire am clearing history before every script. Do you think the Appium driver is picking from somewhere ?

I’m sorry, I’m not quite following here. When you manually clear the settings, you can switch to QR code, and this is happening in Automation? So you are clearing this cache but Appium is picking up something?

You could possibly clear the app by uninstalling/reinstalling. iOS doesn’t have the same facility to do this that Android does.