java - How wait for alert box to perform the action in Selenium? -


i pressing cancel button according code checking text. in chrome , firefox working fine in ie taking time perform operation on alert box code moves next line.

so want code stop till operation preformed on alert box , goes next step. doing automation testing using selenium.

please find piece of code:

alert al = driver.switchto().alert(); al.accept();  wait.until(expectedconditions.presenceofelementlocated(by.xpath(".//*[@id='content-body-full']/p[1]"))); assertequals("your cancellation request has been executed.",driver.findelement(by.xpath(".//*[@id='content-body-full']/p[1]")).gettext().tostring()); 

you want wait until alert present before switching it, similar 3rd row. reference.

edit: try:

new webdriverwait(driver, 60)         .ignoring(noalertpresentexception.class)         .until(expectedconditions.alertispresent());  alert al = driver.switchto().alert(); al.accept(); 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -