jraska / Falcon

Take Android screenshots with Falcons bright eye!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

FalconSpoon dialog screenshot

hansvdg opened this issue · comments

When writing UI tests with espresso the captured FalconSpoon screenshot does not include the dialog I expect to be there.

Open Activity
Trigger dialog (AlertDialog.create...show());
verify that the dialog is present with:
onView(withText("hello dialog").check(matches(isDisplayed()));
FalconSpoon.screenshot(getActivity(), "Dialog_test");

Hi, I will try it during weekend. First thing which comes to my mind is maybe the dialog is not visible yet, because it take some times before the dialog appears in UI. You can check my idea with postponing screenshot capture for a second. Otherwise I will do it myself later.

Hi, I tried a thread.sleep(2000), but that didn't help.
The dialog should be instantly visible, it is triggered as part of the screen startup and there are no animations running on the device.

Hi, ok thank you, is there maybe anything unusual about your dialog? Do you use any library or custom dialog displaying or you just simply call system Alert dialog with message and title? I am trying to gather more information, because I believe it normally works for dialogs, so I am trying to find the difference in your case.

Hi, it is just a regular system AlertDialog with title, message and buttons.

Hi, that is weird, I will double check it when I will find some time, but AlertDialogs are generally working fine, so I believe it should be fine, but obviously its not.

Another idea: When I look at the code you posted above, could it be that getActivity() returns different activity then is currently at the top of Activity stack? It could happen for example when some of your tested activities calls startActivity() test runs fine, but the screenshot will not capture the top most Activity.

Hello, I wrote sample unit test with your scenario described and everything works fine.
Please find example test here.

I also updated Spoon dependency so you can try new Falcon version 1.0.1.

Hi,

The test works on both device and emulator and I could create a similar scenario in my app to get it to work.
That is, press a button to show a dialog and capture a screenshot.
If the dialog is triggered in the startup of the activity (in my case in response to a mocked api call) the dialog is not in the screenshot.
I think it has something to do with timing, but cannot yet find out why.

Thanks for creating a test scenario and thinking for solutions.

No problem.

Good luck with finding the solution. I will close the issue now.