I use Selenium to create web paging, and now I want to find all the elements that the user can click on and that contain the word “download” (in any capitalization) in the link text, button text, id element, class or href element. This may include links, buttons, or any other element.
In this answer, I found an xpath for someone looking for an xpath to search for buttons based on specific text (or case insensitive and partial matches):
text = 'download' driver.find_elements_by_xpath("(//*[contains(text(), 'download')]")
but to this page , which does not return any results, even if there is the following link:
<a id="downloadTop" class="navlink" href="javascript:__doPostBack('downloadTop','')">Download</a>
Does anyone know how I can find all elements that somehow contain the word “upload” on a website?
[EDIT] This question has been marked as a duplicate of a question that gets an answer that suggests changing it to "//*[text()[contains(.,'download')]]" . "//*[text()[contains(.,'download')]]" So I tried the following:
>>> from selenium import webdriver >>> d = webdriver.Firefox() >>> link = 'https://www.yourticketprovider.nl/LiveContent/tickets.aspx?x=492449&y=8687&px=92AD8EAA22C9223FBCA3102EE0AE2899510C03E398A8A08A222AFDACEBFF8BA95D656F01FB04A1437669EC46E93AB5776A33951830BBA97DD94DB1729BF42D76&rand=a17cafc7-26fe-42d9-a61a-894b43a28046&utm_source=PurchaseSuccess&utm_medium=Email&utm_campaign=SystemMails' >>> d.get(link) >>> d.find_elements_by_xpath("//*[text()[contains(.,'download')]]") []
Does anyone know how I can get all the elements that the user can click on and that contain the word “load” in the link text, button text, id element, class element or in href ? All tips are welcome!