How to resolve, Stale element exception? if element is no longer attached to the DOM?

后端 未结 7 1104
盖世英雄少女心
盖世英雄少女心 2020-11-30 23:01

I have a question regarding \"Element is no longer attached to the DOM\".

I tried different solutions but they are working intermittent. Please suggest a solution th

相关标签:
7条回答
  • 2020-11-30 23:29

    When a Stale Element Exception occurs!!

    Stale element exception can happen when the libraries supporting those textboxes/ buttons/ links has changed which means the elements are same but the reference has now changed in the website without affecting the locators. Thus the reference which we stored in our cache including the library reference has now become old or stale because the page has been refreshed with updated libraries.

    for(int j=0; j<5;j++)
    try {
        WebElement elementName=driver.findElement(By.xpath(“somexpath”));
        break;
    } catch(StaleElementReferenceException e){
    e.toString();
    System.out.println(“Stale element error, trying ::  ” + e.getMessage());
    }
    elementName.sendKeys(“xyz”);
    
    0 讨论(0)
提交回复
热议问题