Search in sources :

Example 76 with NoSuchElementException

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");
    }
}
Also used : WebElement(org.openqa.selenium.WebElement) NoSuchElementException(org.openqa.selenium.NoSuchElementException)

Example 77 with NoSuchElementException

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));
}
Also used : NoSuchElementException(org.openqa.selenium.NoSuchElementException) Test(org.junit.jupiter.api.Test)

Example 78 with NoSuchElementException

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));
}
Also used : NoSuchElementException(org.openqa.selenium.NoSuchElementException) Test(org.junit.jupiter.api.Test)

Example 79 with NoSuchElementException

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));
}
Also used : NoSuchElementException(org.openqa.selenium.NoSuchElementException) Test(org.junit.jupiter.api.Test)

Example 80 with NoSuchElementException

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);
}
Also used : WebDriver(org.openqa.selenium.WebDriver) WebElement(org.openqa.selenium.WebElement) NoSuchElementException(org.openqa.selenium.NoSuchElementException) NotYetImplemented(com.gargoylesoftware.htmlunit.junit.BrowserRunner.NotYetImplemented) Test(org.junit.Test) Alerts(com.gargoylesoftware.htmlunit.junit.BrowserRunner.Alerts)

Aggregations

NoSuchElementException (org.openqa.selenium.NoSuchElementException)393 WebElement (org.openqa.selenium.WebElement)212 Test (org.junit.Test)63 TimeoutException (org.openqa.selenium.TimeoutException)53 Test (org.testng.annotations.Test)50 WebDriverException (org.openqa.selenium.WebDriverException)39 MessageEvent (org.cerberus.engine.entity.MessageEvent)35 WebDriver (org.openqa.selenium.WebDriver)30 Test (org.junit.jupiter.api.Test)29 WebDriverWait (org.openqa.selenium.support.ui.WebDriverWait)29 MockitoTest (com.seleniumtests.MockitoTest)23 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)23 Select (org.openqa.selenium.support.ui.Select)22 By (org.openqa.selenium.By)21 AnswerItem (org.cerberus.util.answer.AnswerItem)18 WebElementLocator (de.learnlib.alex.data.entities.WebElementLocator)16 StaleElementReferenceException (org.openqa.selenium.StaleElementReferenceException)14 Actions (org.openqa.selenium.interactions.Actions)14 ArrayList (java.util.ArrayList)13 CerberusEventException (org.cerberus.exception.CerberusEventException)12