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/td/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.
Other articles of interest:
- Working with Tables using the Selenium WebDriver and Katalon Studio
- Katalon Studio – Creating Objects
- Entering and reading text GetText, SetText and SendKeys in Katalon Studio
- Katalon Studio – Manual View – The start of a test script
- Using TypeIt4Me with Katalon Studio
- Stripping away characters with ReplaceAll in Katalon Studio
- Securely storing passwords and login details with Set Encrypted Text in Katalon Studio
- Output status messages and test information by writing to the Log File Viewer in Katalon Studio
- Marking tests as Passed, Failed or in Error using MarkFailed, MarkPassed, MarkError in Katalon Studio
- Passing Object Names as String Variables in Katalon Studio