I'm trying to click on the first link in the results page of an opensecrets.org query. I've searched "chase" using selenium, and I now want to go to the page of the first link available. Eventually I want to loop through a whole list of searches and click on the first link, but now I can't even get my code to run with this one element's specific xpath. When I run this code:
result = driver.find_elements_by_xpath(
'//*[@id="___gcse_0"]/div/div/div/div[5]/div[2]/div/div/div[1]/div[1]/div[1]/div[1]/div/a')[0]
result.click()
I get an error: IndexError: list index out of range. Does anyone know why I'm getting this error or is there a more general way to do this, so that I could do it with any search? I keep seeing answers to click on the first link of a google search, but they all use the tag_name "cite" so I'm unsure of how to apply this to an opensecrets search