I would really appreciate if someone could help figure out what the hell is going on with one of my tests.
I'm getting Stale element reference: element is not attached to the page of the document
error. I'd really like to crack this one since there are a only a few simple steps in the test.
startingNo = Driver.driver.findElement(By.xpath("//*[@id=\"centralForm:startSerialNumber_input\"]"));
System.out.println("Trying to .sendkeys");
startingNo.sendKeys(Integer.toString(i));
System.out.println("Keys sent");
It seems that Selenium has found my element, but it doesn't get to write anything to that input field. This the HTML
of that section:
<div class="ui-g-12 ui-md-6 ui-lg-3">
<span id="centralForm:startSerialNumber" class="ui-inputnumber ui-widget wh-full-width-container">
<input id="centralForm:startSerialNumber_input" name="centralForm:startSerialNumber_input" type="text" value="0" class="ui-inputfield ui-inputtext ui-widget ui-state-default ui-corner-all" aria-required="true" aria-labelledby="centralForm:startSerialNumberLabel" data-p-label="First serial number" data-p-rmsg="input is required" data-p-con="javax.faces.Long" data-p-required="true" data-p-hl="inputnumber" role="textbox" aria-disabled="false" aria-readonly="false">
<input id="centralForm:startSerialNumber_hinput" name="centralForm:startSerialNumber_hinput" type="hidden" autocomplete="off" data-p-label="First serial number" data-p-rmsg="input is required" data-p-con="javax.faces.Long" data-p-required="true" data-p-hl="inputnumber" value="0"></span>
<div id="centralForm:j_idt94" aria-live="polite" data-display="both" data-target="centralForm:startSerialNumber" data-redisplay="true" class="ui-message"></div>
</div>
I never made it to "Keys sent" System.out.println
. The element is visible to the naked eye at all times, and I can locate it using its xpath
in the Inspector at all times.
Error I get is
FAILED: ImportBlankPassportsToProduction
org.openqa.selenium.StaleElementReferenceException: stale element reference: element is not attached to the page document
(Session info: chrome=76.0.3809.132)
I've tried implementing WebDriverWait
for element to be clickable, and I've tried visible as well. But no luck. I'm kinda stuck :/
I'd be willing to try it all over again with tips from you.