Package org.openqa.selenium

Examples of org.openqa.selenium.StaleElementReferenceException


    public class StaleElementAnswer implements Answer<Object> {

        @Override
        public Object answer(InvocationOnMock invocation) throws Throwable {
            if (isStale((WebElement) invocation.getMock())) {
                throw new StaleElementReferenceException("");
            }
            return Answers.RETURNS_SMART_NULLS.get().answer(invocation);
        }
View Full Code Here


  public RemoteWebElement createElement(String elementId) {
    int pageId = Integer.parseInt(elementId.split("_")[0]);
    int nodeId = Integer.parseInt(elementId.split("_")[1]);

    if (currentInspector.getPageIdentifier() != pageId) {
      throw new StaleElementReferenceException("Node " + nodeId
                                               + "is stale.It might still exist, but the "
                                               + "window with focus has changed.");
    }
    if (session != null) {
      return new RemoteWebNativeBackedElement(new NodeId(nodeId), currentInspector, session);
View Full Code Here

  }

  private void assertElementNotStale() {
    // Has the user navigated away from the page this object belongs to?
    if (!parent.objectIds.contains(objectId)) {
      throw new StaleElementReferenceException(
          "Element appears to be stale.  Did you navigate away from the page that contained it?  "
          + "And is the current window focussed the same as the one holding this element?");
    }

    // Check if current document contains this element
    if (Boolean.valueOf(callMethod("locator.parentNode == undefined"))) {
      throw new StaleElementReferenceException(
          "The element seems to be disconnected from the DOM.  This means that the user cannot "
          + "interact with it.");
    }
  }
View Full Code Here

      Boolean isStale =
          Boolean.valueOf(debugger.callFunctionOnObject("locator.parentNode == undefined", id));

      if (isStale) {
        throw new StaleElementReferenceException("This element is no longer part of DOM");
      }

      return new OperaWebElement(this, id);
    } else {
      throw new NoSuchElementException("Cannot find element(s) with " + by);
View Full Code Here

    if (isAvailable) {
      Boolean isStale =
          Boolean.valueOf(debugger.callFunctionOnObject("locator.parentNode == undefined", id));

      if (isStale) {
        throw new StaleElementReferenceException("This element is no longer part of DOM");
      }

      return new OperaWebElement(this, id);
    } else {
      throw new NoSuchElementException("Cannot find element(s) with " + type);
View Full Code Here

          
    case 9:
      throw new UnsupportedOperationException("You may not perform the requested action");
     
    case 10:
      throw new StaleElementReferenceException(
          String.format("You may not %s this element. It looks as if the reference is stale. " +
                        "Did you navigate away from the page with this element on?", message));

    case 11:
      throw new ElementNotVisibleException(
View Full Code Here

  protected void assertElementNotStale() {
    SgmlPage elementPage = element.getPage();
    Page currentPage = parent.lastPage();

    if (!currentPage.equals(elementPage)) {
      throw new StaleElementReferenceException(
          "Element appears to be stale. Did you navigate away from the page that contained it? "
          + " And is the current window focussed the same as the one holding this element?");
    }

    // We need to walk the DOM to determine if the element is actually attached
    DomNode parent = element;
    while (parent != null && !(parent instanceof HtmlHtml)) {
      parent = parent.getParentNode();
    }

    if (parent == null) {
      throw new StaleElementReferenceException("The element seems to be disconnected from the DOM. "
                                               + " This means that a user cannot interact with it.");
    }
  }
View Full Code Here

        when(driver.findElement(By.className(SearchArrowData.SEARCH_ARROW_CLASS))).thenReturn(searchArrow);
        when(searchArrow.findElement(By.className(SearchArrowData.REQUEST_INPUT_CLASS))).thenReturn(searchInput);
        when(searchArrow.findElement(By.className(SearchArrowData.SEARCH_BUTTON_CLASS))).thenReturn(searchButton);

        // cached element lost on refresh
        when(driver.findElement(By.className(SearchArrowData.SEARCH_ARROW_CLASS))).thenThrow(new StaleElementReferenceException(""));

        return driver;
    }
View Full Code Here

    public void staleElementException_should_be_wrapped_in_context_exception() {

        try {
            fc.executeAndWrapReThrowIfNeeded(new Execution() {
                public Void execute() {
                    throw new StaleElementReferenceException("Oops");
                }
            }, null, Context.singular(null, "dummy"), true);
            fail("should have barfed");
        } catch (FluentExecutionStopped.BecauseOfStaleElement e) {
            assertThat(e.getMessage(), equalTo("StaleElementReferenceException during invocation of: ?.dummy()"));
View Full Code Here

                }

                public String getAttribute(String name) {
                    if (countOfGetAttribute[0] == 0) {
                        countOfGetAttribute[0]++;
                        throw new StaleElementReferenceException("boop");
                    }
                    countOfGetAttribute[0]++;
                    return we.getAttribute(name);
                }
View Full Code Here

TOP

Related Classes of org.openqa.selenium.StaleElementReferenceException

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.