how to write relative xpath for windows application in katalon studio.Except absolute path any locators are not available.
how to write relative xpath for windows application in katalon studio.Except absolute path any locators are not available.
What do you mean by saying absolute XPath and relative XPath?
Please tell us your definition of “relative xpath”.
For example, How to use XPath in Selenium? Tutorial writes that the following XPath is a Relative XPath:
//div[@class='featured-box cloumnsize1']//h4[1]//b[1]
I would not agree with categorizing this XPath expression being relative. I think it is a bad wording.
As far as I am aware, Katalon Studio always interpret any XPath expression being relative to the HTML document root. People may say “it is an absolute xpath”.
On the other hand, using the Selenium WebDriver API, you can write a test code that interpretes a XPath being relative to an instance of WebElement, like this:
WebElement baseDiv = driver.findElement(By.xpath("//div[@class='featured-box cloumnsize1']"))
WebElement b = baseDiv.findElement(By.xpath("//h4[1]//b[1]"))
In this case, the XPath expression //h4[1]//b[1] is interpreted as relative to the baseDiv node, not to the HTML document root node.
I mean, any XPath expression will be interpreted as relative to a base node. Which base node? — the application code chooses. The way of interpretation depends on how an application applies the XPath expression; relative to the document root or to some HTML node in the document. XPath has no syntactical component that distinguishes “a relative xpath” and “an absolute xpath”.
Hi @kazurayam,
Thanks for your feedback. I have reopened the topic. My intention is to bring the topic to the attention of our APM and sharing with other AKA participants, I hope the topic can benefit more people. The content belongs to you and the community. Sorry for the inconvenience this may cause.
Best,
Vu Tran