# Ability to pass a URL to an iOS app?

**URL:** <https://discuss.appium.io/t/ability-to-pass-a-url-to-an-ios-app/1174>\
**Category:** Support\
**Created:** [October 29, 2014, 10:57pm UTC](https://discuss.appium.io/t/ability-to-pass-a-url-to-an-ios-app/1174 "2014-10-29T22:57:06Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![gavingmiller](https://discuss.appium.io/user_avatar/discuss.appium.io/gavingmiller/32/5297_2.png) [@gavingmiller](https://discuss.appium.io/u/gavingmiller)\
**Post date:** [October 29, 2014, 10:57pm UTC](https://discuss.appium.io/t/ability-to-pass-a-url-to-an-ios-app/1174/1 "2014-10-29T22:57:06Z")

</div>

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 😄 )

---

<div class="post-metadata">

**Author:** ![Ben\_Boral](https://discuss.appium.io/letter_avatar_proxy/v4/letter/b/8491ac/32.png) [@Ben\_Boral](https://discuss.appium.io/u/Ben_Boral)\
**Post date:** [October 30, 2014, 1:48pm UTC](https://discuss.appium.io/t/ability-to-pass-a-url-to-an-ios-app/1174/2 "2014-10-30T13:48:29Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![gavingmiller](https://discuss.appium.io/user_avatar/discuss.appium.io/gavingmiller/32/5297_2.png) [@gavingmiller](https://discuss.appium.io/u/gavingmiller)\
**Post date:** [October 30, 2014, 6:10pm UTC](https://discuss.appium.io/t/ability-to-pass-a-url-to-an-ios-app/1174/3 "2014-10-30T18:10:57Z")

</div>

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:

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

```

Hope that helps someone else in the future!

---

<div class="post-metadata">

**Author:** ![Ben\_Boral](https://discuss.appium.io/letter_avatar_proxy/v4/letter/b/8491ac/32.png) [@Ben\_Boral](https://discuss.appium.io/u/Ben_Boral)\
**Post date:** [October 30, 2014, 6:47pm UTC](https://discuss.appium.io/t/ability-to-pass-a-url-to-an-ios-app/1174/4 "2014-10-30T18:47:57Z")

</div>

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

[http://adcdownload.apple.com//videos/wwdc\_2012\_\_hd/session\_404\_\_building\_from\_the\_command\_line\_with\_xcode.mov](http://adcdownload.apple.com//videos/wwdc_2012 __hd/session_404__ building_from_the_command_line_with_xcode.mov)

---

<div class="post-metadata">

**Author:** ![wsegar](https://discuss.appium.io/letter_avatar_proxy/v4/letter/w/977dab/32.png) [@wsegar](https://discuss.appium.io/u/wsegar)\
**Post date:** [November 9, 2014, 1:34am UTC](https://discuss.appium.io/t/ability-to-pass-a-url-to-an-ios-app/1174/5 "2014-11-09T01:34:35Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![gavingmiller](https://discuss.appium.io/user_avatar/discuss.appium.io/gavingmiller/32/5297_2.png) [@gavingmiller](https://discuss.appium.io/u/gavingmiller)\
**Post date:** [November 9, 2014, 2:05am UTC](https://discuss.appium.io/t/ability-to-pass-a-url-to-an-ios-app/1174/6 "2014-11-09T02:05:11Z")

</div>

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

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

```

---

<div class="post-metadata">

**Author:** ![wsegar](https://discuss.appium.io/letter_avatar_proxy/v4/letter/w/977dab/32.png) [@wsegar](https://discuss.appium.io/u/wsegar)\
**Post date:** [November 9, 2014, 2:44am UTC](https://discuss.appium.io/t/ability-to-pass-a-url-to-an-ios-app/1174/7 "2014-11-09T02:44:50Z")

</div>

Thank you for the fix, Works!

---

<div class="post-metadata">

**Author:** ![Ben\_Boral](https://discuss.appium.io/letter_avatar_proxy/v4/letter/b/8491ac/32.png) [@Ben\_Boral](https://discuss.appium.io/u/Ben_Boral)\
**Post date:** [November 13, 2014, 11:04pm UTC](https://discuss.appium.io/t/ability-to-pass-a-url-to-an-ios-app/1174/8 "2014-11-13T23:04:40Z")

</div>

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”)

---

<div class="post-metadata">

**Author:** ![Christi](https://discuss.appium.io/user_avatar/discuss.appium.io/christi/32/3214_2.png) [@Christi](https://discuss.appium.io/u/Christi)\
**Post date:** [March 1, 2017, 8:56pm UTC](https://discuss.appium.io/t/ability-to-pass-a-url-to-an-ios-app/1174/9 "2017-03-01T20:56:55Z")

</div>

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

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

```

---

<div class="post-metadata">

**Author:** ![CoHuK](https://discuss.appium.io/user_avatar/discuss.appium.io/cohuk/32/2502_2.png) [@CoHuK](https://discuss.appium.io/u/CoHuK)\
**Post date:** [June 13, 2017, 8:37am UTC](https://discuss.appium.io/t/ability-to-pass-a-url-to-an-ios-app/1174/10 "2017-06-13T08:37:39Z")

</div>

But what about real device?
