Java 类org.openqa.selenium.TimeoutException 实例源码

项目:bromium    文件:ActionExecutor.java   
private void executeIgnoringExceptions(WebDriver webDriver, WebDriverAction webDriverAction) {
    int i = 0;

    while (i < dependencies.getMaxRetries()) {
        try {
            webDriverAction.execute(webDriver, dependencies.getReplayingState(), dependencies.getEventSynchronizer());
            return;
        } catch (WebDriverException ex) {
            logger.error("Could not make it from first try because of {}", ex.toString());
            i++;
            try {
                Thread.sleep(dependencies.getMeasurementsPrecisionMilli());
            } catch (InterruptedException e) {
                throw dependencies.webDriverActionExecutionException("Interrupted while waiting to retry", e);
            }
        }
    }

    throw new TimeoutException("Could not execute the action! " + webDriverAction.getName());
}
项目:Selenium-Foundation    文件:SearchContextWait.java   
/**
 * {@inheritDoc}
 */
@Override
protected RuntimeException timeoutException(String message, Throwable lastException) {
    TimeoutException ex = new TimeoutException(message, lastException);
    ex.addInfo(WebDriverException.DRIVER_INFO, context.getClass().getName());
    WebDriver driver = WebDriverUtils.getDriver(context);
    if (driver instanceof RemoteWebDriver) {
        RemoteWebDriver remote = (RemoteWebDriver) driver;
        if (remote.getSessionId() != null) {
            ex.addInfo(WebDriverException.SESSION_ID, remote.getSessionId().toString());
        }
        if (remote.getCapabilities() != null) {
            ex.addInfo("Capabilities", remote.getCapabilities().toString());
        }
    }
    throw ex;
}
项目:saladium    文件:SaladiumDriver.java   
/**
 * Méthode countRowsTable. Prévoir une DIV avant la déclaration du tableau <display:table />.
 * @param type
 * @param selector
 * @return
 */
private int countRowsTable(String type, String selector) throws TimeoutException {
    int retour = 0;
    try {
        By locator = By.cssSelector(".pagebanner");
        WebElement pagebanner = wait.until(ExpectedConditions.presenceOfElementLocated(locator));
        String pageNumber = pagebanner.getText().trim().split(" ")[0];
        if (!pageNumber.equals("Aucun")) {
            return Integer.valueOf(pageNumber);
        }
    } catch (TimeoutException e) {
        String pathScreenShot = takeScreenShot();
        Assert.fail("countRowsTable impossible ! (type" + type + ", selector" + selector + ")"
            + e.getMessage() + " pathScreenShot=" + pathScreenShot);
    }
    return retour;
}
项目:devtools-driver    文件:DOMContext.java   
RemoteWebElement getDocument() {
  int cpt = 0;
  while (!isReady) {
    cpt++;
    if (cpt > 20) {
      isReady = true;
      throw new TimeoutException("doc not ready.");
    }
    try {
      Thread.sleep(250);
    } catch (InterruptedException e) {
      log.log(Level.FINE, "", e);
    }
  }
  return document;
}
项目:devtools-driver    文件:WebInspectorHelper.java   
private RemoteWebElement retrieveDocumentAndCheckReady(long deadline) {
  RemoteWebElement element = null;
  String readyState = "";
  while (!readyState.equals("complete")) {
    if (deadline > 0 && System.currentTimeMillis() > deadline) {
      throw new TimeoutException("Timeout waiting to get the document.");
    }

    try {
      if (element == null) {
        element = retrieveDocument();
      }
      readyState = element.getRemoteObject().call(".readyState");
    } catch (WebDriverException e) {
      log.info("Caught exception waiting for document to be ready. Retrying...: " + e);
      element = null;
    }
  }
  return element;
}
项目:BrainBridge    文件:BrainInstance.java   
/**
 * Initializes the instance. Call this method prior to chat interaction.
 */
public void initialize() {
    switchToWindow();
    this.mDriver.get(CHAT_SERVICE);
    final WebElement loginAnchor = new CSSSelectorPresenceWait(this.mDriver, LOGIN_ANCHOR).waitUntilCondition();
    try {
        loginAnchor.click();
    } catch (final TimeoutException e) {
        // Ignore the error as it comes from the aborted page load
    }

    final WebElement outputFrame = new FramePresenceWait(this.mDriver, CHAT_OUTPUT_FRAME_NAME).waitUntilCondition();
    final String frameSrc = outputFrame.getAttribute("src");

    final Pattern idPattern = Pattern.compile(ID_PATTERN);
    final Matcher idMatcher = idPattern.matcher(frameSrc);
    if (idMatcher.matches()) {
        this.mId = idMatcher.group(1);
    }
}
项目:POM_HYBRID_FRAMEOWRK    文件:WebUtilities.java   
/**
 * Wait for element to appear.
 *
 * @param driver the driver
 * @param element the element
 * @param logger the logger
 */
public static boolean waitForElementToAppear(WebDriver driver, WebElement element, ExtentTest logger) {
    boolean webElementPresence = false;
    try {
        Wait<WebDriver> fluentWait = new FluentWait<WebDriver>(driver).pollingEvery(2, TimeUnit.SECONDS)
                .withTimeout(60, TimeUnit.SECONDS).ignoring(NoSuchElementException.class);
        fluentWait.until(ExpectedConditions.visibilityOf(element));
        if (element.isDisplayed()) {
            webElementPresence= true;
        }
    } catch (TimeoutException toe) {
        logger.log(LogStatus.ERROR, "Timeout waiting for webelement to be present<br></br>" + toe.getStackTrace());
    } catch (Exception e) {
        logger.log(LogStatus.ERROR, "Exception occured<br></br>" + e.getStackTrace());
    }
    return webElementPresence;
}
项目:pageobjects    文件:WebElementLocatorTest.java   
@Test(expected = TimeoutException.class)
public void testLocate_context_timeout() throws Throwable {
    //prepare
    when(locator.by()).thenReturn(Locator.ByLocator.ID);
    when(locator.value()).thenReturn("testId");
    when(locator.timeout()).thenReturn(1);
    when(webElement.isDisplayed()).thenReturn(false);
    when(searchContext.findElement(By.id("testId"))).thenReturn(webElement);

    //act
    Instant start = Instant.now();
    try {
        WebElementLocator.locate(searchContext, locator);
    } finally {
        Duration dur = Duration.between(start, Instant.now());
        assertTrue(dur.compareTo(Duration.ofMillis(950)) > 0);
    }
}
项目:fogbugz-to-github    文件:GHAttachmentUploader.java   
/**
 * Download the FogBugz attachment, then reupload it to GitHub Issues. If
 * the file type is incompatible with GitHub Issues, zip it beforehand.
 * Since ZIP files are supported by GitHub Issues, this guarantees that any
 * attachment (within size constraints) will be accepted.
 *
 * @param fogBugz      The {@link FogBugz} instance that owns the
 *                     {@link FBAttachment}
 * @param fbAttachment The {@link FBAttachment}
 * @return URL of the uploaded file
 */
@Override
public String convert(final FogBugz fogBugz, final FBAttachment fbAttachment) {
    try {
        // Download FogBugz attachment
        String filename = fbAttachment.getFilename();
        String fbURL = fbAttachment.getAbsoluteUrl(fogBugz);
        File temp = FB2GHUtils.createTempFile(filename);
        int timeoutInMillis = timeoutInSeconds * 1000;
        FileUtils.copyURLToFile(new URL(fbURL), temp, timeoutInMillis, timeoutInMillis);

        // Upload to GitHub Issues
        return upload(temp);
    } catch (IOException | TimeoutException e) {
        logger.error("Could not convert: " + fbAttachment.getAbsoluteUrl(fogBugz), e);
        return fallback.convert(fogBugz, fbAttachment);
    }
}
项目:menggeqa    文件:AppiumElementLocator.java   
private List<WebElement> waitFor() {
    // When we use complex By strategies (like ChainedBy or ByAll)
    // there are some problems (StaleElementReferenceException, implicitly
    // wait time out
    // for each chain By section, etc)
    try {
        changeImplicitlyWaitTimeOut(0, TimeUnit.SECONDS);
        FluentWait<By> wait = new FluentWait<>(by);
        wait.withTimeout(timeOutDuration.getTime(), timeOutDuration.getTimeUnit());
        return wait.until(waitingFunction);
    } catch (TimeoutException e) {
        return new ArrayList<>();
    } finally {
        changeImplicitlyWaitTimeOut(timeOutDuration.getTime(), timeOutDuration.getTimeUnit());
    }
}
项目:awplab-core    文件:AutoClosableWebDriver.java   
public <T> T getWithRetry(String url, ExpectedCondition<T> expectedCondition, Long duration, TimeUnit timeUnit, int retryCount, ExpectedCondition retryImmediatelyCondition) {
    TimeoutException lastException = null;

    RetryImmediateCondition<T> condition = new RetryImmediateCondition<T>(expectedCondition, retryImmediatelyCondition);

    for (int ctr = 0; ctr < retryCount; ctr++) {
        try {
            boolean gotIt = get(url, condition, duration, timeUnit);
            if (gotIt && !condition.retry) return condition.ret;
        }
        catch (TimeoutException ignored) {
            lastException = ignored;
        }
    }

    throw lastException;

}
项目:alex    文件:WaitForTextAction.java   
@Override
protected ExecuteResult execute(final WebSiteConnector connector) {
    final WebDriverWait wait = new WebDriverWait(connector.getDriver(), maxWaitTime);

    node.setSelector(insertVariableValues(node.getSelector()));
    value = insertVariableValues(value);

    try {
        if (regexp) {
            LOGGER.info(LEARNER_MARKER, "Waiting for pattern '{}' to be present in node '{}' for a maximum of " +
                    "{}ms.", value, node, maxWaitTime);
            wait.until(ExpectedConditions.textMatches(node.getBy(), Pattern.compile(value)));
        } else {
            LOGGER.info(LEARNER_MARKER, "Waiting for text '{}' to be present in node '{}' for a maximum of {}ms.",
                        value, node, maxWaitTime);
            wait.until(ExpectedConditions.textToBePresentInElementLocated(node.getBy(), value));
        }

        return getSuccessOutput();
    } catch (NoSuchElementException | TimeoutException e) {
        LOGGER.info(LEARNER_MARKER, "Waiting for text/patter '{}' to be present in node '{}' failed.",
                    value, node);
        return getFailedOutput();
    }
}
项目:find    文件:ResultsComparisonITCase.java   
@Before
public void setUp() {
    findService = (BIFindService)getApplication().findService();
    savedSearchService = getApplication().savedSearchService();
    elementFactory = (BIIdolFindElementFactory)getElementFactory();
    findPage = elementFactory.getFindPage();
    findService.searchAnyView("careful now");

    try {
        findPage = elementFactory.getFindPage();
        findPage.waitUntilSearchTabsLoaded();
        savedSearchService.deleteAll();

        elementFactory.getConceptsPanel().removeAllConcepts();
    } catch(final TimeoutException ignored) {
        //no-op
    }
    elementFactory.getTopicMap().waitForMapLoaded();
}
项目:che    文件:CheckMavenPluginTest.java   
@Test(priority = 1)
public void shouldExcludeModules() {
  projectExplorer.openItemByPath(PROJECT_NAME + "/pom.xml");
  editor.waitActive();
  editor.goToCursorPositionVisible(25, 8);
  editor.typeTextIntoEditor("!--");
  editor.goToCursorPositionVisible(26, 32);
  editor.typeTextIntoEditor("--");
  try {
    projectExplorer.waitFolderDefinedTypeOfFolderByPath(PROJECT_NAME + "/my-lib", SIMPLE_FOLDER);
  } catch (TimeoutException ex) {
    // remove try-catch block after issue has been resolved
    fail("Known issue https://github.com/eclipse/che/issues/7109");
  }

  projectExplorer.waitFolderDefinedTypeOfFolderByPath(PROJECT_NAME + "/my-webapp", SIMPLE_FOLDER);
}
项目:kurento-room    文件:RoomClientBrowserTest.java   
public WebElement findElement(String label, Browser browser, String id) {
  try {
    return new WebDriverWait(browser.getWebDriver(), testTimeout, POLLING_LATENCY)
        .until(ExpectedConditions.presenceOfElementLocated(By.id(id)));
  } catch (TimeoutException e) {
    log.warn("Timeout when waiting for element {} to exist in browser {}", id, label);
    int originalTimeout = 60;
    try {
      originalTimeout = browser.getTimeout();
      log.debug("Original browser timeout (s): {}, set to 10", originalTimeout);
      browser.setTimeout(10);
      browser.changeTimeout(10);
      WebElement elem = browser.getWebDriver().findElement(By.id(id));
      log.info("Additional findElement call was able to locate {} in browser {}", id, label);
      return elem;
    } catch (NoSuchElementException e1) {
      log.debug("Additional findElement call couldn't locate {} in browser {} ({})", id, label,
          e1.getMessage());
      throw new NoSuchElementException("Element with id='" + id + "' not found after "
          + testTimeout + " seconds in browser " + label);
    } finally {
      browser.setTimeout(originalTimeout);
      browser.changeTimeout(originalTimeout);
    }
  }
}
项目:che    文件:ImportProjectFromGitHubTest.java   
private void connectGithubAccount() {
  projectSourcePage.clickOnConnectGithubAccountButton();
  seleniumWebDriver.switchToNoneCurrentWindow(ideWin);

  try {
    projectSourcePage.waitAuthorizationPageOpened();
  } catch (TimeoutException ex) {
    // Remove try-catch block after issue has been resolved
    fail("Known issue https://github.com/eclipse/che/issues/8250");
  }

  projectSourcePage.typeLogin(gitHubUsername);
  projectSourcePage.typePassword(gitHubPassword);
  projectSourcePage.clickOnSignInButton();
  seleniumWebDriver.switchTo().window(ideWin);

  if (!projectSourcePage.isGithubProjectsListDisplayed()) {
    seleniumWebDriver.switchToNoneCurrentWindow(ideWin);
    projectSourcePage.waitAuthorizeBtn();
    projectSourcePage.clickOnAuthorizeBtn();
    seleniumWebDriver.switchTo().window(ideWin);
  }
}
项目:che    文件:Eclipse0093Test.java   
@Test
public void test0093() throws Exception {
  projectExplorer.waitProjectExplorer();
  projectExplorer.waitItem(PROJECT_NAME);
  projectExplorer.quickExpandWithJavaScript();
  projectExplorer.openItemByPath(PROJECT_NAME + PATH_TO_PACKAGE_PREFIX + "Test.java");
  editor.waitActive();

  try {
    editor.waitMarkerInPosition(WARNING_MARKER, 12);
  } catch (TimeoutException ex) {
    // remove try-catch block after issue has been resolved
    fail("Known issue https://github.com/eclipse/che/issues/7161", ex);
  }

  editor.goToCursorPositionVisible(17, 26);
  editor.typeTextIntoEditor(Keys.F4.toString());
  editor.waitTabIsPresent("MyEnum");
  editor.waitSpecifiedValueForLineAndChar(14, 3);
}
项目:che    文件:Eclipse0121Test.java   
@Test
public void test0121() throws Exception {
  projectExplorer.waitProjectExplorer();
  projectExplorer.waitItem(PROJECT_NAME);
  projectExplorer.quickExpandWithJavaScript();
  projectExplorer.openItemByPath(PROJECT_NAME + PATH_TO_PACKAGE_PREFIX + "Test.java");
  editor.waitActive();
  editor.goToCursorPositionVisible(15, 43);
  editor.typeTextIntoEditor(Keys.F4.toString());

  try {
    editor.waitTabIsPresent("Collections");
  } catch (TimeoutException ex) {
    // remove try-catch block after issue has been resolved
    fail("Known issue https://github.com/eclipse/che/issues/7161", ex);
  }

  editor.waitSpecifiedValueForLineAndChar(14, 35);
}
项目:che    文件:Eclipse0115Test.java   
@Test
public void test0115() throws Exception {
  projectExplorer.waitProjectExplorer();
  projectExplorer.waitItem(PROJECT_NAME);
  projectExplorer.quickExpandWithJavaScript();
  projectExplorer.openItemByPath(PROJECT_NAME + PATH_TO_PACKAGE_PREFIX + "X.java");
  editor.waitActive();

  try {
    editor.waitMarkerInPosition(WARNING_MARKER, 14);
  } catch (TimeoutException ex) {
    // remove try-catch block after issue has been resolved
    fail("Known issue https://github.com/eclipse/che/issues/7161", ex);
  }

  editor.goToCursorPositionVisible(32, 14);
  editor.typeTextIntoEditor(Keys.F4.toString());
  editor.waitSpecifiedValueForLineAndChar(35, 24);
}
项目:che    文件:ProjectStateAfterRefreshTest.java   
@Test
public void checkRestoreStateOfProjectAfterRefreshTest() throws Exception {
  projectExplorer.waitProjectExplorer();
  projectExplorer.waitItem(PROJECT_NAME);
  projectExplorer.quickExpandWithJavaScript();
  consoles.closeProcessesArea();
  openFilesInEditor();
  checkFilesAreOpened();
  seleniumWebDriver.navigate().refresh();
  try {
    checkFilesAreOpened();
  } catch (TimeoutException ex) {
    // Remove try-catch block after issue has been resolved
    fail("Known issue https://github.com/eclipse/che/issues/7551");
  }
  editor.closeAllTabsByContextMenu();
}
项目:che    文件:WorkingWithTerminalTest.java   
@Test(priority = 2)
public void shouldScrollIntoTerminal() throws InterruptedException {
  openMC("/");

  try {
    // check scrolling of the terminal
    terminal.movePageDownListTerminal("opt");

  } catch (TimeoutException ex) {
    // remove try-catch block after issue has been resolved
    fail("Known issue https://github.com/eclipse/che-lib/issues/57", ex);
  }

  terminal.moveDownListTerminal(".dockerenv");
  terminal.waitExpectedTextIntoTerminal(".dockerenv");
  terminal.movePageUpListTerminal("projects");
  terminal.moveUpListTerminal("bin");
  terminal.waitExpectedTextIntoTerminal("bin");
}
项目:che    文件:WorkingWithTerminalTest.java   
@Test(priority = 4)
public void shouldNavigateToMC() {
  openMC("/");

  // navigate to midnight commander tree
  consoles.selectProcessByTabName("Terminal");
  terminal.typeIntoTerminal(Keys.ARROW_DOWN.toString());
  terminal.typeIntoTerminal(Keys.ARROW_DOWN.toString());
  terminal.typeIntoTerminal(Keys.ARROW_DOWN.toString());
  terminal.typeIntoTerminal(Keys.ARROW_DOWN.toString());
  terminal.typeIntoTerminal(Keys.ENTER.toString());
  terminal.typeIntoTerminal(Keys.ARROW_DOWN.toString());
  terminal.typeIntoTerminal(Keys.ENTER.toString());

  try {
    // check the home content of the midnight commander
    for (String partOfContent : CHECK_MC_OPENING) {
      terminal.waitExpectedTextIntoTerminal(partOfContent);
    }
  } catch (TimeoutException ex) {
    // remove try-catch block after issue has been resolved
    fail("Known issue https://github.com/eclipse/che-lib/issues/57", ex);
  }

  terminal.typeIntoTerminal(Keys.F10.toString());
}
项目:che    文件:ConvertToProjectWithPomFileTest.java   
@Test
public void checkEditorTabNameAfterChangingArtifactID() {
  projectExplorer.openItemByPath(PROJECT_NAME + "/pom.xml");
  editor.waitActive();
  editor.waitTabIsPresent("qa-spring-sample");
  editor.goToCursorPositionVisible(18, 17);
  editor.typeTextIntoEditor("new-");

  // this timeout is needed for waiting that the Editor tab name of 'pom.xml' file is changed
  WaitUtils.sleepQuietly(5);
  editor.waitTabIsPresent("new-qa-spring-sample");

  seleniumWebDriver.navigate().refresh();
  try {
    projectExplorer.waitItem(PROJECT_NAME + "/pom.xml");
  } catch (TimeoutException ex) {
    // Remove try-catch block after issue has been resolved
    fail("Known issue https://github.com/eclipse/che/issues/7551");
  }
  editor.waitTabIsPresent("new-qa-spring-sample");

  editor.closeAllTabsByContextMenu();
}
项目:che    文件:CheckRestoringWorkspaceAfterStoppingWsAgentProcess.java   
@Test()
public void checkRestoreWsAgentByApi() throws Exception {
  String expectedMessageOInDialog =
      "Workspace agent is no longer responding. To fix the problem, restart the workspace.";
  projectExplorer.waitProjectExplorer();
  projectExplorer.waitItem(PROJECT_NAME);
  terminal.waitTerminalTab();
  projectExplorer.invokeCommandWithContextMenu(
      ProjectExplorer.CommandsGoal.COMMON, PROJECT_NAME, nameCommandForKillWsAgent);

  try {
    new WebDriverWait(seleniumWebDriver, WIDGET_TIMEOUT_SEC)
        .until(
            ExpectedConditions.visibilityOfElementLocated(
                By.xpath("//span[text()='" + expectedMessageOInDialog + "']")));
  } catch (TimeoutException ex) {
    // remove try-catch block after issue has been resolved
    fail("Known issue https://github.com/eclipse/che/issues/6329");
  }

  new WebDriverWait(seleniumWebDriver, REDRAW_UI_ELEMENTS_TIMEOUT_SEC)
      .until(ExpectedConditions.visibilityOfElementLocated(By.id("ask-dialog-first")))
      .click();
  testWorkspaceServiceClient.waitStatus(workspace.getName(), defaultTestUser.getName(), RUNNING);
}
项目:che    文件:RenameTypeTest.java   
private void testCase() {
  projectExplorer.openItemByPath(pathToCurrentPackage + "/A.java");
  editor.waitTextIntoEditor(contentFromInA);
  projectExplorer.selectItem(pathToCurrentPackage + "/A.java");
  menu.runCommand(
      TestMenuCommandsConstants.Assistant.ASSISTANT,
      TestMenuCommandsConstants.Assistant.Refactoring.REFACTORING,
      TestMenuCommandsConstants.Assistant.Refactoring.RENAME);

  refactorPanel.typeAndWaitNewName("B.java");

  try {
    refactorPanel.clickOkButtonRefactorForm();
  } catch (TimeoutException ex) {
    // remove try-catch block after issue has been resolved
    fail("Known issue https://github.com/eclipse/che/issues/7500", ex);
  }

  askDialog.waitFormToOpen();
  askDialog.clickOkBtn();
  askDialog.waitFormToClose();
  refactorPanel.waitRefactorPreviewFormIsClosed();
  projectExplorer.waitItem(pathToCurrentPackage + "/B.java", 6);
  editor.waitTextIntoEditor(contentFromOutB);
}
项目:webcat-testing-platform    文件:NavigationService.java   
public <P extends IPageObject> P getPage(String name) {
    final P pageObject;
    try {
        if (pageObjectResolverMapper.containsKey(name)) {
            pageObject = pageObjectResolverMapper.get(name).getCurrentPage(driver);
        } else if (errorPageObjects.containsKey(name)) {
            pageObject = errorPageObjects.get(name).getCurrentPage(driver);
        } else {
            throw new InvalidPageObjectException("Page Object " + name + " is not registered.");
        }
    } catch(TimeoutException e) {
        throw new PageObjectNotFoundException("Could not find Page Object " + name);
    }

    return pageObject;
}
项目:web-test-framework    文件:DriverTest.java   
/**
 *
 */
@Test(groups = "local")
public void testNavigationDetection() {
  Driver driver = new DriverFactory().getDriver(BrowserVersionPlatform.WIN7FF);

  driver.navigate().to("https://google.com");
  driver.prepareToNavigateToNewUrl();

  driver.setImplicitWaitTimeInSeconds(1);

  // Test that the navigate to new url times out correctly.
  try {
    driver.waitForNavigateToNewUrl();
    Assert.fail();
  } catch (TimeoutException ex) {
  }

  driver.setImplicitWaitTimeInSeconds(4);
  driver.navigate().to("https://twitter.com");

  driver.waitForNavigateToNewUrl();

  driver.quit();
}
项目:product-emm    文件:EditRolePage.java   
public void editRole(String role){
    WebDriverWait waitLoad = new WebDriverWait(driver, 10);
    WebElement permissionItem = driver.findElement(By.xpath(uiElementMapper.getElement("emm.roles.update.permissionItemLogin")));
    permissionItem.click();
    WebElement editRoleButton = driver.findElement(By.id(uiElementMapper.getElement("emm.roles.update.role.button")));
    editRoleButton.click();
    try {
        By roleCreatedMsg  = By.xpath(uiElementMapper.getElement(("emm.roles.update.role.created.msg.div")));
        waitLoad.until(ExpectedConditions.visibilityOfElementLocated(roleCreatedMsg));
        String resultText = driver.findElement(roleCreatedMsg
        ).getText();

        if(!resultText.contains("PERMISSIONS WERE ASSIGNED TO THE ROLE SUCCESSFULLY")){
            throw new IllegalStateException("Role was not edited");
        }
    } catch (TimeoutException e) {
        throw new IllegalStateException("Role was not edited");
    }

}
项目:product-emm    文件:UserAddedPage.java   
public UserAddedPage(WebDriver driver) throws IOException {
    this.driver = driver;
    this.uiElementMapper = UIElementMapper.getInstance();
    WebDriverWait waitLoad = new WebDriverWait(driver, 10);
    try {
        By userCreateMsg  = By.xpath(uiElementMapper.getElement(("emm.users.add.user.created.msg")));
        waitLoad.until(ExpectedConditions.visibilityOfElementLocated(userCreateMsg));
        // Check that we're on the right page.
        String resultText = driver.findElement(userCreateMsg
        ).getText();
        if(!resultText.contains("USER WAS ADDED SUCCESSFULLY")){
            throw new IllegalStateException("User was not created");
        }
    } catch (TimeoutException e) {
        throw new IllegalStateException("User was not created");
    }
}
项目:product-emm    文件:UserListPage.java   
public void deleteUser() throws IOException {
    WebDriverWait waitLoad = new WebDriverWait(driver, 10);
    try {
        By deleteBtnElement = By.xpath(uiElementMapper.getElement(("emm.user.delete.button")));
        By deleteConfirmBtnElement = By.id(uiElementMapper.getElement(("emm.user.delete.button.confirm")));
        waitLoad.until(ExpectedConditions.visibilityOfElementLocated(deleteBtnElement));
        WebElement deleteButton = driver.findElement(deleteBtnElement);
        deleteButton.click();
        WebElement deleteConfirmButton = driver
                .findElement(deleteConfirmBtnElement);
        waitLoad.until(ExpectedConditions.visibilityOfElementLocated(deleteConfirmBtnElement));
        deleteConfirmButton.click();
    } catch (TimeoutException e) {
        throw new IllegalStateException("User was not deleted");
    }
}
项目:edx-app-android    文件:NativeAppDriver.java   
/**
 * Find element by the given locator after proper wait
 */
@Override
public NativeAppElement findElement(final By locator) {
    WebElement appElement = null;
    try {
        appElement = (new WebDriverWait(appiumDriver, maxWaitTime))
                .until(ExpectedConditions.presenceOfElementLocated(locator));

    } catch (Throwable te) {
        Reporter.log("Unable to find the element by locator: "
                + locator.toString() + " within " + maxWaitTime + " secs");
        captureScreenshot();
        throw new TimeoutException(te);
    }
    return new NativeAppElement(this, locator, appElement);

}
项目:webtester-core    文件:DefaultPageObjectFactory.java   
private <T extends PageObject> void waitOnPageObjectListsVisibility(T pageInstance, Field field) {

        PageObjectList<PageObject> list = getPageObjectListFromOf(field, pageInstance);
        int expected = field.getAnnotation(Visible.class).value();

        int actual = 0;
        for (PageObject pageObject : list) {
            try {
                Waits.waitUntil(pageObject, is(visible()));
                actual++;
            } catch (TimeoutException e) {
                // ignore timeout for present but not visible objects
                logger.debug("page object {} of list wasn't visible within the timeout - ignoring");
            }
        }

        if (actual != expected) {
            String message = "Expected %s elements of page object list (%s) to be visible, but there were %s.";
            throw new IllegalStateException(String.format(message, expected, field, actual));
        }

    }
项目:find    文件:ListResultsComparisonITCase.java   
@Test
@ResolvedBug("FIND-228")
public void testCompareUnsavedSearches() {
    findService.searchAnyView("\"not many results\"");
    savedSearchService.openNewTab();
    findService.searchAnyView("\"to speed up comparison\"");

    final ComparisonModal modal = findPage.openCompareModal();
    modal.select("New Search");
    modal.compareButton().click();

    Exception thrown = null;
    try {
        // server appears to cancel comparison request after 90s
        modal.waitForComparisonToLoad(100);
    } catch(final TimeoutException e) {
        thrown = e;
    }
    assertThat(thrown, nullValue());

    findPage.goBackToSearch();
}
项目:saladium    文件:SaladiumDriver.java   
@Override
public void cliquer(String type, String selector) {
    this.logger.info("cliquer type:" + type + " selector:" + selector);
    try {
        By locator = BySelec.get(type, selector);
        wait.until(ExpectedConditions.elementToBeClickable(locator)).click();
    } catch (TimeoutException e) {
        e.printStackTrace();
        String pathScreenShot = takeScreenShot();
        Assert.fail("Cliquer impossible ! (type" + type + ", selector" + selector + ") pathScreenShot=" + pathScreenShot);
    }
}
项目:devtools-driver    文件:DOMContext.java   
public void waitForLoadEvent() {
  try {
    eventsLock.lock();
    pageLoadEvent.await(30, TimeUnit.SECONDS);
  } catch (InterruptedException e) {
    throw new TimeoutException("timeout waiting for page load event.");
  } finally {
    eventsLock.unlock();
  }
}
项目:bromium    文件:ActionExecutorTest.java   
private AutomationResultBuilder getAutomationResultBuilder() {
    return throwable -> {
        if (throwable instanceof AssertionError) {
            return AutomationResult.ASSERTION_ERROR;
        } else if (throwable instanceof java.util.concurrent.TimeoutException || throwable instanceof TimeoutException) {
            return AutomationResult.TIMEOUT;
        } else if (throwable instanceof InterruptedException) {
            return AutomationResult.INTERRUPTED;
        } else if (throwable instanceof WebDriverActionExecutionException) {
            return AutomationResult.INTERRUPTED;
        }

        return AutomationResult.UNRECOGNIZED_EXCEPTION;
    };
}
项目:bromium    文件:InstanceBasedAutomationResultBuilderTest.java   
@Test
public void correctlyCreatesTimeoutExceptionSelenium() {
    Throwable throwable = new TimeoutException();
    AutomationResultBuilder automationResultBuilder = new InstanceBasedAutomationResultBuilder();
    AutomationResult automationResult = automationResultBuilder.buildAutomationResult(throwable);
    assertEquals(automationResult, AutomationResult.TIMEOUT);
}
项目:bromium    文件:InstanceBasedAutomationResultBuilderTest.java   
@Test
public void correctlyCreatesTimeoutExceptionThread() {
    Throwable throwable = new java.util.concurrent.TimeoutException();
    AutomationResultBuilder automationResultBuilder = new InstanceBasedAutomationResultBuilder();
    AutomationResult automationResult = automationResultBuilder.buildAutomationResult(throwable);
    assertEquals(automationResult, AutomationResult.TIMEOUT);
}
项目:mobileAutomation    文件:TestCase.java   
/**
 * Check for alert presence.
 * 
 * @return - true if an alert is present
 */
public boolean isAlertPresent(){
    boolean foundAlert = false;
    // check for alert presence with no timeout (0 seconds)
    WebDriverWait wait = new WebDriverWait(driver, 0);
    try {
        wait.until(ExpectedConditions.alertIsPresent());
        foundAlert = true;
    } catch (TimeoutException eTO) {
        foundAlert = false;
    }
    return foundAlert;
}
项目:pageobjects    文件:WebElementLocatorTest.java   
@Test(expected = TimeoutException.class)
public void testWaitForElement_noContext_timeout() throws Throwable {

    when(selenium.getMockDriver().findElement(By.id("test"))).thenReturn(webElement);
    when(webElement.isDisplayed()).thenReturn(false);
    selenium.execute(() -> {
        assertTrue(WebElementLocator.waitForElement(By.id("test"), 1).isPresent());
        return null;
    });
}