Skip to content

Find Element WITHIN Element doesn't work #342

Closed Answered by Vhyseris
Vhyseris asked this question in Q&A
Discussion options

You must be logged in to vote

Okayyy, thanks to ChatGPT and the right question I found out what the problem was.

Its not a problem with the pylenium code, but you need to know if your searching within an element over XPath, you need to add a dot at the beginning! Here, the dot (.) ensures the XPath starts from the parent element instead of the root of the DOM. This approach ensures scoped searches, avoiding performance hits and ensuring the intended element is found more accurately.

Corrected code

row = py.getx("//div//table//tr")
# Wrong way
# cbbyrow = row.getx("//input")

# Correct way
cbbyrow = row.getx(".//input")

May I suggest to add this info to this section of the documentation:
https://docs.pylenium.io/eleme…

Replies: 5 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@Vhyseris
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by Vhyseris
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants