Appium 1.6.3 ios 10+ [ruby] Handling two alerts at the same time

Hi guys,

So im testing iOS app and i got situation when 2 alerts pop up one after another. And first one is hidden after the second one. Appium says that multiple choices is found and dont give the ability to select

I`m using ruby bindings, is there a way to bypass this situation

[debug] [BaseDriver] Waiting up to 11000 ms for condition
[debug] [JSONWP Proxy] Proxying [POST /elements] to [POST http://localhost:8100/session/FBD28E85-0A3F-4F7A-9673-C254F4B44FE9/elements] with body: {“using”:“xpath”,“value”:"//*[@name=“Enable”]"}
[debug] [WebDriverAgent] Sim: Feb 27 19:38:01 administrators-Mac-mini XCTRunner[86514]: Enqueue Failure: UI Testing Failure - Multiple matches found:
[debug] [WebDriverAgent] Sim: →Application 0x600000577100: {{0.0, 0.0}, {320.0, 568.0}}, label: ‘Test’
[debug] [WebDriverAgent] Sim: ↳Window 0x6000005774c0: Main Window, {{0.0, 0.0}, {320.0, 568.0}}
[debug] [WebDriverAgent] Sim: ↳Other 0x6000005783c0: {{0.0, 0.0}, {320.0, 568.0}}
[debug] [WebDriverAgent] Sim: ↳Alert 0x600000578600: traits: 72057602627862528, {{25.0, 185.5}, {270.0, 197.5}}, label: ‘first’
[debug] [WebDriverAgent] Sim: →Application 0x600000577100: {{0.0, 0.0}, {320.0, 568.0}}, label: ‘Test’
[debug] [WebDriverAgent] Sim: ↳Window 0x6000005774c0: Main Window, {{0.0, 0.0}, {320.0, 568.0}}
[debug] [WebDriverAgent] Sim: ↳Other 0x600000579c80: {{0.0, 0.0}, {320.0, 568.0}}
[debug] [WebDriverAgent] Sim: ↳Alert 0x600000579ec0: traits: 72057602627862528, {{25.0, 139.0}, {270.0, 290.0}}, label: ‘Second’ /usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgentRunner/UITestingUITests.m 35 1

Iterate through them in a loop. You don’t give your code so I’m doing a bit of guesswork:

alerts = <however you are finding these>

    alerts.each do |alert|

Hello Wreed, thank you for your insight and sorry for minimal info.

Your method can’t be aplied cos my code looks like

Element :my_button, xpath “//*[@name=“evaluate”]” #can be typos here


And here appium gives error, i’ve tried to use find_custom to get those alerts to list, and got blank list. Is therer a way to access alert by it’s label maybe?

You could also try to click by exact_text


Never faced this problem so we have to face the solution for the first time I think. Maybe is an scenario where appium gets stuck :S

Hmm. Seems like switch_to.alert is having a problem with the two alerts. Looks like a bug to me. According to this documentation, you might be able to work around this with a helper method like, ‘accept_alert’. Take a look and see if that doesn’t help:

slipy12, wreed Thank you very much for your responses, i will try those 2 sollutions and get back at you.

Currently to fasten up, testing, we solved it from the developers side by not showing second alert until first one is present.

1 Like