Reading Text from a Disabled Input Field in Katalon Studio

Reading text from a disabled input field is a very specific example, but it took a lot of searching to get the right command. I figured it could be a time saver if I put up a working example.
The table I’m working with looks like this:

As noted, I want to read the Plan value, but it’s disabled at the moment so a standard GetText doesn’t read the value. This is a dynamic table, so I’m using the WebDriver to manipulate it.
Once the import commands are in place, I can use the “getAttribute(“value”) to read the text from this input field.

//Read text from an input field where the text is disabled
plan = driver.findElement(By.xpath('//*[@id=\'customersTable\']/tbody/tr[1]/td[7]/input')).getAttribute("value")

Again, I’m using the wildcard //* to find my customersTable. I then reference the “input” field and use the getAttribute.
From there, I’m able to read $159,112 from the field. After that, it’s the standard commands to replace the $ and write it out to the log file.
This turned out to be a simple solution, but again, it took a lot longer to find and put the answer together than I would have expected. Hopefully, this saves time for someone else.

Then again, I could be wrong.

Author Signature for Posts

0