本文整理了Java中org.openqa.selenium.NoSuchElementException.getMessage()
方法的一些代码示例,展示了NoSuchElementException.getMessage()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。NoSuchElementException.getMessage()
方法的具体详情如下:
包路径:org.openqa.selenium.NoSuchElementException
类名称:NoSuchElementException
方法名:getMessage
暂无
代码示例来源:origin: com.lohika.alp/alp-selenium
/**
* Instantiates a new no such element exception.
*
* @param description the description
* @param cause the cause
*/
public NoSuchElementException(LogDescriptionBean description,
org.openqa.selenium.NoSuchElementException cause) {
super(null, cause);
this.description = description;
this.locator = parseLocator(cause.getMessage());
}
代码示例来源:origin: arquillian/arquillian-graphene
@Override
public Object getTarget() {
try {
return dropProxyAndFindElement(by, searchContext);
} catch (NoSuchElementException ex) {
throw new NoSuchElementException((by instanceof ByIdOrName ? EMPTY_FIND_BY_WARNING : "") + ex.getMessage(),
ex);
}
}
});
代码示例来源:origin: org.jboss.arquillian.graphene/graphene-webdriver-impl
@Override
public Object getTarget() {
try {
return dropProxyAndFindElement(by, searchContext);
} catch (NoSuchElementException ex) {
throw new NoSuchElementException((by instanceof ByIdOrName ? EMPTY_FIND_BY_WARNING : "") + ex.getMessage(),
ex);
}
}
});
代码示例来源:origin: qaprosoft/carina
/**
* Find the element list.
*/
public List<WebElement> findElements() {
List<WebElement> elements = null;
NoSuchElementException exception = null;
try {
elements = searchContext.findElements(by);
} catch (NoSuchElementException e) {
LOGGER.debug("Unable to find elements: " + e.getMessage());
}
//TODO: incorporate find by AI???
// If no luck throw general NoSuchElementException
if (elements == null) {
throw exception != null ? exception : new NoSuchElementException("Unable to find elements by Selenium");
}
// we can't enable cache for lists by default as we can't handle/catch list.get(index).action(). And for all dynamic lists
// As result for all dynamic lists we have too often out of bound index exceptions
return elements;
}
代码示例来源:origin: net.thucydides/thucydides-core
@Override
protected void isLoaded() throws Error {
try {
element = SmartAjaxElementLocator.super.findElement();
if (!isElementUsable(element)) {
throw new NoSuchElementException("Element is not usable " + element.toString());
}
} catch (NoSuchElementException e) {
lastException = e;
// Should use JUnit's AssertionError, but it may not be present
throw new NoSuchElementError("Unable to locate the element: " + e.getMessage(), e);
}
}
代码示例来源:origin: net.thucydides/thucydides-core
@Override
protected void isLoaded() throws Error {
try {
elements = SmartAjaxElementLocator.super.findElements();
if (elements.size() == 0) {
/*return even if empty and don't wait for them to become available.
*not sure that it is the correct approach for Ajax Element Locator that should wait for elements
*however correcting it due to https://java.net/jira/browse/THUCYDIDES-187 */
return;
}
for (WebElement element : elements) {
if (!isElementUsable(element)) {
throw new NoSuchElementException("Element is not usable");
}
}
} catch (NoSuchElementException e) {
lastException = e;
// Should use JUnit's AssertionError, but it may not be present
throw new NoSuchElementError("Unable to locate the element " + e.getMessage(), e);
}
}
代码示例来源:origin: org.kurento/kurento-room-test
public void verifyVideoInBrowser(Browser browser, String browserLabel, String chromeName,
String videoElementId, boolean isActive) {
if (isActive) {
log.debug("Verifing element {} exists in browser of {}", videoElementId, chromeName);
try {
WebElement video = findElement(browserLabel, browser, videoElementId);
if (video == null) {
fail("Video element " + videoElementId + " was not found in browser of " + chromeName);
}
} catch (NoSuchElementException e) {
fail(e.getMessage());
}
log.debug("OK - element {} found in browser of {}", videoElementId, chromeName);
} else {
log.debug("Verifing element {} is missing from browser of {}", videoElementId, chromeName);
try {
waitWhileElement(browserLabel, browser, videoElementId);
} catch (TimeoutException e) {
fail(e.getMessage());
}
log.debug("OK - element {} is missing from browser of {}", videoElementId, chromeName);
}
}
代码示例来源:origin: org.kurento/kurento-room-test
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);
}
}
}
代码示例来源:origin: Wikia/selenium-tests
private boolean isElementVisible(WebElement element) {
try {
return element.isDisplayed();
} catch (NoSuchElementException e) {
Log.info(e.getMessage());
return false;
}
}
代码示例来源:origin: Wikia/selenium-tests
/**
* Method to check if WebElement is displayed on the page
*
* @return true if element is displayed, otherwise return false
*/
protected boolean isElementDisplayed(WebElement element) {
try {
return element.isDisplayed();
} catch (NoSuchElementException e) {
Log.info(e.getMessage());
return false;
}
}
代码示例来源:origin: qaprosoft/carina
element = searchContext.findElements(by).get(0);
LOGGER.debug("Unable to find element: " + e.getMessage());
代码示例来源:origin: vmi/selenese-runner-java
String msg = e.getMessage();
int nlIndex = msg.indexOf('\n');
if (nlIndex > 0) {
代码示例来源:origin: arquillian/arquillian-graphene
@Test
public void testFindNonExistingElement() {
try {
browser.findElement(ByJQuery.selector(":contains('non existing string')"));
} catch (NoSuchElementException ex) {
// this is desired state
assertTrue("Error message of NoSuchElementException is wrong! ", ex.getMessage()
.contains(EXPECTED_NO_SUCH_EL_EX_MSG));
return;
}
fail("There was not thrown NoSuchElementException when trying to locate non existed element!");
}
代码示例来源:origin: gradle.plugin.GoBqa/gradle-plugin
private void cmdJavaScriptOnClick(Properties p, String objectName, String objectType, WebDriverWait wait)
throws Exception {
// Si se ha configurado la propiedad de "Scroll and Click" entonces hace un scroll primero.
if (scrollAndClick) {
cmdScroll(p, objectName, objectType, wait, "");
}
WebElement weAux;
// Lo correcto seria poner:
// weAux = buscarElemento(driver,this.getObject(p, objectName, objectType),p);
// Pero entiendo que en este caso es lo mismo, con lo cual lo dejo como estaba y no hago el refactor
// en estas instrucciones por si acaso hay un efecto no deseado entre la configuracion del timeOut del
// wait y la de la tolerancia
// weAux = (WebElement) wait.until(ExpectedConditions.
// visibilityOfElementLocated(this.getObject(p, objectName, objectType)));
try {
weAux=buscarElemento(driver,this.getObject(p, objectName, objectType),p);
JavascriptExecutor exec = (JavascriptExecutor) driver;
exec.executeScript("arguments[0].on", weAux);
}catch(NoSuchElementException e){
track.fail("Objeto No encontrado.\n"
+e.getMessage());
}
}
/**
代码示例来源:origin: gradle.plugin.GoBqa/gradle-plugin
private void cmdJavaScriptClick(Properties p, String objectName, String objectType, WebDriverWait wait)
throws Exception {
// Si se ha configurado la propiedad de "Scroll and Click" entonces hace un scroll primero.
if (scrollAndClick) {
cmdScroll(p, objectName, objectType, wait, "");
}
WebElement weAux;
// Lo correcto seria poner:
// weAux = buscarElemento(driver,this.getObject(p, objectName, objectType),p);
// Pero entiendo que en este caso es lo mismo, con lo cual lo dejo como estaba y no hago el refactor
// en estas instrucciones por si acaso hay un efecto no deseado entre la configuracion del timeOut del
// wait y la de la tolerancia
// weAux = (WebElement) wait.until(ExpectedConditions.
// visibilityOfElementLocated(this.getObject(p, objectName, objectType)));
try {
weAux=buscarElemento(driver,this.getObject(p, objectName, objectType),p);
JavascriptExecutor exec = (JavascriptExecutor) driver;
exec.executeScript("arguments[0].click()", weAux);
}catch(NoSuchElementException e){
track.fail("Objeto No encontrado.\n"
+e.getMessage());
}
}
内容来源于网络,如有侵权,请联系作者删除!