We are using Selenium to open certain webpages, but when opening the webpage, there is a popup that comes up and we are unable to handle the popup using selenium code. Below is the sample code for the same. I'm trying to use the alert method, but the system is unable to detect the alert
System.setProperty("webdriver.chrome.driver","D:\\Test\\drivers\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.manage().window().maximize();
driver.get("https://the-internet.herokuapp.com/basic_auth");
Alert alert=driver.switchTo().alert();
System.out.println(alert.getText());
alert.dismiss();
I put a debug point on the above code. and the code gets stuck at the line no.4 driver.get(). Unless some action is done on the loaded page like manually clicking on the cancel button, the control does not move to the next line.
Help required on
- Using selenium, how do I handle the popup when loading the webpage? I'm unable to detect the Popup elements via selenium
- I guess this is a javascript popup that is coming up on page load. How do I handle javascript popup on page load via selenium?
Any help on this is much appreciated. Thanks in Advance.