handling javaScript alerts when running a selenium test?

Posted by Mo on Stack Overflow See other posts from Stack Overflow or by Mo
Published on 2010-05-25T14:37:10Z Indexed on 2010/05/25 14:41 UTC
Read the original article Hit count: 207

Filed under:
|
|

Hi

I am am running some selenium tests(ruby) on my web page and as i enter an invalid characters in to a text box i have the JavaScript throw a alert like so

if(isNaN($(this).val()) || Number($(this).val().valueOf() <=0)){
    alert("Please Enter A Number");
}

how can i handle this alert when its made and close the pop up?

i tried to use the wait_for_pop_up() and close() but i think that's only for browser pop up's and not JavaScript alerts.

any ideas?

thanks

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about ruby