Advertisement
SeleniumETrainR

how to handle javascript alert in selenium webdriver?

Dec 14th, 2012
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. import java.util.concurrent.TimeUnit;
  2.  
  3. import org.openqa.selenium.WebDriver;
  4. import org.openqa.selenium.firefox.FirefoxDriver;
  5.  
  6.  
  7. public class testJavascriptAlert {
  8.  
  9.  
  10. public static void main(String[] args) throws InterruptedException {
  11. WebDriver myTestDriver = new FirefoxDriver();
  12. myTestDriver.get("http://tinyurl.com/cqpzwnl");
  13. myTestDriver.manage().window().maximize();
  14. myTestDriver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS);
  15.  
  16. Thread.sleep(1000L);
  17. myTestDriver.switchTo().alert().accept();
  18.  
  19. myTestDriver.close();
  20.  
  21. }
  22.  
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement