I was asked this question.
What are the types of XPath in Selenium?
I'm sure most would not be shocked by this question Instead, take it as the right question from an interviewer.
As I heard this question, I asked myself.,
What are the types of XPath in Playwright?
Isn't that fair to ask so?
In simple, the Selenium and Playwright do not have their types of XPath. In fact, the XPath has nothing to do with Selenium and Playwright.
The XPath was created by W3C before the Selenium came to the world.
The XPath is built by W3C and used by the browser to traverse a XML document.
By the way, XPath means XML Path. The XPath is an expression or query to locate the node or element or attribute or what is of interest in the XML document.
The creator of Selenium used the XPath to locate an web element on a web page which is a HTML document -- a XML.
The Playwright also does the same. It uses the XPath to traverse and locate a web element on a web page.
However, XPath has two ways to traverse and locate a node in XML or a web element in HTML page. That is,
- Absolute XPath
- Relative XPath
These are the two types offered by W3C to traverse a XML document using XPath.
LLM and Its Training
The LLMs are trained by the data and information on internet. When the internet is filled with such contents which are incorrect, noise, and misleading, the LLM offers the same.
In my opinion, that question asked about the types of XPath in Selenium and Playwright is technically incorrect. Looks like the question is picked from the web or from a LLM's response.
The LLMs are useful when it is trained on the well reasoned information and data, and when it is questioned in the better ways.
The people are accepting whatever LLMs respond and advocating that is right! Beware!
Let us give the better data to LLMs for its training. This is very much needed to the Software Testing and Test Engineering related training.
Question the LLMs in your prompts and conversation. It can assist better. You should know when to say no for what it is responding. The XPath and its types are independent of any web automation libraries and tools. The web automation libraries and tools make use of the XPath to traverse and locate a web element, a property or a attribute of an element in web page.
The latest XPath version available is 3.1. It is said, the popular browsers which we use supports natively for XPath 1.0 alone. That is, the popular browsers do not natively support the latest version of XPath. The XPath 1.0 became a recommendation in 1999.
References:
ReplyDelete1. https://www.ibm.com/docs/en/i/7.4.0?topic=programming-overview-xpath
2. https://developer.mozilla.org/en-US/docs/Web/XML/XPath
3. https://www.w3.org/TR/xpath20/