Alert alert = wait.until(ExpectedConditions.alertIsPresent()); alert.authenticateUsing(new UserAndPassword(username, password));
WebDriverWait wait = new WebDriverWait(driver, 10); Alert alert = wait.until(ExpectedConditions.alertIsPresent()); alert.authenticateUsing(new UserAndPassword("username","password"));
@Override @Beta public void basicAuthenticate(String username, String password) { alert.authenticateUsing(new UserAndPassword(username, password)); } }
WebDriverWait wdWait = new WebDriverWait(webdriver, 10); Alert alert = wdWait.until(ExpectedConditions.alertIsPresent()); alert.authenticateUsing(new UserAndPassword("username", "password"));
private final WebDriver driverForA = new InternetExplorerDriver(); private final WebDriver driverForB = new InternetExplorerDriver(); @After public void after() { driverForA.close(); driverForB.close(); } @Test public void testADoesThisAndBDoesThatHttpBasic() { // authenticate as a WebDriverWait wait = new WebDriverWait(driverForA, 5); Alert alert = wait.until(ExpectedConditions.alertIsPresent()); alert.authenticateUsing(new UserAndPassword("Joe", "superSecret")); // navigate to other pages and do things driverForB.get("http://my.approval.page"); final WebElement approveButton = driverForB.findElement(By.id("approval_Button")); approveButton.click(); }
/** * @Title: clickOKButtonInAlertDialog @Description: TODO @author * ahu@greendotcorp.com @param @return void return type @throws */ public void clickOKButtonInAlertDialog() { // throw new PendingException(); boolean isclicked = false; WebDriverWait wait = new WebDriverWait(driver, SeleniumCore.DEFAULT_WEBELEMENT_LOADING_TIME); try { Alert alert = wait.until(ExpectedConditions.alertIsPresent()); // log.info("Pop up Alert text is:"+alert.getText()); alert.authenticateUsing(new UserAndPassword("ahu", "gu.chan-10266")); alert.accept(); isclicked = true; } catch (NoAlertPresentException e) { // log.info("the Alert didn't pop up currently:"+e.getMessage()); } catch (TimeoutException e) { log.error("Time out we cannot find this OK button:" + e.getMessage()); } Assert.assertTrue(isclicked); }
/** * @Title: clickOKButtonInAlertDialog @Description: TODO @author * ahu@greendotcorp.com @param @return void return type @throws */ public void clickOKButtonInAlertDialog() { // throw new PendingException(); boolean isclicked = false; WebDriverWait wait = new WebDriverWait(driver, SeleniumCore.DEFAULT_WEBELEMENT_LOADING_TIME); try { Alert alert = wait.until(ExpectedConditions.alertIsPresent()); // log.info("Pop up Alert text is:"+alert.getText()); alert.authenticateUsing(new UserAndPassword("ahu", "gu.chan-10266")); alert.accept(); isclicked = true; } catch (NoAlertPresentException e) { // log.info("the Alert didn't pop up currently:"+e.getMessage()); } catch (TimeoutException e) { log.error("Time out we cannot find this OK button:" + e.getMessage()); } Assert.assertTrue(isclicked); }
alert.authenticateUsing(new UserAndPassword("ahu", "gu.chan-10266")); presentFlag = true;
alert.authenticateUsing(new UserAndPassword("ahu", "gu.chan-10266")); presentFlag = true;