Using to locate an element works regardless of the parents of the element. It doesn’t matter if the parent is an li or a span, as long as your identifier is unique. So if you are using a CSS ID it will work.
Now that CSS ID needs to be unique or if you are using and classes, their combined selection needs to be unique. This can be a challenge if multiple similar exist and/or similar exist at other within the DOM for the parent element. The answer is to learn how to identify for automation and to do that I recommend you read up a couple of books and blogs. is a great reference that is not only good for pythonists may also help has some great examples

Two examples that may help:


Selecting elements


This would all child-element nodes named input which @type-attribute-values are equal to ‘password’. The child:: axis prefix may be omitted, because it is the default behaviour, so this becomes



Selecting an immediate child vs any child under that element:

Immediate child (‘/‘): span/form

Any level deep child (‘//‘) span//form

Many elements would work for both approaches. The // approach allows for the page to be rearranged and thus may be more flexible. The / approach may be helpful to more specificially identify an element when more than 1 exist in the tree below the parent element

Source link


Please enter your comment!
Please enter your name here