Handling javascript alerts in selenium

How to handle onload javascript warnings in selenium?

It is not written to the Selenium IDE, and it is not processed by the getAlert () function.

+5
source share
2 answers

Even I ran into the same problem. After several hours spent with selenium, a solution was found for handling warnings and tooltips in a java script.

we can use keyPressNative selenium to handle java script warnings from RC selenium.

Here's how the method should be used key*Native():

    selenium.keyPressNative("27"); // Escape
    selenium.keyPressNative("10"); // Enter    
    selenium.keyDownNative("16"); // Press and do not relase the shift key, so that
    selenium.keyPressNative("79"); // this character will be capitals
    selenium.keyUpNative("16"); // Release the shift key, as we don't need it for the 
    selenium.keyPressNative("67");

Not recommended, but helped me deal with some of the failures of selenium.

+5
source

It's impossible. As stated in the Selenium documentation :

( window.alert, window.confirm window.prompt), . , , , , , , .

Selenium RC (, , Selenium IDE), , Selenium 2 (WebDriver). onload JS, WebDriver .

Robot Enter . , . alert.

0

All Articles