I’m a new user and I’m experiencing an issue with a Selenium error: **selenium.StaleElementReferenceException: stale element reference: stale element not found**. Unfortunately, I can’t share the HTML code or any related content due to confidentiality, but I’ll provide as many details as possible. I’m performing web application testing on a login page, and the problem occurs when trying to input the encrypted text into the password field.
This attachment is the example of the login page look like
I've tried several solutions, including:
Adding WebUI.delay()
Using Smart Wait
Manually setting up the TestObject
Implementing try and catch blocks
I’ve used WebUI.waitForElementVisible and WebUI.waitForElementClickable. These steps were successful, but when the test attempts to input the encrypted text, it fails and produces the following error.
I would appreciate your expertise to guide me in resolving this issue. Thank you!
Without the HTML, we are going to be handicapped assisting you. However, perhaps you can spend time on the “Username” textbox, and once you have a stable page, then just verify the “Password” textbox is visible and then set your text. The biggie is if you have a solid pathway to your textboxes. Again, without HTML, we can’t help you there either.
Edit: Use the “Find” textbox of your HTML to ensure your pathway is unique for each of your textboxes. If your pathway is not unique (i.e. you don’t see 1 of 1 on the right-hand side of the “Find” textbox), you need to fix it.
The script above tests the username_field, while the section highlighted in red below is for the password_field. The script fails at the line indicated by the red arrow. I’ve tried replacing setEncryptedText with setText and using the spy web tool to recapture the object for input, but it still doesn’t work. The code is written in an ASPX page, so I’m not sure if it is the same as a normal HTML website, although I can see the HTML code from the developer tools in the browser.
Not sure myself, however, I want to check if you have taken your password and used the encryption menu of Katalon Studio on your password, main menu Help > Encrypt Text? Then you copy and paste the encrypted password into your “setEncryptedText”. (Note: I read my encrypted password in from an external source, so I don’t verify it a second time.)
WebUI.setText(findTestObject('...'), 'myPassword')
or
WebUI.setEncryptedText(findTestObject('...'), '#@09@##!!')
It also wouldn’t hurt to add another wait before your login page, like:
If you’re not able to use SetText, it sounds like the path to the object isn’t unique or it’s not on the screen. You may need to try a different locator. Additionally, what does the Console log show when trying to interact with the object and set the text?