using for each i did not get StaleElementReferenceException. But using for loop i am not able to do the operation , only one link got clicked and got NoSuchElementException
@sigmasingh8492 жыл бұрын
I did not get Stale Element Reference Exception in the first method, it worked for me with the first way you explained! ..Why did it happen?
@QAFox2 жыл бұрын
Can you share your code here?
@sigmasingh8492 жыл бұрын
@@QAFox public class StaleElementReferenceExep { public static void main(String[] args) throws InterruptedException { WebDriverManager.chromedriver().setup(); WebDriver driver = new ChromeDriver(); driver.manage().window().maximize(); driver.get("omayo.blogspot.com/"); driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(10)); List links = driver.findElements(By.xpath("//div[@id='LinkList1']//a")); for(WebElement e:links) { e.click(); Thread.sleep(5000); driver.navigate().back(); } driver.close(); } This code worked for me but for you it gave an Stale Element Reference Exception