Alert.Accept() being called Automatically after Appium Update

1,025 views
Skip to first unread message

Roopesh

unread,
Jul 25, 2013, 9:17:18 PM7/25/13
to appium-...@googlegroups.com
Hi,

I pulled latest code from GitHub and ran my application which messed up my automation.

When there is a Alert popup, its being accepted automatically(Pressing OK") and when my code below
tries to handle the Alert its failing(as there is no Pop up).



Alert alert = driver.switchTo().alert();

Thread.sleep(4000);

if(alert!=null

{

Assert.assertEquals(alert.getText(), "“XXXX” Would Like to Use Your Current Location");

alert.dismiss();

}


Has anyone encountered this Problem ?

Vic Wong

unread,
Jul 25, 2013, 9:52:56 PM7/25/13
to appium-...@googlegroups.com
This sounds really similar to what I'm seeing with alerts and it may be the cause of the problem I posted here:

When I watch the simulator, the alert dismiss button is automatically pressed, then when I try to press it in my code, there is an error.

Jonathan Lipps

unread,
Jul 26, 2013, 12:07:18 AM7/26/13
to Roopesh, appium-...@googlegroups.com
Appium now accepts Location Services popups automatically. If you want to disable this, pass a desiredCap of useLocationServices: false

--
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/groups/opt_out.
 
 

Roopesh

unread,
Jul 26, 2013, 12:09:36 AM7/26/13
to appium-...@googlegroups.com, Roopesh
Thanks Jonathan, Could you provide some code snippet.

Jonathan Lipps

unread,
Jul 26, 2013, 12:11:09 AM7/26/13
to Roopesh, appium-...@googlegroups.com
Add a desired capability with the name 'useLocationServices' and value false.

If a Java person wants to translate that into a code snippet, go for it! I'm not sure how to do that in Java.

Dan Dover

unread,
Jul 26, 2013, 12:41:24 AM7/26/13
to Jonathan Lipps, Roopesh, appium-...@googlegroups.com
How about something to disable Appium from handling all popups automatically?  Assuming support for others is coming…Our test suite has tests for all the alerts from services we use so it'd be nice to not have to disable them one at a time as Appium adds automagic handling…

In the meantime, thanks for adding the cap…I'll add it in set to false.  I assume this means Appium won't interact with the alert – setting it to false won't click "don't allow"?

Vic Wong

unread,
Jul 26, 2013, 1:45:31 AM7/26/13
to appium-...@googlegroups.com, Roopesh
Is it possible that this auto-dismiss code is dismissing alerts that its not supposed to, or otherwise interfering with them? 

I have a number of tests that interact with alerts (that are NOT location services alerts) and they are closing themselves and exiting instruments prematurely starting on version 0.8.1. 

The problem persists even if I set useLocationServices to false, so something is definitely amiss.

-v

Jonathan Lipps

unread,
Jul 26, 2013, 12:06:39 PM7/26/13
to Vic Wong, appium-...@googlegroups.com, Roopesh
Sounds like something broke then. We definitely aren't intending to automatically dismiss random popups.

Jonathan Lipps

unread,
Jul 26, 2013, 12:15:17 PM7/26/13
to Vic Wong, appium-...@googlegroups.com, Roopesh
I just ran appium's alert tests and the popup was not auto-accepted or auto-cancelled.

On Jul 25, 2013, at 10:45 PM, Vic Wong <vic...@gmail.com> wrote:

Jonathan Lipps

unread,
Jul 26, 2013, 12:19:13 PM7/26/13
to Vic Wong, appium-...@googlegroups.com, Roopesh
All the same, I just committed this change:


In order to sidestep any possible issues with alert.name() not returning a string or some such.

Can you pull from master and retry?

On Jul 25, 2013, at 10:45 PM, Vic Wong <vic...@gmail.com> wrote:

Vic Wong

unread,
Jul 26, 2013, 12:30:43 PM7/26/13
to appium-...@googlegroups.com, Vic Wong, Roopesh
Looks like that change addressed the issue in at least one case. I'll give it a run on the full test suite and let you know if there's anything else wrong.

Thanks Jonathan!

-v

Ling-Yi Kung

unread,
Jul 29, 2013, 5:28:17 PM7/29/13
to appium-...@googlegroups.com, Roopesh
Hello! I'm having a problem that's related - the app I'm testing has a Location Services popup immediately after launching (for the app to run, location must be enabled). However, I'm getting an Instruments error because the app is not frontmost:

info: [INST] 2013-07-29 21:12:23 +0000 Default: Instruments shell user: lkung
info: [INST] 2013-07-29 21:12:25 +0000 Default: Found node using `which node`: /usr/local/bin/node
info: [INST] 2013-07-29 21:12:35 +0000 Fail: Could not start script, target application is not frontmost.
       Instruments Trace Complete (Duration : 15.988870s; Output : /Users/lkung/Documents/appium/instrumentscli0.trace)

Is there something I'm missing? I would like the popup to be accepted, but the Appium session is not even starting.

info: [INSTSERVER] Instruments exited with code 0
error: Instruments did not launch successfully, failing session
error: Failed to start an Appium session, err was: Instruments did not launch successfully--please check your app paths or bundle IDs and try again
info: Responding to client with error: {"status":6,"value":{"message":"A session is either terminated or not started","origValue":"Instruments did not launch successfully--please check your app paths or bundle IDs and try again"},"sessionId":"b988bc97-a642-4cb4-b2100-12a8ab70d754"}

On Thursday, July 25, 2013 9:07:18 PM UTC-7, Jonathan Lipps wrote:
Reply all
Reply to author
Forward
0 new messages