XPath element which contains an attribute and whose parent's parent contains another attribute -
This is my first post and since I have seen very good answers, I thought I would try it. / P>
I'm trying to use XPath to get the specific element in an HTML document. This is an example based on Google web pages:
& lt; Html & gt; & Lt; Top & gt; & Lt; Title & gt; XPath Test & lt; / Title & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; Name of the form = 'F' & gt; & Lt; Table & gt; & Lt; Tbody & gt; & Lt; TR & gt; & Lt; TD & gt; & Lt; Input name = 'q' type = "text" /> & Lt; / TD & gt; & Lt; / TR & gt; & Lt; / Tbody & gt; & Lt; / Table & gt; & Lt; / Form & gt; & Lt; / Body & gt; & Lt; / Html & gt; Using the above example (which is simplified for the purposes of asking for help), I would like to be able to find the input element whose name is 'q' and its ancestor named 5. Along with who is the parent = 'F' For example, if I had to do this in the syntax of SWAT, which is located on an open source Web Automation Testing Library, the syntax would be as follows:
| AssertElementExists | Expression | Name = q; ParentElement.parentElement.parentElement.parentElement.parentElement.name = f | Input |
I am just starting to learn CPAD and am trying to understand how to get involved with axes. Is it possible to express it with XPath? If this is so, can some knowledgeable help?
You could:
// input [ Name = 'q' and ancestors-or-self: * [[name = 'f']] // - Input element whose name is 'q' and whose name is an ancestor with = 'F'
or
// input [@names = 'q' and ../../../../. ./../*[@name='f ']] // - Input element whose name is in the form of' q 'and 5 parent names, name =' f '
< P> You can use this desktop to test your XPath expressions. a.
Comments
Post a Comment