Package org.openqa.selenium

Examples of org.openqa.selenium.NoSuchElementException


    public WebElement findElement(SearchContext context) {
        installJQueryExtension();

        List<WebElement> elements = findElements(context);
        if (elements == null || elements.size() == 0) {
            throw new NoSuchElementException("Cannot locate element using: " + jquerySelector);
        }
        return elements.get(0);
    }
View Full Code Here


  }

  @Override
  protected WebElement getDelegate() {
    long startTime = System.currentTimeMillis();
    NoSuchElementException exception;
    do {
      try {
        return elementLocator.findElement();
      } catch (NoSuchElementException e) {
        exception = e;
View Full Code Here

    @Override
    public WebElement findElement(SearchContext context) {
        List<WebElement> elements = findElements(context);
        if (elements == null || elements.isEmpty()) {
            throw new NoSuchElementException("Cannot locate element using: " + selector);
        }
        return elements.get(0);
    }
View Full Code Here

        WebElement variantA = mock(WebElement.class);
        WebElement variantB = mock(WebElement.class);

        when(driver.findElement(By.xpath(VARIANT_A))).thenReturn(variantA);
        when(driver.findElement(By.xpath(VARIANT_B))).thenReturn(variantB);
        when(driver.findElement(By.xpath(VARIANT_C))).thenThrow(new NoSuchElementException(VARIANT_C));
        when(variantA.isSelected()).thenReturn(true);
        when(variantB.isSelected()).thenReturn(false);

        return driver;
    }
View Full Code Here

    @Test
    public void sendkeys_should_monitor_even_for_failing_situation() {

        FluentExecutionStopped fes = new FluentExecutionStopped("x", new NullPointerException());

        when(webDriver.findElement(By.tagName("div"))).thenThrow(new NoSuchElementException("boo"));
        when(monitor.start("div()")).thenReturn(timer);
        when(monitor.exceptionDuringExecution(any(FluentExecutionStopped.class), any(WebElement.class))).thenReturn(fes);

        try {
            fluentWebDriver.div().sendKeys("abc");
View Full Code Here

    @Test
    public void referenceException() {

        WebDriver wd = mock(WebDriver.class);
        when(wd.findElement(tagName("button"))).thenThrow(new NoSuchElementException("boo"));

        FluentWebDriver fwd = new FluentWebDriver(wd, new ExceptionCounter());

        try {
            fwd.button();
View Full Code Here

        WebDriver wd = mock(WebDriver.class);

        FluentWebDriver fwd = new FluentWebDriver(wd, new ExceptionCounter());

        when(wd.findElement(tagName("button"))).thenThrow(new NoSuchElementException("boo"));
        assertThat(fwd.hasMissing().button(), equalTo(true));
        assertThat(fwd.has().button(), equalTo(false));
        Assert.assertThat(count, IsEqual.equalTo(0));

    }
View Full Code Here

        FluentWebDriver fwd = new FluentWebDriver(wd, new ExceptionCounter());

        when(wd.findElement(tagName("div"))).thenReturn(we);
        when(we.getTagName()).thenReturn("div");
        when(we.findElement(tagName("button"))).thenThrow(new NoSuchElementException("boo"));

        assertThat(fwd.div().hasMissing().button(), equalTo(true));
        assertThat(fwd.div().has().button(), equalTo(false));
        Assert.assertThat(count, IsEqual.equalTo(0));
View Full Code Here

        FluentWebDriver.BooleanResultsAdapter bwa = new FluentWebDriver.BooleanResultsAdapter(wd, m, c);

        int count = 0;

        Method[] methods = FluentWebDriver.BooleanResultsAdapter.class.getDeclaredMethods();
        when(wd.findElement(byID)).thenThrow(new NoSuchElementException("boo"));
        for (Method method : methods) {
            String name = method.getName();
            if (method.getReturnType().equals(Boolean.TYPE) && !name.equals("returnBool")) {
                if (method.getParameterTypes().length == 0) {
                    when(wd.findElement(tagName(name.replace("link","a")))).thenThrow(new NoSuchElementException("boo"));
                    assertFalse((Boolean) method.invoke(bwa));
                } else {
                    assertFalse((Boolean) method.invoke(bwa, byID));
                }
                count++;
View Full Code Here

    @Override
    public WebElement findElement(SearchContext context) {
        List<WebElement> elements = findElements(context);
        if (elements == null || elements.isEmpty()) {
            throw new NoSuchElementException("Cannot locate element using: " + jquerySelector);
        }
        return elements.get(0);
    }
View Full Code Here

TOP

Related Classes of org.openqa.selenium.NoSuchElementException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.