org.openqa.selenium.TimeoutException.getMessage()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(8.9k)|赞(0)|评价(0)|浏览(137)

本文整理了Java中org.openqa.selenium.TimeoutException.getMessage()方法的一些代码示例,展示了TimeoutException.getMessage()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TimeoutException.getMessage()方法的具体详情如下:
包路径:org.openqa.selenium.TimeoutException
类名称:TimeoutException
方法名:getMessage

TimeoutException.getMessage介绍

暂无

代码示例

代码示例来源:origin: timurstrekalov/saga

@Override
public void until(final Predicate<JavascriptExecutor> isTrue) {
  try {
    super.until(isTrue);
  } catch (final TimeoutException e) {
    logger.debug(e.getMessage());
  }
}

代码示例来源:origin: com.github.arachnidium/arachnidium-core

private void postWindowUrl(IExtendedWindow window) {
  try {
    Log.message("URL is " + window.getCurrentUrl());
  } catch (TimeoutException e) {
    Log.debug("Couldn't get the current URL. " + e.getClass() + " :"
        + e.getMessage() + " was caught");
  }
}

代码示例来源:origin: arachnidium/arachnidium-java

private void postWindowUrl(IExtendedWindow window) {
    try {
      Log.message("URL is " + window.getCurrentUrl());
    } catch (TimeoutException e) {
      Log.debug("Couldn't get the current URL. " + e.getClass() + " :"
          + e.getMessage() + " was caught");
    }
  }
}

代码示例来源:origin: com.cognifide.aet/jobs

@Override
public CollectorStepResult collect() {
 CollectorStepResult result;
 try {
  result = WaitForHelper.waitForExpectedCondition(webDriver, getTimeoutInSeconds(),
    ExpectedConditions.visibilityOfElementLocated(getLocator()),
    this::waitForImageCompletion);
 } catch (TimeoutException te) {
  final String message =
    String.format("Failed to wait for image to be loaded with provided locator. Error: %s",
      te.getMessage());
  result = CollectorStepResult.newProcessingErrorResult(message);
  LOGGER.warn(message, te);
 }
 return result;
}

代码示例来源:origin: Cognifide/aet

@Override
public CollectorStepResult collect() {
 CollectorStepResult result;
 try {
  result = WaitForHelper.waitForExpectedCondition(webDriver, getTimeoutInSeconds(),
    ExpectedConditions.visibilityOfElementLocated(getLocator()),
    this::waitForImageCompletion);
 } catch (TimeoutException te) {
  final String message =
    String.format("Failed to wait for image to be loaded with provided locator. Error: %s",
      te.getMessage());
  result = CollectorStepResult.newProcessingErrorResult(message);
  LOGGER.warn(message, te);
 }
 return result;
}

代码示例来源:origin: com.cognifide.aet/jobs

@Override
public CollectorStepResult collect() throws ProcessingException {
 CollectorStepResult result;
 try {
  result = WaitForHelper.waitForExpectedCondition(webDriver, getTimeoutInSeconds(),
    ExpectedConditions.visibilityOfElementLocated(getLocator()));
 } catch (TimeoutException te) {
  final String message =
    String.format("Failed to wait for element to be visible with provided locator. "
      + "Page: %s. Error: %s", webDriver.getCurrentUrl(), te.getMessage());
  result = CollectorStepResult.newProcessingErrorResult(message);
  LOGGER.warn(message, te);
 }
 return result;
}

代码示例来源:origin: Cognifide/aet

@Override
public CollectorStepResult collect() throws ProcessingException {
 CollectorStepResult result;
 try {
  result = WaitForHelper.waitForExpectedCondition(webDriver, getTimeoutInSeconds(),
    ExpectedConditions.visibilityOfElementLocated(getLocator()));
 } catch (TimeoutException te) {
  final String message =
    String.format("Failed to wait for element to be visible with provided locator. "
      + "Page: %s. Error: %s", webDriver.getCurrentUrl(), te.getMessage());
  result = CollectorStepResult.newProcessingErrorResult(message);
  LOGGER.warn(message, te);
 }
 return result;
}

代码示例来源:origin: com.github.becausetesting/commons

/**
 * @Title: clickCancelButtonInAlertDialog @Description: TODO @author
 *         ahu@greendotcorp.com @param @return void return type @throws
 */
public void clickCancelButtonInAlertDialog() {
  // 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.dismiss();
    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);
}

代码示例来源:origin: net.serenity-bdd/core

@Override
public WebElementFacade waitUntilPresent() {
  if (driverIsDisabled()) {
    return this;
  }
  try {
    waitForCondition().until(elementIsPresent());
  } catch (TimeoutException timeout) {
    throwShouldBePresentErrorWithCauseIfPresent(timeout, timeout.getMessage());
  }
  return this;
}

代码示例来源:origin: com.github.becauseQA/becauseQA-utils

/**
 * @Title: clickCancelButtonInAlertDialog @Description: TODO @author
 *         ahu@greendotcorp.com @param @return void return type @throws
 */
public void clickCancelButtonInAlertDialog() {
  // 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.dismiss();
    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);
}

代码示例来源:origin: net.thucydides/thucydides-core

@Override
public WebElementFacade waitUntilPresent() {
  if (driverIsDisabled()) {
    return this;
  }
  try {
    waitForCondition().until(elementIsPresent());
  } catch (TimeoutException timeout) {
    throwErrorWithCauseIfPresent(timeout, timeout.getMessage());
  }
  return this;
}

代码示例来源:origin: Wikia/selenium-tests

public boolean isDialogVisible() {
 try {
  wait.forElementVisible(salesPitchDialog, 5);
  return true;
 } catch (TimeoutException e) {
  Log.log(e.getMessage(), e, true);
  return false;
 }
}

代码示例来源:origin: Wikia/selenium-tests

public boolean isCreateNewArticleModalVisible() {
 try {
  wait.forElementVisible(addAPageButton);
  return true;
 } catch (TimeoutException e) {
  Log.info(e.getMessage());
  return false;
 }
}

代码示例来源:origin: net.serenity-bdd/serenity-core

@Override
public WebElementFacade waitUntilPresent() {
  try {
    if (!driverIsDisabled()) {
      waitForCondition().until(WebElementExpectations.elementIsPresent(this));
    }
  } catch (TimeoutException timeout) {
    throwShouldBePresentErrorWithCauseIfPresent(timeout, timeout.getMessage());
  }
  return this;
}

代码示例来源:origin: arachnidium/arachnidium-java

/**
 * Creates an alert representation 
 * 
 * @param driver {@link WebDriver} instance 
 * @param secTimeOut time out in second of awaiting for an alert
 * @throws NoAlertPresentException
 */
public AlertHandler(WebDriver driver, long secTimeOut)
    throws NoAlertPresentException {
  super(driver);
  try {
    delegate = new Awaiting(driver)
        .awaitCondition(secTimeOut,
            ExpectedConditions.alertIsPresent());
  } catch (TimeoutException e) {
    throw new NoAlertPresentException(e.getMessage(), e);
  }
}

代码示例来源:origin: com.github.arachnidium/arachnidium-core

/**
 * Creates an alert representation 
 * 
 * @param driver {@link WebDriver} instance 
 * @param secTimeOut time out in second of awaiting for an alert
 * @throws NoAlertPresentException
 */
public AlertHandler(WebDriver driver, long secTimeOut)
    throws NoAlertPresentException {
  super(driver);
  try {
    delegate = new Awaiting(driver)
        .awaitCondition(secTimeOut,
            ExpectedConditions.alertIsPresent());
  } catch (TimeoutException e) {
    throw new NoAlertPresentException(e.getMessage(), e);
  }
}

代码示例来源:origin: arquillian/arquillian-graphene

@Test
public void testMessageUntil() {
  String message = "blah blah blah blah blah";
  try {
    Graphene.waitGui()
        .until(message)
        .element(BY_HEADER)
        .text()
        .equalTo("sjkldhkdjfgjlkfg");
    Assert.fail(TimeoutException.class.getName() + " should be thrown.");
  } catch (TimeoutException e) {
    Assert.assertTrue("The exception message <" + e.getMessage() + "> should contain message <" + message + "> defined by 'withMessage()' method", e.getMessage().contains(message));
  }
}

代码示例来源:origin: arquillian/arquillian-graphene

@Test
public void testWithMessage() {
  String message = "blah blah blah blah blah";
  try {
    Graphene.waitGui()
        .withMessage(message)
        .until()
        .element(BY_HEADER)
        .text()
        .equalTo("sjkldhkdjfgjlkfg");
    Assert.fail(TimeoutException.class.getName() + " should be thrown.");
  } catch (TimeoutException e) {
    Assert.assertTrue("The exception message <" + e.getMessage() + "> should contain message <" + message + "> defined by 'withMessage()' method", e.getMessage().contains(message));
  }
}

代码示例来源:origin: arquillian/arquillian-graphene

@Test
public void testWithMessageAndMessageUntil() {
  String message = "blah blah blah blah blah";
  try {
    Graphene.waitGui()
        .withMessage("srhjkfsdbhfjkfbsdnbfm,sndbsdmnbf")
        .until(message)
        .element(BY_HEADER)
        .text()
        .equalTo("sjkldhkdjfgjlkfg");
    Assert.fail(TimeoutException.class.getName() + " should be thrown.");
  } catch (TimeoutException e) {
    Assert.assertTrue("The exception message <" + e.getMessage() + "> should contain message <" + message + "> defined by 'withMessage()' method", e.getMessage().contains(message));
  }
}

代码示例来源:origin: Wikia/selenium-tests

private boolean isElementVisible(WebElement element) {
  try {
   wait.forElementVisible(element);
   return element.isDisplayed();
  } catch (TimeoutException e) {
   Log.info(e.getMessage());
   return false;
  }
 }
}

相关文章