How to get absolute xpath from webElement


#1

i have got the text of web element
and now i need to get current static xpath of this element

WebUI.openBrowser('https://vk.com/club18163886')

TestObject MYob = new TestObject(); 
String xpathname = '//*[contains(text(),"палаточный кемпинг")]'

MYob.addProperty('xpath', ConditionType.EQUALS, xpathname);
def result_text = WebUI.getText(MYob)

#2

I am afraid I don’t understand your question. Which xpath are you looking for?


#3

i need to get this:
//*[@id=“wpt-18163886_611”]/div[1]


#4

Please follow this topic. I have no idea what you try to achieve. Please be more descriptive.


#5

the dinamic xpath of WebElement (it contain my searching text) is:
‘//*[contains(text(),“палаточный кемпинг”)]’

i need to get the static xpath of WebElement(it contain my searching text) using some function/
and end of all i will get this xpath:
//*[@id=“wpt-18163886_611”]/div[1]


#6

Ok I think I know what you mean.

It is quite difficult to build XPath from the WebElement or TestObject. Is static xpath format always the same? I mean, element with id followed by first div element.


#7

maybe YES

I mean, element with id followed by first div element.

I need to get xpath from element which contain searching text
it can be withaut using:'//*[contains(text(),"палаточный кемпинг")]


#8

Show me please the part of HTML code for the element you want to locate. Because you may be able to get absolute XPath of the WebElement, but it is quite dirty solution.


#9


#10

what is better than this?


#11

i need to get absolute xpath


#12

What we can do?


#13

This is the way how to retrieve XPath form WebElement, but I haven’t tried it.


#14

It’s not working


#15

What we can do?