How to validate a html element

I am trying to validate the text next to Collection Method as highlighted on the attachment but instead I get the text that’s circled in red. The containers have the same xpath. How can I go about validating this I have tried SOAP requests & using the containstring() but no luck

Katalon.JPG

Xpath can use different paths to reach a certain element. Have you tried using something like

//span[text()='Stop Order']

or

//span[contains(text(), 'Stop Order')]

?

Mate Mrse said:

Xpath can use different paths to reach a certain element. Have you tried using something like

//span[text()='Stop Order']

or

//span[contains(text(), 'Stop Order')]

?

Would I then use this as a property of the Xpath or? I am not sure how I would apply this to my script

You could target element with xpath that goes something like:

//span[text()='Collection Method'] 

(I would need to see the HTML to know exactly), and then use the following:

WebUI.verifyElementText(findTestObject('Your Object'), 'Stop Order')

Sello Matloha said:

Mate Mrse said:

Xpath can use different paths to reach a certain element. Have you tried using something like

//span[text()='Stop Order']

or

//span[contains(text(), 'Stop Order')]

?

Would I then use this as a property of the Xpath or? I am not sure how I would apply this to my script

1. first of all, try to define element “Stop Order” by “Record Web” tool (for example click on the label “Stop Order”)
2. then in Object Repository you will see page object of your element
3. Now you can use your element as Object and text “Stop Order” as “Input” for “verifyElementText”
the code in script mode
WebUI.verifyElementText(findTestObject(‘Page_<your_page>/’), ‘Stop Order’)

Thank you