RE: Handle HTTP Authentication – Authentication required dialog
I’m using Selenium with the Firefox Webdriver to test different events on my Website.
One event leads to a HTTP authentication dialog.
Is there a way to set selenium to always press cancel or to reach a timeout so I don’t hang around and get back the control of the driver?
I tried the following code but I’m not sure about the correct order of the coe lines.
Is it correct this way:
FirefoxProfile profile = new FirefoxProfile(); WebDriver driver = new FirefoxDriver(profile); WebDriverWait wait = new WebDriverWait(driver, 10); Alert alert = wait.until(ExpectedConditions.alertIsPresent()); alert.authenticateUsing(new UserAndPassword("username", "password")); driver.get("http://demo.tanmaysarkar.com/authentication/");