use of org.openqa.selenium.NoSuchElementException in project flow-components by vaadin.
the class GridTestPageIT method assertItemIsPresent.
private void assertItemIsPresent(WebElement grid, String itemId, String expectedInnerText) {
try {
WebElement item = grid.findElement(By.id(itemId));
Assert.assertEquals(expectedInnerText, getInnerText(item));
} catch (NoSuchElementException ex) {
Assert.fail("Item with Id '" + itemId + "' should be in the Grid");
}
}
use of org.openqa.selenium.NoSuchElementException in project vividus by vividus-framework.
the class ExpectedSearchActionsConditionsTests method testElementSelectionStateToBeNoElement.
@Test
void testElementSelectionStateToBeNoElement() {
when(locator.toString()).thenReturn(TEXT);
mockFindElements();
IExpectedSearchContextCondition<Boolean> condition = expectedSearchActionsConditions.elementSelectionStateToBe(locator, false);
NoSuchElementException exception = assertThrows(NoSuchElementException.class, () -> condition.apply(searchContext));
assertThat(exception.getMessage(), containsString(NO_SUCH_ELEMENT));
}
use of org.openqa.selenium.NoSuchElementException in project vividus by vividus-framework.
the class ExpectedSearchActionsConditionsTests method testVisibilityOfElementNoSuchElement.
@Test
void testVisibilityOfElementNoSuchElement() {
when(searchActions.findElements(searchContext, locator)).thenThrow(new NoSuchElementException(TEXT));
assertNull(expectedSearchActionsConditions.visibilityOfElement(locator).apply(searchContext));
}
use of org.openqa.selenium.NoSuchElementException in project vividus by vividus-framework.
the class ExpectedSearchActionsConditionsTests method testTextToBePresentInElementLocatedNoElements.
@Test
void testTextToBePresentInElementLocatedNoElements() {
when(locator.toString()).thenReturn(TEXT);
mockFindElements();
IExpectedSearchContextCondition<Boolean> condition = expectedSearchActionsConditions.textToBePresentInElementLocated(locator, TEXT);
NoSuchElementException exception = assertThrows(NoSuchElementException.class, () -> condition.apply(searchContext));
assertThat(exception.getMessage(), containsString(NO_SUCH_ELEMENT));
}
use of org.openqa.selenium.NoSuchElementException in project htmlunit by HtmlUnit.
the class HtmlPage3Test method shouldBeAbleToFindElementByXPathInXmlDocument.
/**
* @throws Exception if an error occurs
*/
@Test
@Alerts(DEFAULT = "error", CHROME = "Something", EDGE = "Something")
@NotYetImplemented({ IE, FF, FF_ESR })
public void shouldBeAbleToFindElementByXPathInXmlDocument() throws Exception {
final String html = "<?xml version='1.0' encoding='UTF-8'?>\n" + "<html xmlns='http://www.w3.org/1999/xhtml'\n" + " xmlns:svg='http://www.w3.org/2000/svg'\n" + " xmlns:xlink='http://www.w3.org/1999/xlink'>\n" + "<body>\n" + " <svg:svg id='chart_container' height='220' width='400'>\n" + " <svg:text y='16' x='200' text-anchor='middle'>Something</svg:text>\n" + " </svg:svg>\n" + "</body>\n" + "</html>\n";
final WebDriver driver = loadPage2(html, URL_FIRST, "application/xhtml+xml", ISO_8859_1, null);
String actual;
try {
final WebElement element = driver.findElement(By.xpath("//svg:svg//svg:text"));
actual = element.getText();
} catch (final NoSuchElementException e) {
actual = "error";
}
assertEquals(getExpectedAlerts()[0], actual);
}
Aggregations