How to access Facebook login dialog with Calabash on Android

1,053 views
Skip to first unread message

will.wilson

unread,
Jun 6, 2012, 3:19:44 PM6/6/12
to calabash...@googlegroups.com
I am testing an app that displays a Facebook page.  The first time a user goes to this page, he must login to Facebook (this is required by Facebook).  To accomplish this, the app brings in the Facebook dialog, which has a field for Email and a field for Password (among other things).  In my automated test with Calabash, I can get it to bring up the dialog, and if I take a screenshot it displays correctly.  But I am not able to enter text in the input fields or press any buttons.  Calabash does not even recognize any text in the dialog.  Has anyone found a solution to this scenario?

Will

Jonas Maturana Larsen

unread,
Jun 6, 2012, 5:55:22 PM6/6/12
to calabash...@googlegroups.com
Hi Will,

Is the Facebook page part of your app or external e.g. part of the Facebook app or a website?

-- 
Jonas Maturana Larsen
Co-founder lesspainful.com
Phone: +45 40 16 75 77
Skype: jonasmaturana

will.wilson

unread,
Jun 6, 2012, 6:13:08 PM6/6/12
to calabash...@googlegroups.com
The app calls the Facebook API, which returns the login screen.  The user stays within the app - it never goes to an external app or external website. 

Thanks for your help!

Will

Jonas Maturana Larsen

unread,
Jun 6, 2012, 6:23:47 PM6/6/12
to calabash...@googlegroups.com
Alright.

In which ways have you tried to enter text and press the buttons?

Could you by any chance provide an example app?

-- 
Jonas Maturana Larsen
Co-founder lesspainful.com
Phone: +45 40 16 75 77
Skype: jonasmaturana

will.wilson

unread,
Jun 6, 2012, 7:04:08 PM6/6/12
to calabash...@googlegroups.com
I have tried to enter text in the fields with commands such as:

Then I enter "myfacebooklogin" into input field number 1
When I run it, it gets an error on that step: EditText with index 0 is not available (RunTimeError)
I get the same error if I try with input field number 0 or 2 (index -1 and 1, respectively)

Then I enter "myfacebooklogin" as "Email"
When I run it, it gets an error on that step: No view found with content description: 'Email' (RunTimeError)
I get the same thing for: Then I enter "myfacebooklogin" as "Email or Phone"

Then I enter "myfacebooklogin" into "Email"
When I run it, it gets an error on that step: No view found with content description: 'Email' (RunTimeError)
I get the same thing for: Then I enter "myfacebooklogin" as "Email or Phone"

I have also tried these commands and failed:

Then I press the "Log In" button
When I run it, it gets an error on that step: Button with the text: Log In is not found! (RunTimeError)

Then I see "You must log in first"
When I run it, it gets an error on that step: Text 'You must log in first' was not found (RunTimeError)

Unfortunately I am not able to provide the app, but I did upload a screenshot of the facebook dialog screen.

Will
droid_facebook-dialog-screen.png

Jonas Maturana Larsen

unread,
Jun 6, 2012, 7:23:26 PM6/6/12
to calabash...@googlegroups.com
Try to look at hierarchyviewer when the login screen is showing.
What kind of UI elements do you see?

-- 
Jonas Maturana Larsen
Co-founder lesspainful.com
Phone: +45 40 16 75 77
Skype: jonasmaturana

Attachments:
- droid_facebook-dialog-screen.png

darshan gurudev

unread,
Jan 18, 2013, 12:27:26 AM1/18/13
to calabash...@googlegroups.com
Hi Jonas Maturana Larsen 

Please could you share the details for facebook login for a hybrid application.
As mentioned above the  the app involves facebook login integrated to it. I have given the details below:

Hi Its a hybrid application as I entered the facebook log in this is what I tried :
Then I login as “abc”
performAction(‘press’,email);
performAction(‘enter_text_into_named_field’,email, “edittext_email”) #username is the value and “edittext_email” is the identifier for the field
performAction(‘press_button_with_text’, “Log in”) #This is pressing the button with the text of “button_sign_in”

I get a lexical error , I have attached the log for the same below :

Lexing error on line 46: ‘ performAction(‘press’,email);’. Seehttp://wiki.github.com/cucumber/gherkin/lexingerror for more information. (Gherkin::Lexer::LexingError)
/Users/darshan/.gem/ruby/1.8/gems/gherkin-2.11.5/lib/gherkin/lexer/i18n_lexer.rb:22:in `scan’
/Users/darshan/.gem/ruby/1.8/gems/gherkin-2.11.5/lib/gherkin/lexer/i18n_lexer.rb:22:in `scan’
/Users/darshan/.gem/ruby/1.8/gems/gherkin-2.11.5/lib/gherkin/parser/parser.rb:32:in `parse’
/Library/Ruby/Gems/1.8/gems/cucumber-1.2.1/bin/../lib/cucumber/feature_file.rb:37:in `parse’
/Library/Ruby/Gems/1.8/gems/cucumber-1.2.1/bin/../lib/cucumber/runtime/features_loader.rb:28:in `load’
/Library/Ruby/Gems/1.8/gems/cucumber-1.2.1/bin/../lib/cucumber/runtime/features_loader.rb:26:in `each’
/Library/Ruby/Gems/1.8/gems/cucumber-1.2.1/bin/../lib/cucumber/runtime/features_loader.rb:26:in `load’
/Library/Ruby/Gems/1.8/gems/cucumber-1.2.1/bin/../lib/cucumber/runtime/features_loader.rb:14:in `features’
/Library/Ruby/Gems/1.8/gems/cucumber-1.2.1/bin/../lib/cucumber/runtime.rb:170:in `features’
/Library/Ruby/Gems/1.8/gems/cucumber-1.2.1/bin/../lib/cucumber/runtime.rb:46:in `run!’
/Library/Ruby/Gems/1.8/gems/cucumber-1.2.1/bin/../lib/cucumber/cli/main.rb:43:in `execute!’
/Library/Ruby/Gems/1.8/gems/cucumber-1.2.1/bin/../lib/cucumber/cli/main.rb:20:in `execute’

Jonas Maturana Larsen

unread,
Jan 20, 2013, 4:18:35 PM1/20/13
to calabash...@googlegroups.com
Hi Darshan,

Welcome to the group.

First you have to understand that in the feature files you put all the human readable stuff while all the code goes in a Ruby file in the step_definitions folder.
I would recommend that you read this wiki entry: https://github.com/calabash/calabash-ios/wiki/03-Writing-custom-steps

All the best,
Jonas

DZ

unread,
Jul 9, 2014, 9:48:10 AM7/9/14
to calabash...@googlegroups.com
hi will, i am having almost the same issue!.
regarding your issue, the page you are seeing is a webview and you can get the content by using the query command for webviews
the commands there will help you get data from the html inside the webview.
in order to view the source html itself i suggest you use the chrome dev tool.
to view webviews it requires your device  to run android kitkat and to insert a special line inside your code to enable webview debugging
you can see how to use it in this link https://developer.chrome.com/devtools/docs/remote-debugging

my problem is a bit different, in your case it seems that the facebook app is not installed on your device. if it is installed, you will get a different webview asking you to sign in. the issue here is that this webview is totally invisble when quering it in calabash or trying to find it with the devtool. i would appriciate any help if someone found out how to bypass this.

Doron

Steve Momcilovic

unread,
Mar 30, 2015, 6:34:19 PM3/30/15
to calabash...@googlegroups.com
/bump

I am encountering this as well. The Facebook login button presents the User with a login page and Calabash query functions do not detect any elements. The UI Automator View is able to capture the FB login page, but I have not had success circumventing the issue in this way either. The elements found from the UI Automator View do not work on the page.

Is there a known workaround for scenarios like this?

Jani Jegoroff

unread,
Mar 30, 2015, 7:19:10 PM3/30/15
to calabash...@googlegroups.com
You can use adb shell commands or utilise monkeyrunner.

Steve Momcilovic

unread,
Mar 30, 2015, 8:08:03 PM3/30/15
to calabash...@googlegroups.com
Hello and thanks for your reply!

I'm not familiar with monkeyrunner. Would this interact well with automation done in ruby? I can't tell. Would it be able to click on the correct elements across 30+ devices?

adb shell commands? Are you thinking of maybe granting permissions to the FB app? That could possibly solve an issue on that.



--
You received this message because you are subscribed to a topic in the Google Groups "calabash-android" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/calabash-android/7AhqqC1dyvY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to calabash-andro...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jani Jegoroff

unread,
Mar 31, 2015, 6:45:44 AM3/31/15
to calabash...@googlegroups.com
You can perform coordinate based touch gestures through adb shell commands:

adb shell input tap x y

Enable Settings > Developer options > Pointer location to see exact coordinates.

Never used monkeyrunner either but I will try it out and come back with an example.

Jani Jegoroff

unread,
Mar 31, 2015, 7:01:19 AM3/31/15
to calabash...@googlegroups.com
Equivalent example for previous post using monkeyrunner:

Janis-iMac:~ janijegoroff$ adb devices
List of devices attached
HT35DW918545 device

Janis-iMac:~ janijegoroff$ monkeyrunner
Jython 2.5.3 (2.5:c56500f08d34+, Aug 13 2012, 14:54:35)
[Java HotSpot(TM) 64-Bit Server VM (Oracle Corporation)] on java1.8.0_25
>>> from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice
>>> device = MonkeyRunner.waitForConnection()
>>> device.touch(280, 1230, 'DOWN_AND_UP')
>>>

Of course you want to rather use text/ids than coordinates to perform touch gestures. Don't know yet how to do that...

Jani Jegoroff

unread,
Mar 31, 2015, 10:28:32 AM3/31/15
to calabash...@googlegroups.com
One more example utilising AndroidViewClient so that button is touched by id: https://gist.github.com/JaniJegoroff/4500c8c392004c0adff7

Steve Momcilovic

unread,
Apr 3, 2015, 6:32:13 PM4/3/15
to calabash...@googlegroups.com
Thanks for these answers! I was able to use adb pretty quickly, but yes, I will need to be able to use button ids or text. I'm very likely to use your python AndroidViewClient suggestion. I will have to report back to you when we automate those scenarios.

Thanks!
Steve
Reply all
Reply to author
Forward
0 new messages