[selenium-users] onload confirmation box

508 views
Skip to first unread message

santosh

unread,
May 20, 2010, 3:59:01 AM5/20/10
to Selenium Users
Dear All,

In my application, a confirmation dialogue is not recognized by
selenium as it is being fired based on a check.
This pop up is shown on page load. We have to manually click on ‘ok’
to proceed further before it times out

Can any one please advice how to handle this.

Best Regards,
Santosh.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/selenium-users?hl=en.

Yuping Zhong

unread,
May 20, 2010, 4:08:18 AM5/20/10
to seleniu...@googlegroups.com
Do press the "enter" in keyboard is the same as click "ok" in the pop up?

If so,you can write the code to press the keyboard.

Thanks!

Elias Nogueira

unread,
May 20, 2010, 8:00:02 AM5/20/10
to seleniu...@googlegroups.com
Hello Santosh!

I have two approach's to this issue: one is add a javascript in a web page and the other is use the Java Robot.

Selenium not recognized alerts or other's js windows in onload function.
Please, read this link first.
http://seleniumhq.org/docs/05_selenium_rc.html#is-it-ok-to-load-a-custom-pop-up-as-the-parent-page-is-loading-i-e-before-the-parent-page-s-javascript-window-onload-function-runs

In a fist approach, put the follow javascript[1] on your web page before the confirm() or alert() function
if (parent.browserbot) {
   parent.browserbot.modifyWindowToRecordPopUpDialogs(window, parent.browserbot);
}

In second approach, in Java, if you can't handler or interact with the confirm or alert, send enter key with Java Robot[2] after alert or confirmation appears:
import java.awt.Robot;
import java.awt.event.KeyEvent;

Robot robot = new Robot();
robot.keyPress(KeyEvent.VK_ENTER);
 

[1] http://www.mail-archive.com/seleniu...@lists.public.thoughtworks.org/msg00652.html
[2] http://functionaltestautomation.blogspot.com/2009/10/maximize-browser-window-using-java.html

Best regards!
--
Elias Nogueira, CSTE
elias.n...@gmail.com

CSTE - Certified Software Tester
Blog: http://sembugs.blogspot.com
Twitter: http://twitter.com/eliasnogueira
LinkedIn: http://www.linkedin.com/in/eliasnogueira
Reply all
Reply to author
Forward
0 new messages