Switching driver to safari for Facebook login and back to iOS afterward?

583 views
Skip to first unread message

Timothy Brandt

unread,
Jun 2, 2014, 8:41:56 PM6/2/14
to appium-...@googlegroups.com
Hey Guys -

Is anyone successfully automating a Facebook login pop-up in Safari & switching back to an iOS driver to continue testing their app?

I was checking out this example, and I am not sure if it is still relevant for Appium 1.0 :

I also referenced these threads :

This is the script that I currently have :

I get the following error :

Failures:


  1) Login allows to log in using the correct credentials

     Failure/Error: Appium::Driver.new(caps: web_capabilities).start_driver

     Selenium::WebDriver::Error::WebDriverError:

       We don't have write access to /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.1.sdk/Applications/MobileSafari.app, please re-run authorize as timothybrandt

     # ./RevelIntegrationTest_sample.rb:45:in `setup_safari'

     # ./RevelIntegrationTest_sample.rb:64:in `block (2 levels) in <top (required)>'


Finished in 9.5 seconds (files took 0.27382 seconds to load)

1 example, 1 failure


Failed examples:



Anyone have a good example of how to set this up using Appium 1.0+ ?

Thanks

Timothy Brandt

unread,
Jun 2, 2014, 9:27:29 PM6/2/14
to appium-...@googlegroups.com
Alright - I got past the permissions errors using sudo authorize-ios

But, it looks like when I switch the to safari driver, it closes the iOS app and opens up safari in a separate window.
Is there anyway to keep these seamless, where my app pops open the Facebook login & I can use the driver to populate the login form?

Has anyone successfully encountered this issue? Thanks

Timothy Brandt

unread,
Jun 2, 2014, 11:13:44 PM6/2/14
to appium-...@googlegroups.com
Wait is this what I'm looking for?

http://appium.io/slate/en/master/?ruby#automating-hybrid-ios-apps

Is the Facebook login loaded in the web context?


Timothy Brandt

unread,
Jun 2, 2014, 11:48:38 PM6/2/14
to appium-...@googlegroups.com
I think I've got it :


puts "available_contexts"

puts available_contexts

puts "current_context"

puts current_context


################################


available_contexts

NATIVE_APP

WEBVIEW_1

current_context






Timothy Brandt

unread,
Jun 3, 2014, 1:06:01 AM6/3/14
to appium-...@googlegroups.com
Yep, that was it. I just needed to change the context to WEBVIEW.
I was unaware about the whole context thing.

I'll leave this thread here in case anyone else is as oblivious as I was.

Isaac Murchie

unread,
Jun 3, 2014, 11:48:10 AM6/3/14
to Timothy Brandt, appium-...@googlegroups.com
Thanks for this Timothy! It was both entertaining and instructive.

Cheers,
Isaac.


--
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.

Timothy Brandt

unread,
Jun 3, 2014, 2:56:26 PM6/3/14
to appium-...@googlegroups.com, timothy...@gmail.com
Yes - 
My stream of consciousness is often entertaining.
Having no previous experience w/ Selenium or integration testing at all, and only 6 months of iOS dev experience,
I came into this missing that pool of assumed knowledge most of your audience probably has.

So, it took me a while to just to find heads or tails w/ all the boilerplate.
I think that I have a good handle on how everything works, now. 
Learned the hard way, of course.

Timothy Brandt

unread,
Jun 4, 2014, 3:34:39 AM6/4/14
to appium-...@googlegroups.com, timothy...@gmail.com
Ok - here's another one.
It looks like I can only call available_contexts once within my spec script.
The second time, the script freezes up or returns null.

Any thoughts?

Jonathan Lipps

unread,
Jun 4, 2014, 4:13:05 PM6/4/14
to Timothy Brandt, appium-...@googlegroups.com
If the actual app changes, then this will not be possible on iOS. It would be possible if the FB login is in a webview embedded in your app.

App switching is unfortunately not possible with iOS

Timothy Brandt

unread,
Jun 4, 2014, 4:53:00 PM6/4/14
to Jonathan Lipps, appium-...@googlegroups.com
Hey Jonathon -

So, you are about the 5th person to mention that I should be using a webview embedded in my app for the login.
I believe that I just plugged in face books example. Any advice on where I can find out how to update our app's login to have an embedded web view?

Thanks

Jonathan Lipps

unread,
Jun 4, 2014, 8:12:45 PM6/4/14
to Timothy Brandt, appium-...@googlegroups.com
Sorry, I'm not super familiar with how things actually work on the FB integration side--I just know what's testable on the iOS side, and Apple doesn't allow us to maintain an automation context if your app switches to another one :-/

Timothy Brandt

unread,
Jun 4, 2014, 8:18:43 PM6/4/14
to Jonathan Lipps, appium-...@googlegroups.com
Hmmm ... but I am able to switch to the WEBVIEW & back to the NATIVE_APP view just fine in my test.

The problem is that when I launch a new driver for the second test. I am unable to query or switch contexts.

Make sense?

Jonathan Lipps

unread,
Jun 5, 2014, 1:13:11 PM6/5/14
to Timothy Brandt, appium-...@googlegroups.com

Timothy Brandt

unread,
Jun 5, 2014, 1:21:07 PM6/5/14
to Jonathan Lipps, appium-...@googlegroups.com
That's the issue that I opened that Isaac is checking out.

Jonathan Lipps

unread,
Jun 5, 2014, 1:43:54 PM6/5/14
to Timothy Brandt, appium-...@googlegroups.com
Sounds like it's the one then :-)
Reply all
Reply to author
Forward
0 new messages