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

StackOverflow https://stackoverflow.com/questions/16048123

  •  04-04-2022
  •  | 
  •  

Question

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!

Was it helpful?

Solution 2

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.

OTHER TIPS

There has been an appium update for this. Simply add the capability to always accept these alerts to avoid failures anywhere in the app. Java example:

        capabilities.setCapability("autoAcceptAlerts", true);

I had the same issue. To get it working I added 2 capabilities to Appium

    caps = {
        "locationServicesAuthorized" => true
        "bundleId" => "com.domain.myproject"
    }

Also you can try:

start your app, accept location manually, then copy file from path to your test folder.

path - /Users/your_username/Library/Application Support/iPhone Simulator/7.0/Library/Caches/locationd/clients.plist

then each time before starting your test, copy that file back to that location and you will not see Location Popup.

BR. Aleks.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top