Ability to pass a URL to an iOS app?

Our application responds to URLs from outside the application (IE push notification/email link), and I’d love to be able to test those flows within appium. Our urls are of the form: petrofeed://foo/.

Is there anyway I can send this URL to my application? Or can I somehow trigger our app to launch based on that url? One idea I had was clicking through to that url from safari or something (really thinking outside the norm here :smile: )

Check out Xcode cli’s simctl. It has an openURL command

Thanks @Ben_Boral, worked like a charm!

With openurl I needed to pass the device id (UUID) that appium was running the tests on. There were no methods (that I could find) to get the device id, so I used xcrun simctl list to query for the booted device. Here’s the ruby code I used:

def launch_url(url)
    simulator_id = `xcrun simctl list | grep 'Booted' | cut -d \( -f2 | tr -d ')'`.strip
    `xcrun simctl openurl #{simulator_id} #{url}`

Hope that helps someone else in the future!

Good for you. I recommend anybody working in test automation for iOS watch the following WWDC video about Xcode’s command line tools:


This was very helpful, thank you gavingmiller.

I did find one problem though, the grep pattern to retrieve the device id will not work if ‘iPhone 6 Plus’ is the booted device. It returns ‘Plus’ as the device id. Do you have a new grep pattern that will work when this device is selected.

Thank you very much in advance for your help.

Hey @wsegar updated my previous answer. New command is:

xcrun simctl list | grep 'Booted' | cut -d \( -f2 | tr -d ')'

Thank you for the fix, Works!

Calling out to the command line is a suboptimal way of solving this problem. It would be great if this was a part of Appium. For ex. iosDriver.openUrl(“path/to/page”)

I had to add single quotes around the open parenthesis delimiter to get this to work in 2017:

def launch_url(url)
    simulator_id = `xcrun simctl list | grep 'Booted' | cut -d '\(' -f2 | tr -d ')'`.strip
    `xcrun simctl openurl #{simulator_id} #{url}`

But what about real device?