Handle browser pop ups in windows/linux

195 views
Skip to first unread message

techi...@gmail.com

unread,
Nov 4, 2014, 12:34:06 PM11/4/14
to seleniu...@googlegroups.com
Hello All,

I have attached screen shot of browser pop up , it will open on click of button in my application. I have seen in different forum people mentioned using AutoIT lib we can handle windows based pop up. 

AutoIT lib will work in linux also or is it specific to windows?


thanks
popup.jpg

PeterJeffreyGale

unread,
Nov 4, 2014, 1:54:56 PM11/4/14
to seleniu...@googlegroups.com
AutoIT is for windows only, though the Java Robot class, for example, would work on both Windows and Linux, if you use Java.

However, yours looks like a javascript popup that the built-in Selenium "alert" functionality should be axle go handle.

Jim Evans

unread,
Nov 4, 2014, 1:58:09 PM11/4/14
to seleniu...@googlegroups.com
AutoIT is a Windows-only solution, which is one reason I never, ever recommend it. It's likely this dialog can be handled by the Alert interface of WebDriver, if it's brought up by the JavaScript confirm() function. On the other hand, if it's just rendered HTML, you can simply handle it via standard WebDriver element manipulation.

techi...@gmail.com

unread,
Nov 4, 2014, 3:26:00 PM11/4/14
to seleniu...@googlegroups.com

Application was using java script  confirm("Press a button!") method, for pop up to come with OK and Cancel buttons


I tried to use below code but it is failing.

driver.switchTo().alert().accept();


Error

 NoAlertPresentException: No alert is present (WARNING: The server did not provide any stacktrace information)


Any suggestions please

PeterJeffreyGale

unread,
Nov 4, 2014, 3:42:58 PM11/4/14
to seleniu...@googlegroups.com
 confirm("Press a button!")  sounds like a custom javascipt method.

Cam you attach the full html of the page?

techi...@gmail.com

unread,
Nov 4, 2014, 3:54:44 PM11/4/14
to seleniu...@googlegroups.com

it is regular java script method, execute below link from Firefox we will get the popup





On Tuesday, November 4, 2014 12:34:06 PM UTC-5, techi...@gmail.com wrote:

PeterJeffreyGale

unread,
Nov 4, 2014, 6:04:31 PM11/4/14
to seleniu...@googlegroups.com
Hmmn ... without writing the myself, it looks like that should work, but the w3schools page seems a but slow to respond on my PC - are you sure the alert has appreared by the time your code to accept it appears?

And I'm a bit puzzled why the alert message on that page is different to the one you mentioned in your first post?

CH!NN@ K

unread,
Nov 5, 2014, 12:34:59 AM11/5/14
to seleniu...@googlegroups.com

---
Thanks & Regards,
Purushotham Karimbedu,
Web Developer and QA Engineer,
Personal Website : http://techlearn.in
Phone no :9000109120.

On Wed, Nov 5, 2014 at 4:34 AM, PeterJeffreyGale <peterjef...@hotmail.co.uk> wrote:
Hmmn ... without writing the myself, it looks like that should work, but the w3schools page seems a but slow to respond on my PC - are you sure the alert has appreared by the time your code to accept it appears?

And I'm a bit puzzled why the alert message on that page is different to the one you mentioned in your first post?

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/c3fff286-ff85-483e-ba0b-81741a8d6134%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

PeterJeffreyGale

unread,
Nov 5, 2014, 2:52:14 AM11/5/14
to seleniu...@googlegroups.com
Uttam

The OP has used what seems to be he right code ... the issue now is why it doesn't work.

techi...@gmail.com

unread,
Nov 5, 2014, 8:34:46 AM11/5/14
to seleniu...@googlegroups.com
@Peter

And I'm a bit puzzled why the alert message on that page is different to the one you mentioned in your first post?


The attached one is from my application which is using the same Java script confirm method , instead of attaching whole html i thought to give you example which is in w3schools.






On Tuesday, November 4, 2014 12:34:06 PM UTC-5, techi...@gmail.com wrote:

PeterJeffreyGale

unread,
Nov 5, 2014, 8:48:02 AM11/5/14
to seleniu...@googlegroups.com
Ok ...

I just run a test on that W3Schools page using:

  driver.switchTo().alert().accept();  

... and it worked for me.

For the code you have which is failing, are you running it against the W3Schools page or your own application?

techi...@gmail.com

unread,
Nov 5, 2014, 11:51:08 AM11/5/14
to seleniu...@googlegroups.com
Yes it is working fine now.

In debug mode i verified there wasn't enough time to click confirmation messages , i have added time now it works fine..

Thank you all for your help



On Tuesday, November 4, 2014 12:34:06 PM UTC-5, techi...@gmail.com wrote:
Reply all
Reply to author
Forward
0 new messages