I am automating my current project. In that am trying to click on the main menu.

For that below is my code

WebElement ul = driver.findElementByXPath(prop.getProperty("category"));
    List<WebElement> options = ul.findElements(By.tagName("li"));
    for(WebElement sample: options)
    {
        if(sample.getText().equals(data)){
            sample.click();
        }
    }

When I run this code the main menu is getting clicked and it gets loaded but still am getting exception. Help me to this.

Error:

Exception in thread "main" 
org.openqa..StaleElementReferenceException: stale element 
reference: element is not attached to the  

HTML code:

enter image description here



Source link https://sqa.stackexchange.com/questions/34318/how-to-resolve-stale-element-reference-error-element-is-not--in-page-do

LEAVE A REPLY

Please enter your comment!
Please enter your name here