How to handle Random popups in Selenium WebDriver ?

classic Classic list List threaded Threaded
17 messages Options
Reply | Threaded
Open this post in threaded view
|

How to handle Random popups in Selenium WebDriver ?

Sumit Mishra

Hello,

When running my testscripts, sometimes an popups appears. The problem is that the popup is totally random and I have no way of knowing when it's going to appear.

I need to know what the popups says, so this can be fixed. Can someone tell me how to handle such an popup, so that i can see what the popup says?

Thanks
Sumit Mishra

--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/fd4501c2-d8d2-44bb-8172-af098ff8cb15%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

RE: How to handle Random popups in Selenium WebDriver ?

Xiang Dong
what kind of popup it is? if it is alert/confirm/prompt, you can override those popup by writing javascript (via web driver) to your UTA page, you can disable those popup and retrieve the content in the popup and writing it to an page element (you may dynamic generate an html element and attach it to the end of html body, the javascript can be injected by web driver).
before run each test step, retrieve the content from this page element, you will get content of it.

window._alert = window.alert;
window.alert = function(str) {
     document.getElementById('popup_content').value=str;
     return false;
}

But something should be aware of, with this javascript, all your alert dialog will not displayed.

I didn't test your case, but above javascript should works.

Best Regards,
--david


Date: Mon, 23 Jun 2014 01:01:56 -0700
From: [hidden email]
To: [hidden email]
Subject: [selenium-users] How to handle Random popups in Selenium WebDriver ?


Hello,

When running my testscripts, sometimes an popups appears. The problem is that the popup is totally random and I have no way of knowing when it's going to appear.

I need to know what the popups says, so this can be fixed. Can someone tell me how to handle such an popup, so that i can see what the popup says?

Thanks
Sumit Mishra

--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/fd4501c2-d8d2-44bb-8172-af098ff8cb15%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/BLU174-W20FB52DABB2B5FD866FF15901F0%40phx.gbl.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to handle Random popups in Selenium WebDriver ?

Oscar Rieken
if you are testing a site you should probably know the mechanics behind the popup. I would probably talk to your team and see when and why it happens then you will know when you have to check for it or how to avoid it


On Mon, Jun 23, 2014 at 4:55 AM, DongXiang <[hidden email]> wrote:
what kind of popup it is? if it is alert/confirm/prompt, you can override those popup by writing javascript (via web driver) to your UTA page, you can disable those popup and retrieve the content in the popup and writing it to an page element (you may dynamic generate an html element and attach it to the end of html body, the javascript can be injected by web driver).
before run each test step, retrieve the content from this page element, you will get content of it.

window._alert = window.alert;
window.alert = function(str) {
     document.getElementById('popup_content').value=str;
     return false;
}

But something should be aware of, with this javascript, all your alert dialog will not displayed.

I didn't test your case, but above javascript should works.

Best Regards,
--david


Date: Mon, 23 Jun 2014 01:01:56 -0700
From: [hidden email]
To: [hidden email]
Subject: [selenium-users] How to handle Random popups in Selenium WebDriver ?



Hello,

When running my testscripts, sometimes an popups appears. The problem is that the popup is totally random and I have no way of knowing when it's going to appear.

I need to know what the popups says, so this can be fixed. Can someone tell me how to handle such an popup, so that i can see what the popup says?

Thanks
Sumit Mishra

--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/fd4501c2-d8d2-44bb-8172-af098ff8cb15%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/BLU174-W20FB52DABB2B5FD866FF15901F0%40phx.gbl.

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

--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CACuB3fYoy%2B2ZYV8jDSOyUNnMRogYZoA9o9yCDz%3D8K29GVRoCog%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to handle Random popups in Selenium WebDriver ?

amritab85
In reply to this post by Xiang Dong
Hi David,

I am facing similar issue.. Could you please let me know code if it is an alert, something like this: alert("You have a new message");

On Monday, June 23, 2014 at 2:27:36 PM UTC+5:30, David Dong wrote:
what kind of popup it is? if it is alert/confirm/prompt, you can override those popup by writing javascript (via web driver) to your UTA page, you can disable those popup and retrieve the content in the popup and writing it to an page element (you may dynamic generate an html element and attach it to the end of html body, the javascript can be injected by web driver).
before run each test step, retrieve the content from this page element, you will get content of it.

window._alert = window.alert;
window.alert = function(str) {
     document.getElementById('popup_content').value=str;
     return false;
}

But something should be aware of, with this javascript, all your alert dialog will not displayed.

I didn't test your case, but above javascript should works.

Best Regards,
--david


Date: Mon, 23 Jun 2014 01:01:56 -0700
From: <a href="javascript:" target="_blank" gdf-obfuscated-mailto="ckYLv75jTCUJ" rel="nofollow" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">sumit.m...@...
To: <a href="javascript:" target="_blank" gdf-obfuscated-mailto="ckYLv75jTCUJ" rel="nofollow" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">seleniu...@googlegroups.com
Subject: [selenium-users] How to handle Random popups in Selenium WebDriver ?


Hello,

When running my testscripts, sometimes an popups appears. The problem is that the popup is totally random and I have no way of knowing when it's going to appear.

I need to know what the popups says, so this can be fixed. Can someone tell me how to handle such an popup, so that i can see what the popup says?

Thanks
Sumit Mishra

--
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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="ckYLv75jTCUJ" rel="nofollow" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">selenium-user...@googlegroups.com.
To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="ckYLv75jTCUJ" rel="nofollow" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">seleniu...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/selenium-users/fd4501c2-d8d2-44bb-8172-af098ff8cb15%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href='https://groups.google.com/d/msgid/selenium-users/fd4501c2-d8d2-44bb-8172-af098ff8cb15%40googlegroups.com?utm_medium\75email\46utm_source\75footer';return true;" onclick="this.href='https://groups.google.com/d/msgid/selenium-users/fd4501c2-d8d2-44bb-8172-af098ff8cb15%40googlegroups.com?utm_medium\75email\46utm_source\75footer';return true;">https://groups.google.com/d/msgid/selenium-users/fd4501c2-d8d2-44bb-8172-af098ff8cb15%40googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href='https://groups.google.com/d/optout';return true;" onclick="this.href='https://groups.google.com/d/optout';return true;">https://groups.google.com/d/optout.

--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/da786c04-3237-4cfd-9d09-bdf08a710c64%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

RE: How to handle Random popups in Selenium WebDriver ?

Xiang Dong
Hi,

In general, web driver will not notify your test code there is an alert dialog popup. the only way is try switch to the alert dialog, if no alert present, an exception will throw out. You can try catch the codes and continue check before any other web driver actions.

My codes below is override the basic behavior of native dialog, it will make the alert dialog not display.

--david


Date: Mon, 30 Mar 2015 00:35:42 -0700
From: [hidden email]
To: [hidden email]
Subject: Re: [selenium-users] How to handle Random popups in Selenium WebDriver ?

Hi David,

I am facing similar issue.. Could you please let me know code if it is an alert, something like this: alert("You have a new message");

On Monday, June 23, 2014 at 2:27:36 PM UTC+5:30, David Dong wrote:
what kind of popup it is? if it is alert/confirm/prompt, you can override those popup by writing javascript (via web driver) to your UTA page, you can disable those popup and retrieve the content in the popup and writing it to an page element (you may dynamic generate an html element and attach it to the end of html body, the javascript can be injected by web driver).
before run each test step, retrieve the content from this page element, you will get content of it.

window._alert = window.alert;
window.alert = function(str) {
     document.getElementById('popup_content').value=str;
     return false;
}

But something should be aware of, with this javascript, all your alert dialog will not displayed.

I didn't test your case, but above javascript should works.

Best Regards,
--david


Date: Mon, 23 Jun 2014 01:01:56 -0700
From: [hidden email]
To: seleniu...@googlegroups.com
Subject: [selenium-users] How to handle Random popups in Selenium WebDriver ?


Hello,

When running my testscripts, sometimes an popups appears. The problem is that the popup is totally random and I have no way of knowing when it's going to appear.

I need to know what the popups says, so this can be fixed. Can someone tell me how to handle such an popup, so that i can see what the popup says?

Thanks
Sumit Mishra

--
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/fd4501c2-d8d2-44bb-8172-af098ff8cb15%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/da786c04-3237-4cfd-9d09-bdf08a710c64%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/BLU174-W22C369DA87C9E50AF17CF090F50%40phx.gbl.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to handle Random popups in Selenium WebDriver ?

Mukesh otwani
In reply to this post by amritab85
Hi Amrita and David,

We can create a while statement which check if alert is present then it will capture alert message and close alert window.

Try below code and let me know if you finding any issue.

http://learn-automation.com/handle-alert-in-selenium-webdriver/

On Monday, March 30, 2015 at 1:07:37 PM UTC+5:30, Amrita B wrote:
Hi David,

I am facing similar issue.. Could you please let me know code if it is an alert, something like this: alert("You have a new message");

On Monday, June 23, 2014 at 2:27:36 PM UTC+5:30, David Dong wrote:
what kind of popup it is? if it is alert/confirm/prompt, you can override those popup by writing javascript (via web driver) to your UTA page, you can disable those popup and retrieve the content in the popup and writing it to an page element (you may dynamic generate an html element and attach it to the end of html body, the javascript can be injected by web driver).
before run each test step, retrieve the content from this page element, you will get content of it.

window._alert = window.alert;
window.alert = function(str) {
     document.getElementById('popup_content').value=str;
     return false;
}

But something should be aware of, with this javascript, all your alert dialog will not displayed.

I didn't test your case, but above javascript should works.

Best Regards,
--david


Date: Mon, 23 Jun 2014 01:01:56 -0700
From: [hidden email]
To: [hidden email]
Subject: [selenium-users] How to handle Random popups in Selenium WebDriver ?


Hello,

When running my testscripts, sometimes an popups appears. The problem is that the popup is totally random and I have no way of knowing when it's going to appear.

I need to know what the popups says, so this can be fixed. Can someone tell me how to handle such an popup, so that i can see what the popup says?

Thanks
Sumit Mishra

--
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 [hidden email].
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/selenium-users/fd4501c2-d8d2-44bb-8172-af098ff8cb15%40googlegroups.com?utm_medium=email&amp;utm_source=footer" rel="nofollow" target="_blank" onmousedown="this.href='https://groups.google.com/d/msgid/selenium-users/fd4501c2-d8d2-44bb-8172-af098ff8cb15%40googlegroups.com?utm_medium\75email\46utm_source\75footer';return true;" onclick="this.href='https://groups.google.com/d/msgid/selenium-users/fd4501c2-d8d2-44bb-8172-af098ff8cb15%40googlegroups.com?utm_medium\75email\46utm_source\75footer';return true;">https://groups.google.com/d/msgid/selenium-users/fd4501c2-d8d2-44bb-8172-af098ff8cb15%40googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" rel="nofollow" target="_blank" onmousedown="this.href='https://groups.google.com/d/optout';return true;" onclick="this.href='https://groups.google.com/d/optout';return true;">https://groups.google.com/d/optout.

--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/6bb85f79-21b7-4676-81a3-5a8d416f7512%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

RE: How to handle Random popups in Selenium WebDriver ?

Xiang Dong
sure it is a way, but it make the codes complicated, programmer need to check alert present and catch the exception before perform any action, in spite of it, it is not 100% percent works because between the check alert and perform action, there are still some time gap. alert dialog still has possibility to popup. the other way is capture exception for any web driver action, if there is an alert dialog, close it and re-perform the action.

considering it is a random alert dialog, there is no way to anticipate when the alert dialog popup. so, a dedicate logic to handle it is necessary.

Best Regards,
--david


Date: Tue, 31 Mar 2015 09:35:06 -0700
From: [hidden email]
To: [hidden email]
Subject: Re: [selenium-users] How to handle Random popups in Selenium WebDriver ?

Hi Amrita and David,

We can create a while statement which check if alert is present then it will capture alert message and close alert window.

Try below code and let me know if you finding any issue.

http://learn-automation.com/handle-alert-in-selenium-webdriver/

On Monday, March 30, 2015 at 1:07:37 PM UTC+5:30, Amrita B wrote:
Hi David,

I am facing similar issue.. Could you please let me know code if it is an alert, something like this: alert("You have a new message");

On Monday, June 23, 2014 at 2:27:36 PM UTC+5:30, David Dong wrote:
what kind of popup it is? if it is alert/confirm/prompt, you can override those popup by writing javascript (via web driver) to your UTA page, you can disable those popup and retrieve the content in the popup and writing it to an page element (you may dynamic generate an html element and attach it to the end of html body, the javascript can be injected by web driver).
before run each test step, retrieve the content from this page element, you will get content of it.

window._alert = window.alert;
window.alert = function(str) {
     document.getElementById('popup_content').value=str;
     return false;
}

But something should be aware of, with this javascript, all your alert dialog will not displayed.

I didn't test your case, but above javascript should works.

Best Regards,
--david


Date: Mon, 23 Jun 2014 01:01:56 -0700
From: [hidden email]
To: [hidden email]
Subject: [selenium-users] How to handle Random popups in Selenium WebDriver ?


Hello,

When running my testscripts, sometimes an popups appears. The problem is that the popup is totally random and I have no way of knowing when it's going to appear.

I need to know what the popups says, so this can be fixed. Can someone tell me how to handle such an popup, so that i can see what the popup says?

Thanks
Sumit Mishra

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/fd4501c2-d8d2-44bb-8172-af098ff8cb15%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/6bb85f79-21b7-4676-81a3-5a8d416f7512%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/BLU174-W2332D97D5431E9C15DFD3E90F30%40phx.gbl.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to handle Random popups in Selenium WebDriver ?

amritab85
Hi David,

Could you please let me know the "the other way is capture exception for any web driver action, if there is an alert dialog, close it and re-perform the action."

Also, do we have any way to default behaviour of alert() like we have way for window.alert (  ((JavascriptExecutor)driver).executeScript("window.alert = function(msg){};");)

Actually, I had created code for checking alert and take necessary actions. I have placed it at numerous places in the script but each time it executes it takes time. Also, there's no surety that at other places, message will not come.

I am really tired of this one..

Thanks!

On 1 April 2015 at 11:59, Xiang Dong <[hidden email]> wrote:
sure it is a way, but it make the codes complicated, programmer need to check alert present and catch the exception before perform any action, in spite of it, it is not 100% percent works because between the check alert and perform action, there are still some time gap. alert dialog still has possibility to popup. the other way is capture exception for any web driver action, if there is an alert dialog, close it and re-perform the action.

considering it is a random alert dialog, there is no way to anticipate when the alert dialog popup. so, a dedicate logic to handle it is necessary.

Best Regards,
--david


Date: Tue, 31 Mar 2015 09:35:06 -0700
From: [hidden email]
To: [hidden email]
Subject: Re: [selenium-users] How to handle Random popups in Selenium WebDriver ?


Hi Amrita and David,

We can create a while statement which check if alert is present then it will capture alert message and close alert window.

Try below code and let me know if you finding any issue.

http://learn-automation.com/handle-alert-in-selenium-webdriver/

On Monday, March 30, 2015 at 1:07:37 PM UTC+5:30, Amrita B wrote:
Hi David,

I am facing similar issue.. Could you please let me know code if it is an alert, something like this: alert("You have a new message");

On Monday, June 23, 2014 at 2:27:36 PM UTC+5:30, David Dong wrote:
what kind of popup it is? if it is alert/confirm/prompt, you can override those popup by writing javascript (via web driver) to your UTA page, you can disable those popup and retrieve the content in the popup and writing it to an page element (you may dynamic generate an html element and attach it to the end of html body, the javascript can be injected by web driver).
before run each test step, retrieve the content from this page element, you will get content of it.

window._alert = window.alert;
window.alert = function(str) {
     document.getElementById('popup_content').value=str;
     return false;
}

But something should be aware of, with this javascript, all your alert dialog will not displayed.

I didn't test your case, but above javascript should works.

Best Regards,
--david


Date: Mon, 23 Jun 2014 01:01:56 -0700
From: [hidden email]
To: [hidden email]
Subject: [selenium-users] How to handle Random popups in Selenium WebDriver ?


Hello,

When running my testscripts, sometimes an popups appears. The problem is that the popup is totally random and I have no way of knowing when it's going to appear.

I need to know what the popups says, so this can be fixed. Can someone tell me how to handle such an popup, so that i can see what the popup says?

Thanks
Sumit Mishra

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/fd4501c2-d8d2-44bb-8172-af098ff8cb15%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/6bb85f79-21b7-4676-81a3-5a8d416f7512%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "Selenium Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/selenium-users/Kt0lHgr4qf8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/BLU174-W2332D97D5431E9C15DFD3E90F30%40phx.gbl.

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

--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CAPjkdGH01Y8f%3DsFn1MczUnoX59GNqHbqDwhX3mfMk7anDP5tKQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to handle Random popups in Selenium WebDriver ?

tulsi.tester
In reply to this post by Sumit Mishra
Hello,

If it is a java script alert we can create a function to check whether an alert is present or not and call this function before each line of your webdriver script as you doesn't have any information when an alert pops up.


Function to check alert is present or not:
---------------------------------------------------------

public static Alert alert=null;   //declare this a global variable

public boolean isAlertPresent(){

boolean ispresent = false;

                 try{

                        alert = driver.switchTo().alert();
                        ispresent= true;
                     }catch(NoSuchAlertException e){
                         ispresent = false;
                    }
}


Call the above function before each line of your webdriver code and accept the alert. After accepting the alert again assign alert to null;




On Monday, June 23, 2014 at 1:31:56 PM UTC+5:30, Sumit Mishra wrote:

Hello,

When running my testscripts, sometimes an popups appears. The problem is that the popup is totally random and I have no way of knowing when it's going to appear.

I need to know what the popups says, so this can be fixed. Can someone tell me how to handle such an popup, so that i can see what the popup says?

Thanks
Sumit Mishra

--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/54567afa-9e17-4e10-b7d7-6c9d299838c0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

RE: How to handle Random popups in Selenium WebDriver ?

Xiang Dong
In reply to this post by amritab85
your alert dialog is random, you may have three ways to handle it

1. check alert present or not before perform any web driver based action, such as click, but I think you may have a lot of places to add check, it will be a big effort

2. try catch all your web driver action, if there is an unexpected alert present, you will get exception "UnhandledAlertException", catch this exception and accept the alert, then perform your action again.

3. Override windows.alert function, make your web page totally not display it, you need to add this javascript into the web page, web driver can inject it for you. 

Both three ways all have some weakness, the 1 & 2 needs you fix the codes in a lot of places. A fast way for it is that you can implement a new class inherit from WebDriver, WebElement and other web driver classes. add your alert checking code in each web driver actions, includes findElement or methodes. the third one does not requires much codes but it will override alert function, it also includes the intentional alert dialog. 

Hope it can help you.
--david


Date: Thu, 2 Apr 2015 15:32:44 +0530
Subject: Re: [selenium-users] How to handle Random popups in Selenium WebDriver ?
From: [hidden email]
To: [hidden email]

Hi David,

Could you please let me know the "the other way is capture exception for any web driver action, if there is an alert dialog, close it and re-perform the action."

Also, do we have any way to default behaviour of alert() like we have way for window.alert (  ((JavascriptExecutor)driver).executeScript("window.alert = function(msg){};");)

Actually, I had created code for checking alert and take necessary actions. I have placed it at numerous places in the script but each time it executes it takes time. Also, there's no surety that at other places, message will not come.

I am really tired of this one..

Thanks!

On 1 April 2015 at 11:59, Xiang Dong <[hidden email]> wrote:
sure it is a way, but it make the codes complicated, programmer need to check alert present and catch the exception before perform any action, in spite of it, it is not 100% percent works because between the check alert and perform action, there are still some time gap. alert dialog still has possibility to popup. the other way is capture exception for any web driver action, if there is an alert dialog, close it and re-perform the action.

considering it is a random alert dialog, there is no way to anticipate when the alert dialog popup. so, a dedicate logic to handle it is necessary.

Best Regards,
--david


Date: Tue, 31 Mar 2015 09:35:06 -0700
From: [hidden email]
To: [hidden email]
Subject: Re: [selenium-users] How to handle Random popups in Selenium WebDriver ?


Hi Amrita and David,

We can create a while statement which check if alert is present then it will capture alert message and close alert window.

Try below code and let me know if you finding any issue.

http://learn-automation.com/handle-alert-in-selenium-webdriver/

On Monday, March 30, 2015 at 1:07:37 PM UTC+5:30, Amrita B wrote:
Hi David,

I am facing similar issue.. Could you please let me know code if it is an alert, something like this: alert("You have a new message");

On Monday, June 23, 2014 at 2:27:36 PM UTC+5:30, David Dong wrote:
what kind of popup it is? if it is alert/confirm/prompt, you can override those popup by writing javascript (via web driver) to your UTA page, you can disable those popup and retrieve the content in the popup and writing it to an page element (you may dynamic generate an html element and attach it to the end of html body, the javascript can be injected by web driver).
before run each test step, retrieve the content from this page element, you will get content of it.

window._alert = window.alert;
window.alert = function(str) {
     document.getElementById('popup_content').value=str;
     return false;
}

But something should be aware of, with this javascript, all your alert dialog will not displayed.

I didn't test your case, but above javascript should works.

Best Regards,
--david


Date: Mon, 23 Jun 2014 01:01:56 -0700
From: [hidden email]
To: [hidden email]
Subject: [selenium-users] How to handle Random popups in Selenium WebDriver ?


Hello,

When running my testscripts, sometimes an popups appears. The problem is that the popup is totally random and I have no way of knowing when it's going to appear.

I need to know what the popups says, so this can be fixed. Can someone tell me how to handle such an popup, so that i can see what the popup says?

Thanks
Sumit Mishra

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/fd4501c2-d8d2-44bb-8172-af098ff8cb15%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/6bb85f79-21b7-4676-81a3-5a8d416f7512%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "Selenium Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/selenium-users/Kt0lHgr4qf8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/BLU174-W2332D97D5431E9C15DFD3E90F30%40phx.gbl.

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


--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CAPjkdGH01Y8f%3DsFn1MczUnoX59GNqHbqDwhX3mfMk7anDP5tKQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/BLU174-W3545CDB97EC92E9D511BB590F10%40phx.gbl.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to handle Random popups in Selenium WebDriver ?

Oscar Rieken
4. is not make the alert random. if the system is yours nothing should happen randomly, work with your team to find out what causes the popup, then go from there, your tests should be deterministic


if you need tests around the popup, then create a state where the pop up happens consistently. 
if you dont need to test the popup, then create a state where it does not pop up

On Fri, Apr 3, 2015 at 1:41 AM, Xiang Dong <[hidden email]> wrote:
your alert dialog is random, you may have three ways to handle it

1. check alert present or not before perform any web driver based action, such as click, but I think you may have a lot of places to add check, it will be a big effort

2. try catch all your web driver action, if there is an unexpected alert present, you will get exception "UnhandledAlertException", catch this exception and accept the alert, then perform your action again.

3. Override windows.alert function, make your web page totally not display it, you need to add this javascript into the web page, web driver can inject it for you. 

Both three ways all have some weakness, the 1 & 2 needs you fix the codes in a lot of places. A fast way for it is that you can implement a new class inherit from WebDriver, WebElement and other web driver classes. add your alert checking code in each web driver actions, includes findElement or methodes. the third one does not requires much codes but it will override alert function, it also includes the intentional alert dialog. 

Hope it can help you.
--david


Date: Thu, 2 Apr 2015 15:32:44 +0530
Subject: Re: [selenium-users] How to handle Random popups in Selenium WebDriver ?
From: [hidden email]
To: [hidden email]


Hi David,

Could you please let me know the "the other way is capture exception for any web driver action, if there is an alert dialog, close it and re-perform the action."

Also, do we have any way to default behaviour of alert() like we have way for window.alert (  ((JavascriptExecutor)driver).executeScript("window.alert = function(msg){};");)

Actually, I had created code for checking alert and take necessary actions. I have placed it at numerous places in the script but each time it executes it takes time. Also, there's no surety that at other places, message will not come.

I am really tired of this one..

Thanks!

On 1 April 2015 at 11:59, Xiang Dong <[hidden email]> wrote:
sure it is a way, but it make the codes complicated, programmer need to check alert present and catch the exception before perform any action, in spite of it, it is not 100% percent works because between the check alert and perform action, there are still some time gap. alert dialog still has possibility to popup. the other way is capture exception for any web driver action, if there is an alert dialog, close it and re-perform the action.

considering it is a random alert dialog, there is no way to anticipate when the alert dialog popup. so, a dedicate logic to handle it is necessary.

Best Regards,
--david


Date: Tue, 31 Mar 2015 09:35:06 -0700
From: [hidden email]
To: [hidden email]
Subject: Re: [selenium-users] How to handle Random popups in Selenium WebDriver ?


Hi Amrita and David,

We can create a while statement which check if alert is present then it will capture alert message and close alert window.

Try below code and let me know if you finding any issue.

http://learn-automation.com/handle-alert-in-selenium-webdriver/

On Monday, March 30, 2015 at 1:07:37 PM UTC+5:30, Amrita B wrote:
Hi David,

I am facing similar issue.. Could you please let me know code if it is an alert, something like this: alert("You have a new message");

On Monday, June 23, 2014 at 2:27:36 PM UTC+5:30, David Dong wrote:
what kind of popup it is? if it is alert/confirm/prompt, you can override those popup by writing javascript (via web driver) to your UTA page, you can disable those popup and retrieve the content in the popup and writing it to an page element (you may dynamic generate an html element and attach it to the end of html body, the javascript can be injected by web driver).
before run each test step, retrieve the content from this page element, you will get content of it.

window._alert = window.alert;
window.alert = function(str) {
     document.getElementById('popup_content').value=str;
     return false;
}

But something should be aware of, with this javascript, all your alert dialog will not displayed.

I didn't test your case, but above javascript should works.

Best Regards,
--david


Date: Mon, 23 Jun 2014 01:01:56 -0700
From: [hidden email]
To: [hidden email]
Subject: [selenium-users] How to handle Random popups in Selenium WebDriver ?


Hello,

When running my testscripts, sometimes an popups appears. The problem is that the popup is totally random and I have no way of knowing when it's going to appear.

I need to know what the popups says, so this can be fixed. Can someone tell me how to handle such an popup, so that i can see what the popup says?

Thanks
Sumit Mishra

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/fd4501c2-d8d2-44bb-8172-af098ff8cb15%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/6bb85f79-21b7-4676-81a3-5a8d416f7512%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "Selenium Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/selenium-users/Kt0lHgr4qf8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/BLU174-W2332D97D5431E9C15DFD3E90F30%40phx.gbl.

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


--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CAPjkdGH01Y8f%3DsFn1MczUnoX59GNqHbqDwhX3mfMk7anDP5tKQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/BLU174-W3545CDB97EC92E9D511BB590F10%40phx.gbl.

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

--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CACuB3fYau6p4-TXWZksv_6UBJcpbtGKdjGqLTPFCiB_poPvnXw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to handle Random popups in Selenium WebDriver ?

Rajiv Nanduani
You can use webdriver listener

On Friday, April 3, 2015, Oscar Rieken <[hidden email]> wrote:

> 4. is not make the alert random. if the system is yours nothing should happen randomly, work with your team to find out what causes the popup, then go from there, your tests should be deterministic
>
> if you need tests around the popup, then create a state where the pop up happens consistently. 
> if you dont need to test the popup, then create a state where it does not pop up
> On Fri, Apr 3, 2015 at 1:41 AM, Xiang Dong <[hidden email]> wrote:
>>
>> your alert dialog is random, you may have three ways to handle it
>> 1. check alert present or not before perform any web driver based action, such as click, but I think you may have a lot of places to add check, it will be a big effort
>> 2. try catch all your web driver action, if there is an unexpected alert present, you will get exception "UnhandledAlertException", catch this exception and accept the alert, then perform your action again.
>> 3. Override windows.alert function, make your web page totally not display it, you need to add this javascript into the web page, web driver can inject it for you. 
>> Both three ways all have some weakness, the 1 & 2 needs you fix the codes in a lot of places. A fast way for it is that you can implement a new class inherit from WebDriver, WebElement and other web driver classes. add your alert checking code in each web driver actions, includes findElement or methodes. the third one does not requires much codes but it will override alert function, it also includes the intentional alert dialog. 
>> Hope it can help you.
>> --david
>> ________________________________
>> Date: Thu, 2 Apr 2015 15:32:44 +0530
>> Subject: Re: [selenium-users] How to handle Random popups in Selenium WebDriver ?
>> From: [hidden email]
>> To: [hidden email]
>>
>> Hi David,
>> Could you please let me know the "the other way is capture exception for any web driver action, if there is an alert dialog, close it and re-perform the action."
>> Also, do we have any way to default behaviour of alert() like we have way for window.alert (  ((JavascriptExecutor)driver).executeScript("window.alert = function(msg){};");)
>> Actually, I had created code for checking alert and take necessary actions. I have placed it at numerous places in the script but each time it executes it takes time. Also, there's no surety that at other places, message will not come.
>> I am really tired of this one..
>> Thanks!
>> On 1 April 2015 at 11:59, Xiang Dong <[hidden email]> wrote:
>>
>> sure it is a way, but it make the codes complicated, programmer need to check alert present and catch the exception before perform any action, in spite of it, it is not 100% percent works because between the check alert and perform action, there are still some time gap. alert dialog still has possibility to popup. the other way is capture exception for any web driver action, if there is an alert dialog, close it and re-perform the action.
>> considering it is a random alert dialog, there is no way to anticipate when the alert dialog popup. so, a dedicate logic to handle it is necessary.
>> Best Regards,
>> --david
>>
>> ________________________________
>> Date: Tue, 31 Mar 2015 09:35:06 -0700
>> From: [hidden email]
>> To: [hidden email]
>> Subject: Re: [selenium-users] How to handle Random popups in Selenium WebDriver ?
>>
>> Hi Amrita and David,
>> We can create a while statement which check if alert is present then it will capture alert message and close alert window.
>> Try below code and let me know if you finding any issue.
>> http://learn-automation.com/handle-alert-in-selenium-webdriver/
>>
>> On Monday, March 30, 2015 at 1:07:37 PM UTC+5:30, Amrita B wrote:
>>
>> Hi David,
>> I am facing similar issue.. Could you please let me know code if it is an alert, something like this: alert("You have a new message");
>>
>> On Monday, June 23, 2014 at 2:27:36 PM UTC+5:30, David Dong wrote:
>>
>> what kind of popup it is? if it is alert/confirm/prompt, you can override those popup by writing javascript (via web driver) to your UTA page, you can disable those popup and retrieve the content in the popup and writing it to an page element (you may dynamic generate an html element and attach it to the end of html body, the javascript can be injected by web driver).
>> before run each test step, retrieve the content from this page element, you will get content of it.
>> window._alert = window.alert;
>> window.alert = function(str) {
>>      document.getElementById('popup_content').value=str;
>>      return false;
>> }
>> But something should be aware of, with this javascript, all your alert dialog will not displayed.
>> I didn't test your case, but above javascript should works.
>> Best Regards,
>> --david
>> ________________________________
>> Date: Mon, 23 Jun 2014 01:01:56 -0700
>> From: [hidden email]
>> To: [hidden email]
>> Subject: [selenium-users] How to handle Random popups in Selenium WebDriver ?
>>
>>
>> Hello,
>>
>> When running my testscripts, sometimes an popups appears. The problem is that the popup is totally random and I have no way of knowing when it's going to appear.
>>
>> I need to know what the popups says, so this can be fixed. Can someone tell me how to handle such an popup, so that i can see what the popup says?
>>
>> Thanks
>> Sumit Mishra
>>
>> --
>> 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 [hidden email].
>> To post to this group, send email to [hidden email].
>> To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/fd4501c2-d8d2-44bb-8172-af098ff8cb15%40googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>> --
>> 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 [hidden email].
>> To post to this group, send email to [hidden email].
>> To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/6bb85f79-21b7-4676-81a3-5a8d416f7512%40googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>> --
>> You received this message because you are subscribed to a topic in the Google Groups "Selenium Users" group.
>> To unsubscribe from this topic, visit https://groups.google.com/d/topic/selenium-users/Kt0lHgr4qf8/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to [hidden email].
>> To post to this group, send email to [hidden email].
>> To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/BLU174-W2332D97D5431E9C15DFD3E90F30%40phx.gbl.
>> For more options, visit https://groups.google.com/d/optout.
>>
>>
>> --
>> 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 [hidden email].
>> To post to this group, send email to [hidden email].
>> To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CAPjkdGH01Y8f%3DsFn1MczUnoX59GNqHbqDwhX3mfMk7anDP5tKQ%40mail.gmail.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>> --
>> 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 [hidden email].
>> To post to this group, send email to [hidden email].
>> To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/BLU174-W3545CDB97EC92E9D511BB590F10%40phx.gbl.
>> For more options, visit https://groups.google.com/d/optout.
>
> --
> 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 [hidden email].
> To post to this group, send email to [hidden email].
> To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CACuB3fYau6p4-TXWZksv_6UBJcpbtGKdjGqLTPFCiB_poPvnXw%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.
>

--

Regards

RAJIV KUMAR NANDVANI

http://rajivkumarnandvani.wordpress.com
http://testeverythingqtp.blogspot.com/




--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CAH_FQGqsgTfVSLjbMjApv_1Ts7eb-ToEW7MkJEF-ihnE_Y5opQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to handle Random popups in Selenium WebDriver ?

amritab85
In reply to this post by Xiang Dong
David,

I had tried the 3rd option but as I mentioned earlier it is not working correctly for alert() function. It works for window.alert() though.

On 3 April 2015 at 11:11, Xiang Dong <[hidden email]> wrote:
your alert dialog is random, you may have three ways to handle it

1. check alert present or not before perform any web driver based action, such as click, but I think you may have a lot of places to add check, it will be a big effort

2. try catch all your web driver action, if there is an unexpected alert present, you will get exception "UnhandledAlertException", catch this exception and accept the alert, then perform your action again.

3. Override windows.alert function, make your web page totally not display it, you need to add this javascript into the web page, web driver can inject it for you. 

Both three ways all have some weakness, the 1 & 2 needs you fix the codes in a lot of places. A fast way for it is that you can implement a new class inherit from WebDriver, WebElement and other web driver classes. add your alert checking code in each web driver actions, includes findElement or methodes. the third one does not requires much codes but it will override alert function, it also includes the intentional alert dialog. 

Hope it can help you.
--david


Date: Thu, 2 Apr 2015 15:32:44 +0530
Subject: Re: [selenium-users] How to handle Random popups in Selenium WebDriver ?
From: [hidden email]
To: [hidden email]


Hi David,

Could you please let me know the "the other way is capture exception for any web driver action, if there is an alert dialog, close it and re-perform the action."

Also, do we have any way to default behaviour of alert() like we have way for window.alert (  ((JavascriptExecutor)driver).executeScript("window.alert = function(msg){};");)

Actually, I had created code for checking alert and take necessary actions. I have placed it at numerous places in the script but each time it executes it takes time. Also, there's no surety that at other places, message will not come.

I am really tired of this one..

Thanks!

On 1 April 2015 at 11:59, Xiang Dong <[hidden email]> wrote:
sure it is a way, but it make the codes complicated, programmer need to check alert present and catch the exception before perform any action, in spite of it, it is not 100% percent works because between the check alert and perform action, there are still some time gap. alert dialog still has possibility to popup. the other way is capture exception for any web driver action, if there is an alert dialog, close it and re-perform the action.

considering it is a random alert dialog, there is no way to anticipate when the alert dialog popup. so, a dedicate logic to handle it is necessary.

Best Regards,
--david


Date: Tue, 31 Mar 2015 09:35:06 -0700
From: [hidden email]
To: [hidden email]
Subject: Re: [selenium-users] How to handle Random popups in Selenium WebDriver ?


Hi Amrita and David,

We can create a while statement which check if alert is present then it will capture alert message and close alert window.

Try below code and let me know if you finding any issue.

http://learn-automation.com/handle-alert-in-selenium-webdriver/

On Monday, March 30, 2015 at 1:07:37 PM UTC+5:30, Amrita B wrote:
Hi David,

I am facing similar issue.. Could you please let me know code if it is an alert, something like this: alert("You have a new message");

On Monday, June 23, 2014 at 2:27:36 PM UTC+5:30, David Dong wrote:
what kind of popup it is? if it is alert/confirm/prompt, you can override those popup by writing javascript (via web driver) to your UTA page, you can disable those popup and retrieve the content in the popup and writing it to an page element (you may dynamic generate an html element and attach it to the end of html body, the javascript can be injected by web driver).
before run each test step, retrieve the content from this page element, you will get content of it.

window._alert = window.alert;
window.alert = function(str) {
     document.getElementById('popup_content').value=str;
     return false;
}

But something should be aware of, with this javascript, all your alert dialog will not displayed.

I didn't test your case, but above javascript should works.

Best Regards,
--david


Date: Mon, 23 Jun 2014 01:01:56 -0700
From: [hidden email]
To: [hidden email]
Subject: [selenium-users] How to handle Random popups in Selenium WebDriver ?


Hello,

When running my testscripts, sometimes an popups appears. The problem is that the popup is totally random and I have no way of knowing when it's going to appear.

I need to know what the popups says, so this can be fixed. Can someone tell me how to handle such an popup, so that i can see what the popup says?

Thanks
Sumit Mishra

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/fd4501c2-d8d2-44bb-8172-af098ff8cb15%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/6bb85f79-21b7-4676-81a3-5a8d416f7512%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "Selenium Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/selenium-users/Kt0lHgr4qf8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/BLU174-W2332D97D5431E9C15DFD3E90F30%40phx.gbl.

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


--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CAPjkdGH01Y8f%3DsFn1MczUnoX59GNqHbqDwhX3mfMk7anDP5tKQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "Selenium Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/selenium-users/Kt0lHgr4qf8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/BLU174-W3545CDB97EC92E9D511BB590F10%40phx.gbl.

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

--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CAPjkdGHHvFvxuNLm2xH3-sk5BwZCwTW7bnjgRE2mzvradVKt%2BQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to handle Random popups in Selenium WebDriver ?

amritab85
In reply to this post by Oscar Rieken
Yes, I had discussed to switch off a functionality that displays alert messages. I have avoided it for now but not sure if I can encounter random pop ups in other areas..

On 3 April 2015 at 18:55, Oscar Rieken <[hidden email]> wrote:
4. is not make the alert random. if the system is yours nothing should happen randomly, work with your team to find out what causes the popup, then go from there, your tests should be deterministic


if you need tests around the popup, then create a state where the pop up happens consistently. 
if you dont need to test the popup, then create a state where it does not pop up

On Fri, Apr 3, 2015 at 1:41 AM, Xiang Dong <[hidden email]> wrote:
your alert dialog is random, you may have three ways to handle it

1. check alert present or not before perform any web driver based action, such as click, but I think you may have a lot of places to add check, it will be a big effort

2. try catch all your web driver action, if there is an unexpected alert present, you will get exception "UnhandledAlertException", catch this exception and accept the alert, then perform your action again.

3. Override windows.alert function, make your web page totally not display it, you need to add this javascript into the web page, web driver can inject it for you. 

Both three ways all have some weakness, the 1 & 2 needs you fix the codes in a lot of places. A fast way for it is that you can implement a new class inherit from WebDriver, WebElement and other web driver classes. add your alert checking code in each web driver actions, includes findElement or methodes. the third one does not requires much codes but it will override alert function, it also includes the intentional alert dialog. 

Hope it can help you.
--david


Date: Thu, 2 Apr 2015 15:32:44 +0530
Subject: Re: [selenium-users] How to handle Random popups in Selenium WebDriver ?
From: [hidden email]
To: [hidden email]


Hi David,

Could you please let me know the "the other way is capture exception for any web driver action, if there is an alert dialog, close it and re-perform the action."

Also, do we have any way to default behaviour of alert() like we have way for window.alert (  ((JavascriptExecutor)driver).executeScript("window.alert = function(msg){};");)

Actually, I had created code for checking alert and take necessary actions. I have placed it at numerous places in the script but each time it executes it takes time. Also, there's no surety that at other places, message will not come.

I am really tired of this one..

Thanks!

On 1 April 2015 at 11:59, Xiang Dong <[hidden email]> wrote:
sure it is a way, but it make the codes complicated, programmer need to check alert present and catch the exception before perform any action, in spite of it, it is not 100% percent works because between the check alert and perform action, there are still some time gap. alert dialog still has possibility to popup. the other way is capture exception for any web driver action, if there is an alert dialog, close it and re-perform the action.

considering it is a random alert dialog, there is no way to anticipate when the alert dialog popup. so, a dedicate logic to handle it is necessary.

Best Regards,
--david


Date: Tue, 31 Mar 2015 09:35:06 -0700
From: [hidden email]
To: [hidden email]
Subject: Re: [selenium-users] How to handle Random popups in Selenium WebDriver ?


Hi Amrita and David,

We can create a while statement which check if alert is present then it will capture alert message and close alert window.

Try below code and let me know if you finding any issue.

http://learn-automation.com/handle-alert-in-selenium-webdriver/

On Monday, March 30, 2015 at 1:07:37 PM UTC+5:30, Amrita B wrote:
Hi David,

I am facing similar issue.. Could you please let me know code if it is an alert, something like this: alert("You have a new message");

On Monday, June 23, 2014 at 2:27:36 PM UTC+5:30, David Dong wrote:
what kind of popup it is? if it is alert/confirm/prompt, you can override those popup by writing javascript (via web driver) to your UTA page, you can disable those popup and retrieve the content in the popup and writing it to an page element (you may dynamic generate an html element and attach it to the end of html body, the javascript can be injected by web driver).
before run each test step, retrieve the content from this page element, you will get content of it.

window._alert = window.alert;
window.alert = function(str) {
     document.getElementById('popup_content').value=str;
     return false;
}

But something should be aware of, with this javascript, all your alert dialog will not displayed.

I didn't test your case, but above javascript should works.

Best Regards,
--david


Date: Mon, 23 Jun 2014 01:01:56 -0700
From: [hidden email]
To: [hidden email]
Subject: [selenium-users] How to handle Random popups in Selenium WebDriver ?


Hello,

When running my testscripts, sometimes an popups appears. The problem is that the popup is totally random and I have no way of knowing when it's going to appear.

I need to know what the popups says, so this can be fixed. Can someone tell me how to handle such an popup, so that i can see what the popup says?

Thanks
Sumit Mishra

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/fd4501c2-d8d2-44bb-8172-af098ff8cb15%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/6bb85f79-21b7-4676-81a3-5a8d416f7512%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "Selenium Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/selenium-users/Kt0lHgr4qf8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/BLU174-W2332D97D5431E9C15DFD3E90F30%40phx.gbl.

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


--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CAPjkdGH01Y8f%3DsFn1MczUnoX59GNqHbqDwhX3mfMk7anDP5tKQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/BLU174-W3545CDB97EC92E9D511BB590F10%40phx.gbl.

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

--
You received this message because you are subscribed to a topic in the Google Groups "Selenium Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/selenium-users/Kt0lHgr4qf8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CACuB3fYau6p4-TXWZksv_6UBJcpbtGKdjGqLTPFCiB_poPvnXw%40mail.gmail.com.

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

--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CAPjkdGGMvv4e%3DfwCd%3DGQ9PnSv-gUzR_YVcwkB39oobp8sxRMkA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to handle Random popups in Selenium WebDriver ?

amritab85
In reply to this post by Rajiv Nanduani
Could you please elaborate on how I can use this especially when I am using a framework for testing.

On 3 April 2015 at 22:06, Rajiv Nanduani <[hidden email]> wrote:
You can use webdriver listener

On Friday, April 3, 2015, Oscar Rieken <[hidden email]> wrote:

> 4. is not make the alert random. if the system is yours nothing should happen randomly, work with your team to find out what causes the popup, then go from there, your tests should be deterministic
>
> if you need tests around the popup, then create a state where the pop up happens consistently. 
> if you dont need to test the popup, then create a state where it does not pop up
> On Fri, Apr 3, 2015 at 1:41 AM, Xiang Dong <[hidden email]> wrote:
>>
>> your alert dialog is random, you may have three ways to handle it
>> 1. check alert present or not before perform any web driver based action, such as click, but I think you may have a lot of places to add check, it will be a big effort
>> 2. try catch all your web driver action, if there is an unexpected alert present, you will get exception "UnhandledAlertException", catch this exception and accept the alert, then perform your action again.
>> 3. Override windows.alert function, make your web page totally not display it, you need to add this javascript into the web page, web driver can inject it for you. 
>> Both three ways all have some weakness, the 1 & 2 needs you fix the codes in a lot of places. A fast way for it is that you can implement a new class inherit from WebDriver, WebElement and other web driver classes. add your alert checking code in each web driver actions, includes findElement or methodes. the third one does not requires much codes but it will override alert function, it also includes the intentional alert dialog. 
>> Hope it can help you.
>> --david
>> ________________________________
>> Date: Thu, 2 Apr 2015 15:32:44 +0530
>> Subject: Re: [selenium-users] How to handle Random popups in Selenium WebDriver ?
>> From: [hidden email]
>> To: [hidden email]
>>
>> Hi David,
>> Could you please let me know the "the other way is capture exception for any web driver action, if there is an alert dialog, close it and re-perform the action."
>> Also, do we have any way to default behaviour of alert() like we have way for window.alert (  ((JavascriptExecutor)driver).executeScript("window.alert = function(msg){};");)
>> Actually, I had created code for checking alert and take necessary actions. I have placed it at numerous places in the script but each time it executes it takes time. Also, there's no surety that at other places, message will not come.
>> I am really tired of this one..
>> Thanks!
>> On 1 April 2015 at 11:59, Xiang Dong <[hidden email]> wrote:
>>
>> sure it is a way, but it make the codes complicated, programmer need to check alert present and catch the exception before perform any action, in spite of it, it is not 100% percent works because between the check alert and perform action, there are still some time gap. alert dialog still has possibility to popup. the other way is capture exception for any web driver action, if there is an alert dialog, close it and re-perform the action.
>> considering it is a random alert dialog, there is no way to anticipate when the alert dialog popup. so, a dedicate logic to handle it is necessary.
>> Best Regards,
>> --david
>>
>> ________________________________
>> Date: Tue, 31 Mar 2015 09:35:06 -0700
>> From: [hidden email]
>> To: [hidden email]
>> Subject: Re: [selenium-users] How to handle Random popups in Selenium WebDriver ?
>>
>> Hi Amrita and David,
>> We can create a while statement which check if alert is present then it will capture alert message and close alert window.
>> Try below code and let me know if you finding any issue.
>> http://learn-automation.com/handle-alert-in-selenium-webdriver/
>>
>> On Monday, March 30, 2015 at 1:07:37 PM UTC+5:30, Amrita B wrote:
>>
>> Hi David,
>> I am facing similar issue.. Could you please let me know code if it is an alert, something like this: alert("You have a new message");
>>
>> On Monday, June 23, 2014 at 2:27:36 PM UTC+5:30, David Dong wrote:
>>
>> what kind of popup it is? if it is alert/confirm/prompt, you can override those popup by writing javascript (via web driver) to your UTA page, you can disable those popup and retrieve the content in the popup and writing it to an page element (you may dynamic generate an html element and attach it to the end of html body, the javascript can be injected by web driver).
>> before run each test step, retrieve the content from this page element, you will get content of it.
>> window._alert = window.alert;
>> window.alert = function(str) {
>>      document.getElementById('popup_content').value=str;
>>      return false;
>> }
>> But something should be aware of, with this javascript, all your alert dialog will not displayed.
>> I didn't test your case, but above javascript should works.
>> Best Regards,
>> --david
>> ________________________________
>> Date: Mon, 23 Jun 2014 01:01:56 -0700
>> From: [hidden email]
>> To: [hidden email]
>> Subject: [selenium-users] How to handle Random popups in Selenium WebDriver ?
>>
>>
>> Hello,
>>
>> When running my testscripts, sometimes an popups appears. The problem is that the popup is totally random and I have no way of knowing when it's going to appear.
>>
>> I need to know what the popups says, so this can be fixed. Can someone tell me how to handle such an popup, so that i can see what the popup says?
>>
>> Thanks
>> Sumit Mishra
>>
>> --
>> 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 [hidden email].
>> To post to this group, send email to [hidden email].
>> To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/fd4501c2-d8d2-44bb-8172-af098ff8cb15%40googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>> --
>> 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 [hidden email].
>> To post to this group, send email to [hidden email].
>> To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/6bb85f79-21b7-4676-81a3-5a8d416f7512%40googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>> --
>> You received this message because you are subscribed to a topic in the Google Groups "Selenium Users" group.
>> To unsubscribe from this topic, visit https://groups.google.com/d/topic/selenium-users/Kt0lHgr4qf8/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to [hidden email].
>> To post to this group, send email to [hidden email].
>> To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/BLU174-W2332D97D5431E9C15DFD3E90F30%40phx.gbl.
>> For more options, visit https://groups.google.com/d/optout.
>>
>>
>> --
>> 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 [hidden email].
>> To post to this group, send email to [hidden email].
>> To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CAPjkdGH01Y8f%3DsFn1MczUnoX59GNqHbqDwhX3mfMk7anDP5tKQ%40mail.gmail.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>> --
>> 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 [hidden email].
>> To post to this group, send email to [hidden email].
>> To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/BLU174-W3545CDB97EC92E9D511BB590F10%40phx.gbl.
>> For more options, visit https://groups.google.com/d/optout.
>
> --
> 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 [hidden email].
> To post to this group, send email to [hidden email].
> To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CACuB3fYau6p4-TXWZksv_6UBJcpbtGKdjGqLTPFCiB_poPvnXw%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.
>

--

Regards

RAJIV KUMAR NANDVANI

http://rajivkumarnandvani.wordpress.com
http://testeverythingqtp.blogspot.com/




--
You received this message because you are subscribed to a topic in the Google Groups "Selenium Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/selenium-users/Kt0lHgr4qf8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CAH_FQGqsgTfVSLjbMjApv_1Ts7eb-ToEW7MkJEF-ihnE_Y5opQ%40mail.gmail.com.

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

--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CAPjkdGEQHKqZQeEhSBB34O0BOx63NUrKYubnaE2RSkUc-X7t9Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to handle Random popups in Selenium WebDriver ?

Devendra Singh
In reply to this post by Mukesh otwani
Hi Mukesh ,

Same issue i'm facing for unwanted/unexpected pop-up(Bootstrap unwanted pop-up) that occurs .
Your article can be helpful place when we are sure or expected that pop-up might comes .

If any other recommendation or code .Please help out .



On Tuesday, March 31, 2015 at 10:05:06 PM UTC+5:30, Mukesh otwani wrote:
Hi Amrita and David,

We can create a while statement which check if alert is present then it will capture alert message and close alert window.

Try below code and let me know if you finding any issue.

<a href="http://learn-automation.com/handle-alert-in-selenium-webdriver/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Flearn-automation.com%2Fhandle-alert-in-selenium-webdriver%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHGs-2MCdk-I3l3Ss-0wuNhSP0slg&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Flearn-automation.com%2Fhandle-alert-in-selenium-webdriver%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHGs-2MCdk-I3l3Ss-0wuNhSP0slg&#39;;return true;">http://learn-automation.com/handle-alert-in-selenium-webdriver/

On Monday, March 30, 2015 at 1:07:37 PM UTC+5:30, Amrita B wrote:
Hi David,

I am facing similar issue.. Could you please let me know code if it is an alert, something like this: alert("You have a new message");

On Monday, June 23, 2014 at 2:27:36 PM UTC+5:30, David Dong wrote:
what kind of popup it is? if it is alert/confirm/prompt, you can override those popup by writing javascript (via web driver) to your UTA page, you can disable those popup and retrieve the content in the popup and writing it to an page element (you may dynamic generate an html element and attach it to the end of html body, the javascript can be injected by web driver).
before run each test step, retrieve the content from this page element, you will get content of it.

window._alert = window.alert;
window.alert = function(str) {
     document.getElementById('popup_content').value=str;
     return false;
}

But something should be aware of, with this javascript, all your alert dialog will not displayed.

I didn't test your case, but above javascript should works.

Best Regards,
--david


Date: Mon, 23 Jun 2014 01:01:56 -0700
From: [hidden email]
To: [hidden email]
Subject: [selenium-users] How to handle Random popups in Selenium WebDriver ?


Hello,

When running my testscripts, sometimes an popups appears. The problem is that the popup is totally random and I have no way of knowing when it's going to appear.

I need to know what the popups says, so this can be fixed. Can someone tell me how to handle such an popup, so that i can see what the popup says?

Thanks
Sumit Mishra

--
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 [hidden email].
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/selenium-users/fd4501c2-d8d2-44bb-8172-af098ff8cb15%40googlegroups.com?utm_medium=email&amp;utm_source=footer" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/selenium-users/fd4501c2-d8d2-44bb-8172-af098ff8cb15%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/selenium-users/fd4501c2-d8d2-44bb-8172-af098ff8cb15%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/selenium-users/fd4501c2-d8d2-44bb-8172-af098ff8cb15%40googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/43b65899-1c3b-4e04-b8d2-a7b05eb1e883%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to handle Random popups in Selenium WebDriver ?

Rajeev Rahi
Try to use Robot class. It is able to handle even windows popups.



On Thu, May 31, 2018, 1:58 PM Devendra Singh <[hidden email]> wrote:
Hi Mukesh ,

Same issue i'm facing for unwanted/unexpected pop-up(Bootstrap unwanted pop-up) that occurs .
Your article can be helpful place when we are sure or expected that pop-up might comes .

If any other recommendation or code .Please help out .



On Tuesday, March 31, 2015 at 10:05:06 PM UTC+5:30, Mukesh otwani wrote:
Hi Amrita and David,

We can create a while statement which check if alert is present then it will capture alert message and close alert window.

Try below code and let me know if you finding any issue.

http://learn-automation.com/handle-alert-in-selenium-webdriver/

On Monday, March 30, 2015 at 1:07:37 PM UTC+5:30, Amrita B wrote:
Hi David,

I am facing similar issue.. Could you please let me know code if it is an alert, something like this: alert("You have a new message");

On Monday, June 23, 2014 at 2:27:36 PM UTC+5:30, David Dong wrote:
what kind of popup it is? if it is alert/confirm/prompt, you can override those popup by writing javascript (via web driver) to your UTA page, you can disable those popup and retrieve the content in the popup and writing it to an page element (you may dynamic generate an html element and attach it to the end of html body, the javascript can be injected by web driver).
before run each test step, retrieve the content from this page element, you will get content of it.

window._alert = window.alert;
window.alert = function(str) {
     document.getElementById('popup_content').value=str;
     return false;
}

But something should be aware of, with this javascript, all your alert dialog will not displayed.

I didn't test your case, but above javascript should works.

Best Regards,
--david


Date: Mon, 23 Jun 2014 01:01:56 -0700
From: [hidden email]
To: [hidden email]
Subject: [selenium-users] How to handle Random popups in Selenium WebDriver ?


Hello,

When running my testscripts, sometimes an popups appears. The problem is that the popup is totally random and I have no way of knowing when it's going to appear.

I need to know what the popups says, so this can be fixed. Can someone tell me how to handle such an popup, so that i can see what the popup says?

Thanks
Sumit Mishra

--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/fd4501c2-d8d2-44bb-8172-af098ff8cb15%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/43b65899-1c3b-4e04-b8d2-a7b05eb1e883%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CAH-THsCpr9xy55jCHRbmf2mu%3DNQwCSCGR1om%2Bq823g1dhobH6w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.