[updates below]
i'm trying to click a result from this list: http://www.imdb.com/find?ref_=nv_sr_fn&q=walking+dead&s=all
there are parameters i'm trying to match before selecting, so i find elements first, then try to click the child element of the one that matches. in this case, it would be the first link, for the 2010 series
right now i have this, which does not result in an error, but the link is not actually getting clicked. can someone please help me figure this out?
i get a list of the result elements
element = browser.find_elements_by_xpath('//td[contains(@class, "result_text")]')
after filtering, the first result is what i want. element[0] is 'The Walking Dead (2010) (TV Series)'. the link part of that is found by searching for href
element = element[0].find_element_by_xpath('//a[contains(@href, "title")]')
actions = ActionChains(browser)
actions.click(element).perform()
update1: element.click() does not work
Traceback (most recent call last):
File "U:\backup\references\python practice\episodes.py", line 41, in <module>
element.click()
File "C:\Python27\lib\site-packages\selenium-3.0.1-py2.7.egg\selenium\webdriver\remote\webelement.py", line 77, in click
self._execute(Command.CLICK_ELEMENT)
File "C:\Python27\lib\site-packages\selenium-3.0.1-py2.7.egg\selenium\webdriver\remote\webelement.py", line 494, in _execute
return self._parent.execute(command, params)
File "C:\Python27\lib\site-packages\selenium-3.0.1-py2.7.egg\selenium\webdriver\remote\webdriver.py", line 236, in execute
self.error_handler.check_response(response)
File "C:\Python27\lib\site-packages\selenium-3.0.1-py2.7.egg\selenium\webdriver\remote\errorhandler.py", line 192, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.ElementNotVisibleException: Message: element not visible
(Session info: chrome=54.0.2840.99)
(Driver info: chromedriver=2.25.426923 (0390b88869384d6eb0d5d09729679f934aab9eed),platform=Windows NT 6.1.7601 SP1 x86_64)
update2: tried to wait for visibility of element
element = browser.find_elements_by_xpath('//td[contains(@class, "result_text")]')
elementchild = element[x].find_element_by_xpath('//a[contains(@href, "title")]')
elementvisibility = WebDriverWait(browser, 60).until(
EC.visibility_of_element_located((By.XPATH, '//a[contains(@href, "title")]'))
)
elementchild.click()
but am getting timeout exceptions
Traceback (most recent call last):
File "U:\backup\references\python practice\episodes.py", line 44, in <module>
EC.visibility_of_element_located((By.XPATH, '//a[contains(@href, "title")]'))
File "C:\Python27\lib\site-packages\selenium-3.0.1-py2.7.egg\selenium\webdriver\support\wait.py", line 80, in until
raise TimeoutException(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message:
what's weird is that the element can be found with the 'elementchild...' line, but it isn't visible even with a 60s timer. can javascript load that much slower?