Extract the current url of a webview

1,008 views
Skip to first unread message

Aish

unread,
Aug 25, 2014, 4:45:54 AM8/25/14
to appium-...@googlegroups.com
Hi guys,

Just a naive question. Is there any simple way to extract the webview URL when I'm automating a hybrid IOS app? I'm using ruby! 

Thanks 
Aish

Jonah Stiennon

unread,
Aug 26, 2014, 6:46:57 PM8/26/14
to appium-...@googlegroups.com

If you switch to the context of the webview, you can call driver.getCurrentUrl(); in java.
(All clients should support the command https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/url)

Aish

unread,
Aug 27, 2014, 2:44:42 AM8/27/14
to appium-...@googlegroups.com
Any hints in ruby? 

Right now I'm doing a session id extraction and a GET call to get the url. Is there a better way? 

Thanks! :)

bootstrap online

unread,
Aug 27, 2014, 8:35:40 AM8/27/14
to Aish, appium-...@googlegroups.com
driver.current_url
> --
> http://appium.io
> ---
> You received this message because you are subscribed to the Google Groups
> "Appium-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to appium-discus...@googlegroups.com.
> Visit this group at http://groups.google.com/group/appium-discuss.
> For more options, visit https://groups.google.com/d/optout.

Aish

unread,
Aug 27, 2014, 9:08:57 AM8/27/14
to appium-...@googlegroups.com, ash.da...@gmail.com
I'm getting undefined method `current_url' for #<Appium::Driver:0x007fd78a2221a8> (NoMethodError)

bootstrap online

unread,
Aug 27, 2014, 9:11:48 AM8/27/14
to Aish, appium-...@googlegroups.com
you could try:

$driver.driver.current_url

Aish

unread,
Aug 28, 2014, 7:21:00 AM8/28/14
to appium-...@googlegroups.com, ash.da...@gmail.com
Works! Thanks! Any reason why I need to traverse this extra level? 

bootstrap online

unread,
Aug 28, 2014, 8:52:03 AM8/28/14
to Aish, appium-...@googlegroups.com
I'm not sure. It depends on how your code is setup. current_url is
defined on the selenium driver which is a different driver from the
appium one. For me, "current_url" works unqualified.
Reply all
Reply to author
Forward
0 new messages