Search code examples
iosseleniumappium

Appium and Selenium fail to connect when "Use current location" permission popup appears


I am attempting to automate iOS testing with Appium. I have an app that requires user location and requests location permission on first launch. When I try to connect selenium to a fresh install, it fails when the popup appears. When I manually accept the popup, Seleium and Appium connect without fail and the test is able to continue.

This is a copy of the server output:

error: Instruments did not launch successfully, failing session
error: Failed to start an Appium session, err was: Instruments did not launch successfully--please check your app paths or bundle IDs and try again
info: Responding to client with error: {"status":6,"value":{"message":"A session is either terminated or not started","origValue":"Instruments did not launch successfully--please check your app paths or bundle IDs and try again"},"sessionId":"faccc84b-fa8e-4137-ad77-f0c79d09b045"}
POST /wd/hub/session 500 13605ms - 270
debug: - - - "POST /wd/hub/session HTTP/1.1" 500 270 "-" "Ruby"
info: Clearing out appium devices

and a copy of the selenium output:

Selenium::WebDriver::Error::NoSuchDriverError:
       A session is either terminated or not started

and I am initializing Selenium with the following command:

@driver = Selenium::WebDriver.for(:remote, :desired_capabilities => capabilities, :url => server_url)

Any help is appreciated!


Solution

  • I believe this is a known issue in Instruments. When the location services pops up within about 8 seconds of app launch, UIAutomation doesn't handle the popup for some reason. See this discussion on the Appium mailing list for more information.

    The only solution proposed so far is to delay the location services check until ~8s after app launch.