GXtest UI Commands - Get Text

Official Content

Getting visible text from HTML controls is very useful for several purposes.

Typically is used combined with assertions to let GXtest check for expected conditions. Another common usage is to retrieve web panel data that needs to be used in other test case steps.

GetTextByID

Goal: To get the text from an HTML element using its ID.

Returns: The text of the selected element.

Parameters:

  • ID: the HTML element ID to retrieve the text. 

Example of use: 

&txt1 = &driver.GetTextById("CountryName")

GetTextByName

Goal: To get the text from an HTML element using its  'name' attribute.

Returns: The text of the selected element.

Parameters:

  • Name: the value of the NAME attribute of the element. 

Example of use: 

&txt1 = &driver.GetTextByName("CustomerName")

GetTextByCSS

Goal: To get the text from an HTML element using a CSS selector.

Returns: The text of the selected element.

Parameters:

  • CSS: the CSS selector to the element. 

Example of use: 

&txt1 = &driver.GetTextByCSS("label.gx-label.col-sm-3.AttributeLabel.control-label")

GetTextByXPath

Goal: To get the text from an HTML element using an XPath selector.

Returns: The text of the selected element.

Parameters:

  • XPath: the XPath selector to the element. 

Example of use: 

&txt1 = &driver.GetTextByXPath("//label")

Was this page helpful?
What Is This?
Your feedback about this content is important. Let us know what you think.