I'm experiencing a StaleElementReferenceExpection that seems beyond all reason in an application. It involves absolutely no refreshing or reloading of the page, but just two consecutive actions of accessing the element - one click and one assertion that the element is not selected.
Java/Selenium code:
this.element.findElement(By.cssSelector("input[type='checkbox']")).sendKeys(Keys.SPACE);
(SPACE is used because when usng click, Selenium claims "ElementClickInterceptedExcpetion - other element would receive the click")
assertThat(this.element.findElement(By.cssSelector("input[type='checkbox']")).isSelected()).isFalse();
This results in:
org.openqa.selenium.StaleElementReferenceException: stale element reference: element is not attached to the page document
even when I use brake points int the code, and skip slowly through each step.
Markup:
<div class="hb-cell hb-cell--autoWidth">
<input tusenskilletegn="" id="utgift-2-belop">
<input type="checkbox" id="utgift-2-inkludert">
<div class="hb-label>
<label class="hb-label-tekst" for="utgift-2-inkludert"></label>
</div>
</div>
Also tried accessing the for" in the label, with no luck: (using partial match, in this example)
this.element.findElement(By.cssSelector("label[for$=-inkludert]")).click();
It results in
org.openqa.selenium.ElementNotInteractableException: element not interactable
Any ideas? Selenium seems to have become impossible for me to use lately, with this type of error occuring all "over the place".