how to get the ID of the element that contains our search text?

The web element contains our search text.

I need to determine the ID / XPATH of this element.

please post at least HTML with element in question

1.jpg

our text = “У всех есть

the ID that i need to get will be as “wpt-126142305_237

i assume that text is in div with class wall_post_text so i’ll define test object with xpath like:

(//div[contains(@class,'wall_post_text') and contains(text(),'У всех есть')])/../div[contains(@id,'wpt')]

and to get id use function

getElementAttribute(testObject, 'id')

i’m writing this from head, to maybe some mistake in xpath can be found

can we put our text instead of testObject? and How it looks?

yes you can parametrize testObject

(//div[contains(@class,'wall_post_text') and contains(text(),'${SEARCH_TEXT}')])/../div[contains(@id,'wpt')]

and then you just call

WebUI.getAttribute(findTestObject('Object Repository/testObject',[('SEARCH_TEXT'):'У всех есть']), 'id')

image.png

1 Like

thx!!))
i wil try it soon