Issue
I am trying to find multiple elements by their respective ids The elements are named
dcm-reservation-limit-multiple-input-generic-X
with X being the number of elements, it could be:
dcm-reservation-limit-multiple-input-generic-0
dcm-reservation-limit-multiple-input-generic-1
dcm-reservation-limit-multiple-input-generic-2
...
dcm-reservation-limit-multiple-input-generic-10
and the list goes on. I've tried already this code:
pricesToFind = driver.find_elements_by_xpath(".//*[@id='dcm-reservation-limit-multiple-input-generic-']")
without any success, the results always return NULL even if they really exist
piece of HTML to help:
<input _ngcontent-ihk-c34="" autocomplete="off" class="lib-input" maxlength="11" type="text" id="dcm-reservation-limit-multiple-input-variation-0">
the input name is randomly generated by javascript, so it's useless to scrape it via input name
Solution
Use contains or starts-with?
pricesToFind = driver.find_elements_by_xpath(".//*[contains(@id,'dcm-reservation-limit-multiple-input-generic-')]")
pricesToFind = driver.find_elements_by_xpath(".//*[starts-with(@id,'dcm-reservation-limit-multiple-input-generic-')]")
Answered By - Yevhen B
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.