[WebUI] Get Text


#1

This is a companion discussion topic for the original entry at https://docs.katalon.com/katalon-studio/docs/webui-get-text.html

#3

How to set the innerText of a non-input element?


#4

Can you give an example of what you mean? You could try importing

import org.openqa.selenium.Keys as Keys

and sending the desired text as key actions

WebUI.sendKeys(findTestObject(‘Your_Object_Goes_Here’), Keys.chord(Keys.ARROW_RIGHT))


#5

Hi, can you help me why i can’t get text that input text?



#6

You are not targeting the correct element. I typically bring up Object spy and capture as much of an element as possible. Notice that when you hover over elements, sometimes the red border shifts on just the text, the entire field, etc. Figure out how you need to target it then go from there. Technically, the element you targeted is there, its just empty.


#7

I’ve come across an issue where WebUI.getText is not able to trim the trailing space in actual text.

The actual text rendered in webpage HTML has &nbsp at the end. This is causing the trailing space. I thought WebUI.getText will take care of it but it didn’t work.

Example:
Actual Text in webpage HTML: sample text 1&nbsp
Actual Text grabbed by WebUI.getText: sample text 1
Expected Text in Test Case: sample text 1


#8

They said it removes whitespace in which case that’s a bug. Please make out a bug report, mention it should remove all whitespace including HTML entities like     etc.


#9

Done, here’s the link.