List of usage examples for org.openqa.selenium.support.ui ExpectedConditions alertIsPresent
public static ExpectedCondition<Alert> alertIsPresent()
From source file:npg.webadmin.acceptance.test.navigation.stepdefs.WebAdminSiteAccountAdminFunctionalDefinitions.java
@When("user searches site \"([^\"]*)\" with existing inactive license$") public void functionalSearchAndActivateSite(String siteId) { // to WebAdmin main page navigationService.toWebAdminMainPage(webDriver); // select 'Main Site License Search navigationService.toWebAdminMainSiteLicenseSearch(webDriver); // search for Site ID navigationService.toWebAdminMainSiteLicenseSearchSiteId(webDriver, siteId); try {//from w w w . j a va2 s . c o m webDriver.findElement(By.xpath( "//a[text()[normalize-space(.)='inactive']][@href='webAdmin.do?initparam=updateSiteAccountStatus&site_account_id=" + siteId + "']")); } catch (NoSuchElementException e) { // the license is currently active. make it inactive webDriver.findElement(By.xpath( "//a[contains(text(), 'active')][@href='webAdmin.do?initparam=updateSiteAccountStatus&site_account_id=" + siteId + "']")) .click(); WebDriverWait wait = new WebDriverWait(webDriver, 10); wait.until(ExpectedConditions.alertIsPresent()); Alert alert = webDriver.switchTo().alert(); System.out.println("Activate alert box text --------> " + alert.getText() + " ----------"); alert.accept(); // go back to search and this time the site is inactive navigationService.toWebAdminMainPage(webDriver); navigationService.toWebAdminMainSiteLicenseSearch(webDriver); navigationService.toWebAdminMainSiteLicenseSearchSiteId(webDriver, siteId); } }
From source file:npg.webadmin.acceptance.test.navigation.stepdefs.WebAdminSiteAccountAdminFunctionalDefinitions.java
@Then("^confirm window message \"([^\"]*)\" should display at site \"([^\"]*)\"$") public void functionalAssertConfirmWindowMessage(String message, String siteId) { webDriver.findElement(By.xpath(// w w w .ja va2 s .c o m "//a[contains(text(), 'active')][@href='webAdmin.do?initparam=updateSiteAccountStatus&site_account_id=" + siteId + "']")) .click(); try { //System.out.println("====== wait for alert window to popup ===== "); WebDriverWait wait = new WebDriverWait(webDriver, 10); wait.until(ExpectedConditions.alertIsPresent()); try { //System.out.println("xxxxx START " ); Alert alert = webDriver.switchTo().alert(); //System.out.println("xxxxx alert is " + (alert == null?"null":"not null")); String alertText = alert.getText(); //System.out.println("Alert box text --------> " + alertText + " ----------"); //System.out.println("Alert param message ---> " + message + " ----------"); alert.accept(); assertTrue("Alert message is invalid.", message.trim().equals(alertText.trim())); } catch (NoAlertPresentException e2) { //System.out.println("++++++ NoAlertPresentException " + e2.getMessage()); assertTrue("No Alert Present Exception", false); } catch (Exception e2) { assertTrue("General exception generated during alert verification", false); //System.out.println("++++++ Exception " + e2.getMessage()); //e2.printStackTrace(); } } catch (Exception e) { System.out.println("++++++" + e.getMessage()); assertTrue("General exception generated. No alert message is found.", false); } }
From source file:org.callimachusproject.webdriver.helpers.WebBrowserDriver.java
License:Apache License
public void confirm(String msg) { new WebDriverWait(driver, 120).ignoring(NoAlertPresentException.class) .until(ExpectedConditions.alertIsPresent()); Alert alert = driver.switchTo().alert(); assertTrue(alert.getText().contains(msg)); alert.accept();/*from www . j a v a 2 s .c o m*/ waitForScript(); }
From source file:org.eclipse.che.selenium.factory.CheckFactoryWithSincePolicyTest.java
License:Open Source License
@Test public void checkFactoryAcceptingWithSincePolicy() throws Exception { // check factory now, make sure its restricted dashboard.open();//from w w w .j a v a 2 s. c o m testFactory.open(ide.driver()); //driver.get(factoryUrl); new WebDriverWait(ide.driver(), PREPARING_WS_TIMEOUT_SEC).until(ExpectedConditions.alertIsPresent()); assertTrue(ide.driver().switchTo().alert().getText().contains(ALERT_EXPIRE_MESSAGE), "actual message: " + ide.driver().switchTo().alert().getText()); popupDialogsBrowser.acceptAlert(); // wait until factory becomes avaialble while (System.currentTimeMillis() <= INIT_TIME + ADDITIONAL_TIME) { WaitUtils.sleepQuietly(1); } // check again testFactory.open(ide.driver()); seleniumWebDriver.switchFromDashboardIframeToIde(); projectExplorer.waitProjectExplorer(); }
From source file:org.eclipse.che.selenium.factory.CheckFactoryWithUntilPolicyTest.java
License:Open Source License
@Test public void checkFactoryAcceptingWithUntilPolicy() throws Exception { // first//w w w .j a v a2s. co m dashboard.open(); testFactory.open(seleniumWebDriver); seleniumWebDriver.switchFromDashboardIframeToIde(); projectExplorer.waitProjectExplorer(); while (System.currentTimeMillis() <= INIT_TIME + ADDITIONAL_TIME) { if (popupDialogsBrowser.isAlertPresent()) { popupDialogsBrowser.acceptAlert(); fail("Factory expired before the until period"); } WaitUtils.sleepQuietly(1); } // second testFactory.open(seleniumWebDriver); new WebDriverWait(seleniumWebDriver, PREPARING_WS_TIMEOUT_SEC).until(ExpectedConditions.alertIsPresent()); assertTrue(seleniumWebDriver.switchTo().alert().getText().contains(ALERT_EXPIRE_MESSAGE), "actual message: " + seleniumWebDriver.switchTo().alert().getText()); popupDialogsBrowser.acceptAlert(); }
From source file:org.eclipse.che.selenium.pageobject.PopupDialogsBrowser.java
License:Open Source License
/** Wait pop up browser window is closed */ public void waitAlertClose() { new WebDriverWait(seleniumWebDriver, 20).until(ExpectedConditions.not(ExpectedConditions.alertIsPresent())); }
From source file:org.kurento.tutorial.crowddetector.test.CrowdDetectorIT.java
License:Open Source License
@Test public void testCrowdDetector() throws InterruptedException { // Start application driver.findElement(By.id("start")).click(); // Check alert WebDriverWait wait = new WebDriverWait(driver, ALERT_TIMEOUT); try {/*from ww w . j a v a 2s. c om*/ if (wait.until(ExpectedConditions.alertIsPresent()) != null) { driver.switchTo().alert().accept(); driver.findElement(By.id("address")) .sendKeys("rtsp://184.72.239.149/vod/mp4:BigBuckBunny_175k.mov"); driver.findElement(By.id("changeFeed")).click(); if (wait.until(ExpectedConditions.alertIsPresent()) != null) { driver.switchTo().alert().accept(); driver.findElement(By.id("start")).click(); } } } catch (TimeoutException te) { log.warn(te.getMessage()); } // Assessment #1: Remote video tag should play media waitForStream("videoOutput"); // Guard time to see application in action Thread.sleep(PLAY_TIME * 1000); // Stop application driver.findElement(By.id("stop")).click(); }
From source file:org.openmrs.steps.DashboardPageSteps.java
License:Open Source License
@Then("an alert is displayed and I hit ok") public void closeAlert() { WebDriverWait wait = new WebDriverWait(driver, 2); wait.until(ExpectedConditions.alertIsPresent()); Alert alert = driver.switchTo().alert(); alert.accept();//from ww w . j a v a2 s. c o m driver.switchTo().defaultContent(); }
From source file:org.openmrs.steps.EditPatientPageSteps.java
License:Open Source License
@When("I double confirm delete forever") public void confirmDeleteForever() { WebElement btn = driver/*from w ww. j a va 2 s . c om*/ .findElement(By.cssSelector("#deletePatientDiv input[value=\"Delete Patient Forever\"]")); btn.click(); try { WebDriverWait wait = new WebDriverWait(driver, 2); wait.until(ExpectedConditions.alertIsPresent()); Alert alert = driver.switchTo().alert(); alert.accept(); driver.switchTo().defaultContent(); } catch (Exception e) { //exception handling } }
From source file:org.opennms.smoketest.MenuHeaderTest.java
License:Open Source License
@Test public void testMenuEntries() throws Exception { clickMenuItem("Search", null, "element/index.jsp"); findElementByXpath("//h3[text()='Search for Nodes']"); clickMenuItem("Info", "Nodes", "element/nodeList.htm"); findElementByXpath("//h3//span[text()='Nodes' or text()='Availability']"); clickMenuItem("Info", "Assets", "asset/index.jsp"); findElementByXpath("//h3[text()='Search Asset Information']"); clickMenuItem("Info", "Path Outages", "pathOutage/index.jsp"); findElementByXpath("//h3[text()='All Path Outages']"); clickMenuItem("Status", "Events", "event/index"); findElementByXpath("//h3[text()='Event Queries']"); clickMenuItem("Status", "Alarms", "alarm/index.htm"); findElementByXpath("//h3[text()='Alarm Queries']"); clickMenuItem("Status", "Notifications", "notification/index.jsp"); findElementByXpath("//h3[text()='Notification queries']"); clickMenuItem("Status", "Outages", "outage/index.jsp"); findElementByXpath("//h3[text()='Outage Menu']"); clickMenuItem("Status", "Distributed Status", "distributedStatusSummary.htm"); findElementByXpath("//h3[contains(text(), 'Distributed Status Summary')]"); clickMenuItem("Status", "Surveillance", "surveillanceView.htm?viewName=default"); wait.until(ExpectedConditions/*from w w w . j a v a 2 s. c o m*/ .visibilityOfElementLocated(By.xpath("//h3[text()='Surveillance View: default']"))); clickMenuItem("Reports", "Charts", "charts/index.jsp"); wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("include-charts"))); clickMenuItem("Reports", "Resource Graphs", "graph/index.jsp"); wait.until(ExpectedConditions .visibilityOfElementLocated(By.xpath("//h3[contains(text(), 'Standard Resource')]"))); clickMenuItem("Reports", "KSC Reports", "KSC/index.htm"); findElementByXpath("//h3[text()='Customized Reports']"); clickMenuItem("Reports", "Statistics", "statisticsReports/index.htm"); findElementByXpath("//h3[text()='Statistics Report List']"); clickMenuItem("Dashboards", "Dashboard", "dashboard.jsp"); findElementByXpath("//h3[text()='Surveillance View: default']"); clickMenuItem("Dashboards", "Ops Board", "vaadin-wallboard"); findElementByXpath("//select[@class='v-select-select']"); frontPage(); clickMenuItem("Maps", "Distributed", "RemotePollerMap/index.jsp"); m_driver.switchTo().frame("app"); wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("gwt-uid-1"))); frontPage(); clickMenuItem("Maps", "Topology", "topology"); wait.until(ExpectedConditions .visibilityOfElementLocated(By.xpath("//div[contains(text(), 'Last update time')]"))); frontPage(); clickMenuItem("Maps", "Geographical", "node-maps"); wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[text()='Show Severity >=']"))); frontPage(); clickMenuItem("Maps", "SVG", "map/index.jsp"); findElementById("opennmsSVGMaps"); try { final Alert alert = wait.until(ExpectedConditions.alertIsPresent()); alert.dismiss(); } catch (final Exception e) { } frontPage(); clickMenuItem("name=nav-admin-top", "Configure OpenNMS", BASE_URL + "opennms/admin/index.jsp"); findElementByXpath("//h3[text()='OpenNMS System']"); findElementByXpath("//h3[text()='Operations']"); frontPage(); clickMenuItem("name=nav-admin-top", "Quick-Add Node", BASE_URL + "opennms/admin/node/add.htm"); findElementByXpath("//h3[text()='Node Quick-Add']"); frontPage(); clickMenuItem("name=nav-admin-top", "Help/Support", BASE_URL + "opennms/support/index.htm"); findElementByXpath("//h3[text()='Commercial Support']"); frontPage(); clickMenuItem("name=nav-admin-top", "Log Out", BASE_URL + "opennms/j_spring_security_logout"); findElementById("input_j_username"); }