RE: Stale element issue

Answered

Hi,

I am trying to click on add to cart from different pages. this works 1 in 5 times. rest of the times, i get stale element error.

Exception in thread “main” org.openqa.selenium.StaleElementReferenceException: stale element reference: element is not attached to the page document

Below is the click code i am trying to execute.

i have tried page refresh / maximize / full screen option before this code.

       WebElement ckAddTo1;

        WebDriverWait waitAdd = new WebDriverWait(driver, 10);

        ckAddTo1 = waitAdd.until(ExpectedConditions.elementToBeClickable(By.xpath(“//button[@class=’button button–green’ and @data-product-id =’221894′]”)));

        ckAddTo1.click();

 

Thanks,

Mithun

Add Comment
1 Answers
Best answer

i got this working by using try catch with multiple attempt.

Default Answered on March 19, 2018.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.