Unable to get text from TextBox

On the project I’m currently working on, I need to save the value of a TextBox in a variable. However, maybe due to the fact it’s disabled, it’s harder than expected.

Here’s the TextBox in question:

I’ve tried:
- String NoDS = WebUI.getText(findTestObject([path to object])): gives me a null value
- String NoDS = WebUI.getAttribute(findTestObject([path to object]), ‘value’): fails with a StaleElementException saying “element is not attached to the page document”.
- String NoDS = WebUI.getAttribute(findTestObject([path to object]), ‘title’): fails with a StaleElementException giving the same message as above.

Of course, all of these have been tested in Chrome, Firefox and IE. No difference in behavior.

The page is dynamically created with Spring. So maybe that’s why the TextBox is giving me issues. But I’m able to get the value of other TextBoxes just not that one. Am I doing something wrong?

Make sure your element is loaded properly before you try to get the text. Try adding explicit wait and check.

First, don’t use explicit waits if you can avoid it.

Second, paste the HTML of the element that you’re having trouble with – is it an input element with type=“text”?

1 Like

Russ Thomas said:

First, don’t use explicit waits if you can avoid it.

Second, paste the HTML of the element that you’re having trouble with – is it an input element with type=“text”?

Right, don’t use explicit wait, but just for debugging purpose you can check if your issue is really related to wait issues.