2

I want to test sharing functionality of an app but I have no idea how to handle android dialog "Complete action using" (Facebook, Gmail etc.)
When I use query("*") it is returning an empty set of fields.
Is there any way to handle such system dialogs using Calabash or any other way to test such functionality as sharing?

I am running my tests on physical device.

Edit: If there is no way to check whether the dialog has been opened or not, then maybe it is possible using adb shell or something like that?

kjuri
  • 158
  • 1
  • 10

1 Answers1

1

It's not a very elegant solution but you can simulate screen touches using adb. There is an answer that covers it here - simulating touch using ADB

Edit: Adding some details on using adb to dump a file of all of the UI elements.

In the android sdk in the platforms/android-L folder there is a tool called uiautomater.jar that adb can use to run tests (though I've never used it for that) and to dump an xml file of the visible elements.

adb shell uiautomator dump test.xml

will create the xml file (on the device not your computer) that you could then look through in your code to check for the pop up you want. If you want to interact with the pop up then you can use the coordinates given in the xml dump to pick which one you want and use an adb touch event to click it.

Not a pretty solution but hopefully not too difficult to work into your tests :)

Community
  • 1
  • 1
alannichols
  • 1,496
  • 1
  • 10
  • 20
  • I have already found some solutions about touching elements via adb, but I still do not know if it is possible to "simply" (it is not that simple as I can see) check if dialog system is opened - that's the main goal of test I am writing. But still many thanks for the link you have provided - I have read many interesting things :) – kjuri Jul 31 '14 at 14:34
  • Sorry, I didn't see your edit. Again it isn't a pretty solution but you can make a dump of all of the visible ui elements to an xml file and when search the file for the pop up. I'll edit my answer to include some details. – alannichols Aug 01 '14 at 10:12
  • Many thanks! It worked for me :) That's the code I have used inside step definition: `system("adb shell uiautomator dump /storage/emulated/legacy/test.xml")` `system("adb pull /storage/emulated/legacy/test.xml ~")` `unless system("grep -e 'Facebook' ~/test.xml") raise "'Share' button doesn\'t work'" end` – kjuri Aug 01 '14 at 11:04