Reputation: 9392
I am working with selenium python and lettuce to test django application.
There are many elements having xpath in the following pattern and i don't know how many of these elements exists in the document.
.//*[@id='accordion-note-1']
.//*[@id='accordion-note-2']
.//*[@id='accordion-note-3']
.//*[@id='accordion-note-4']
Is there any way to use pattern in driver.find_elements_by_xpath ?
Basically my purpose is to get all items having this pattern of xpath.
Upvotes: 3
Views: 2986
Reputation: 3004
Not sure this will work, but you can try by using the below xpath:
.//*[starts-with(@id, 'accordion-note')]
here is the link http://www.zvon.org/xxl/XSLTreference/Output/function_starts-with.html
u can also use contain here like
.//*[contains(@id, 'accordion-note')]
Upvotes: 7