Unable to verify text on page using WebUI.verifyTextPresent

Hi Folks, I am trying to validate text on a page where the element does not have a ‘value=xxx’ attribute. The text ‘FundName001’ and ‘FundName002’ as well as other entered data values display on the page but the following is not finding the text. I have tried several things to assert/validate the text but no luck so far… Has anyone dealt with this type of issue? Note: There are no iframes on this page.

HTML Element value:

<input id="fundName0" name="activePacFundEntities[0].fundName" placeholder="Fund name" required="" type="text" maxlength="40">

Test case:

//Test steps that create the data for the page... 
WebUI.delay(2)
WebUI.verifyTextPresent('FundName001', false)
WebUI.verifyTextPresent('FundName002', false)

Possibly the text “FundName001” is not visible as a part of DOM. Therefore WebUI.verifyTextPresent does not help.

Possibly you need to write JavaScript to get access to the text “FundName001” out of the <input> elements.

Which, if you weren’t aware, is the value sent to the page from the server. The value that is sent back to the server, comes from the element.value property. In other words, you don’t want the attribute, you want the property. Testing docs tend to fuzzy up the distinction between the two, but for you, just do what Kaz hinted at:

String js = "return document.querySelector('#fundName0').value;"
String value = WebUI.executeJavaScript(js, null)
1 Like

Or perhaps because the element is an input tag you can see if the below works:

item = com.Tools.createTestObject('id("fundName0")')
WebUI.verifyElementAttributeValue(item, "value", "FundName001", 10)
2 Likes