Acceptance test for login with Facebook Connect

309 views
Skip to first unread message

alexhancock

unread,
Sep 6, 2012, 4:41:36 PM9/6/12
to frank-...@googlegroups.com
Hi,

Has anyone here tried to write Frank acceptance tests which test login with Facebook Connect on the iPhone Simulator? 

We have a feature spec running which launches the app, clicks the "Login with Facebook" button and then our app goes into the background, Safari opens with the Facebook login dialog and we lose control. We are trying to brainstorm a way we could get the tests to hang, and then run some script to click the "Ok" button on the facebook page and then come back to our app and continue our Frank tests. Has anyone dealt with this problem before?

Cheers,

Alex

kra Larivain

unread,
Sep 6, 2012, 6:52:31 PM9/6/12
to frank-...@googlegroups.com
I haven't personnaly dealt with this, but you could try using facebook's in app authentication.
It's based on a UIWebView, so it's not going to be trivially implemented, but at least you'll have a way out, rather than being stuck in safari with no Frank support whatsoever.

What's up with the latest and greatest SDK by the way?
Weren't they supposed to release an sdk that was much more objc based and much less web based? Worth taking a look if you have the luxury to pick your Facebook SDK version.

/kra

alexhancock

unread,
Sep 6, 2012, 9:29:47 PM9/6/12
to frank-...@googlegroups.com
They did release a new SDK, it's nice.

Found a (hacky) solution. We wrote an applescript which moves the iPhone Simulator to the top left-hand side of the display, waits a second and then generates a click event in the location we know the facebook "Okay" button will be. This function takes care of that...

def click_okay_button
    %x{osascript<<APPLESCRIPT
        tell application "iPhone Simulator"
            activate
        end tell

        tell application "System Events"
            tell process "iPhone Simulator"
                set the position of the first window to {1, 1, 1, 1}
                delay 1
                click at {300, 162}
            end tell
        end tell
    APPLESCRIPT}
end

And then in the test, we tap the login button, sleep for a little while to ensure the UI will be ready on the facebook page, and then run our applescript.

When /^I tap the "(.*?)" button$/ do |arg1|
    touch "view:'UIButton' marked:'Facebook Login Button@2x'"
    sleep 8.0
    click_okay_button();
end

The sleep hangs the cucumber process passed the point where it would normally exit when the app goes into the background.

Not pretty, but it works. :)

Alex

Pete Hodgson

unread,
Sep 6, 2012, 9:32:48 PM9/6/12
to frank-...@googlegroups.com, frank-...@googlegroups.com
Very creative!

Cheers,
Pete
--
Typed on a little bitty keyboard

brettlevine

unread,
Sep 25, 2012, 4:48:25 PM9/25/12
to frank-...@googlegroups.com
Yes, really clever.  Don't forget you have to enable access for assistive devices from the System Preferences Universal Access pane in order for this to work. 

Arun

unread,
Sep 26, 2012, 4:19:50 PM9/26/12
to frank-...@googlegroups.com
I am not sure if you guys got the answers for that. But in general, the
stringByEvaluatingJavaScriptFromString works magically. 

frankly_map("webView index:0", "stringByEvaluatingJavaScriptFromString:","$('##{id}').trigger('click');")

This has worked for me to get pass through for webviews.

-Arun

Camilo Lopez

unread,
Feb 8, 2013, 1:53:13 PM2/8/13
to frank-...@googlegroups.com
Arun,

How can you get the #id of the facebook connect button? Is there an easy way on the simulator?

Nandini Adiyodi

unread,
Feb 19, 2013, 4:28:02 PM2/19/13
to frank-...@googlegroups.com
Hey Arun , 
I have a similar issue , where i want to be able to enter my password and then submit the form to access a dropbox account in my app . 

I tried using 
frankly_map("webView index:0", "stringByEvaluatingJavaScriptFromString:","$('##{id}').trigger('click');")
But the click  does not seem to work .
Ideally i woud want to click on the password field and bring up the keyboard .
Was this the behaviour you achieved with the above code snippet ? 

Thanks
Nandini

James Thomason

unread,
May 6, 2013, 12:17:05 PM5/6/13
to frank-...@googlegroups.com
Was anyone able to get past this?  I've tried the frankly_map("webView index:0", "stringByEvaluatingJavaScriptFromString:","$('##{id}').trigger('click');") line as well without luck.  Any help would be appreciated.

Thanks,

Jamie
Reply all
Reply to author
Forward
0 new messages