How to handle dynamic popup

1,254 views
Skip to first unread message

arunchandu ganta

unread,
Jun 5, 2014, 5:11:12 AM6/5/14
to seleniu...@googlegroups.com
Hi,

I am trying to automate one application using Java and webdriver - ticket rising application but having small issue.
If network or any account having issues then we will get some popup's and can't say when we will get popup. I'm not sure how to handle it.
Could you please help me.

Thanks
Arunchandu Ganta

Mark Paxton

unread,
Jun 5, 2014, 5:18:02 AM6/5/14
to selenium-users
Hello,

Have a look at getWindowHandles or getAllWindowHandles, this should give you a list of windows open in your site. You should be able to check if your popups are in the list by id or by counting the total.


Regards,
Mark


--
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/da43a6a8-ae86-4285-a5d9-a300f8f1a193%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

arunchandu ganta

unread,
Jun 5, 2014, 6:03:19 AM6/5/14
to seleniu...@googlegroups.com, vinn...@gmail.com
Hello Mark,

Thanks for responding, I am already using 'driver.getWindowHandles()' in my script. Problem of the application is we can't say when will get popup. :(
For Example: 

driver.findElement(By.xpath("/html/body/div/div[5]/div[21]/fieldset/div/div/div[2]/fieldset/div/div/div[2]/div/div/table/tbody/tr[6]/td/nobr/span")).click();
driver.findElement(By.xpath("/html/body/div/div[5]/div[21]/fieldset/div[2]/a/img")).click(); 
driver.findElement(By.cssSelector("[arvalue=\"Integrated\"]")).click();

Consider above three line of code, some time pop will come after first step execute, other time after third step execute and we can't when we will get that popup. Popup is  not J Query or JavaScript popup... It was div and kept in hidden. 
For reference I'm providing source code and marked in red color box

After every line or step I can check whether popup is coming or not however its not correct way to do. Could you please let me know how can we handle it.

Regards
Arunchandu Ganta.

Oscar Rieken

unread,
Jun 7, 2014, 9:48:01 PM6/7/14
to seleniu...@googlegroups.com
why not eliminate the network and account issues, wouldn't that be easier than trying to figure out a work around for something you don't know when/if it will happen?




Gau Mun

unread,
Jun 8, 2014, 9:47:26 PM6/8/14
to seleniu...@googlegroups.com
Dear friend , 

It mean that you need to wait for the popup showing first then you will check this.


In Wait Command we have a function Wait.Until(ExpectedConditions.IsElementPresent(By.xpath)).

Hope it can help you!

anjaneyulu v

unread,
Jun 9, 2014, 10:59:54 PM6/9/14
to seleniu...@googlegroups.com
Hi,
I have same issue that how to handle unexpected popup in mid of executing , we don't know when we will get that popup.
 
Thanks,
Anjaneyulu Vujani
On Thursday, June 5, 2014 2:41:12 PM UTC+5:30, arunchandu ganta wrote:,

http://thebuddhatree.blogspot.in/

unread,
Jun 10, 2014, 3:30:10 AM6/10/14
to seleniu...@googlegroups.com
An Easy solution is -
1. write a method to handle pop up
2. Call this method before performing an action on AUT

anjaneyulu v

unread,
Jun 10, 2014, 2:10:03 PM6/10/14
to seleniu...@googlegroups.com
Hi,
If i have Hundred different actions in my test, then do i need to call popup handling method before every action?
 
Thanks,
Anjaneyulu Vujani

http://thebuddhatree.blogspot.in/

unread,
Jun 11, 2014, 7:47:24 AM6/11/14
to seleniu...@googlegroups.com
You may use some Hook which gets executed before an action. For example if you are using TestNG, you can try beforeMethod(). Similar hooks are available in other framework also.

arunchandu ganta

unread,
Jun 11, 2014, 8:00:34 AM6/11/14
to seleniu...@googlegroups.com
Hi,

I didn't get you, Could you please explain like bit more or example

Thanks
Arunchandu Ganta

Krishnan Mahadevan

unread,
Jun 11, 2014, 10:04:03 AM6/11/14
to Selenium Users
What you need over here is EventFiringWebDriver.

Assuming that your tests dont use Actions class [ EventFiringWebDriver doesn't get events pertaining to Actions ], here's what you would need to do:

1. Create an actual WebDriver of your choice.
2. Now instantiate a EventFiringWebDriver using the WebDriver created in step(1) and inject an implementation of WebDriverEventListener.
3. Now use the EventFiringWebDriver object in your tests [ from step (2) ]
4. Override the methods of your choice in WebDriverEventListener interface implementation and then add code to handle Alerts with a try catch block.

That should take care of your scenario.

Darrell has written up a fairly detailed blog post on this : http://darrellgrainger.blogspot.in/2012/07/creating-screen-capture-on-every-action.html





Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.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 selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages