Website: https://www.annualreports.com/Companies?
I want to identify the links on the website using the linktext, e.g. a companies name and click the respective link:
company = "1-800-FLOWERS"
browser.get(r'https://www.annualreports.com/Companies?')
continue_link = browser.find_elements(By.XPATH,f"//span[@class='companyName'][.//a[contains(.,'{company}')]]")
if len(continue_link) == 0:
print("No Firm Found")
elif len(continue_link) > 1:
print("Multiple Firms Found")
elif len(continue_link) == 1:
print("Firm Found")
continue_link[0].click()
This works just fine in some cases, for example for the company in the above code sample, "1-800-FLOWERS".
For other companies, the button won't be clicked, even though an element is found. Replacing "1-800-FLOWERS" with the company "3D Systems" leads to a case where the link is not clicked. I haven't identified a potential pattern with respect to the companies that might explain this behavior.
I also tried all kinds of possible solutions from this thread without any success.
Any help is much appreciated