def parse_match(driver, url):
wait = WebDriverWait(driver, 2)
driver.get(url)
hiddens_list = []
more = wait.until(EC.visibility_of_element_located((By.CLASS_NAME, "more")))
ActionChains(driver).move_to_element(more).perform()
hiddens = driver.find_elements_by_xpath('//div[contains(@class, "othersList")]')[1].find_elements_by_tag_name('a')
for hidden in hiddens:
hiddens_list.append(hidden.text)
more = wait.until(EC.visibility_of_element_located((By.CLASS_NAME, "more")))
for link in hiddens:
for name in hiddens_list:
print(link.text)
if link.text == name:
link.click()
more = wait.until(EC.visibility_of_element_located((By.CLASS_NAME, "more")))
ActionChains(driver).move_to_element(more).perform()
continue
url = 'https://www.oddsportal.com/soccer/england/premier-league/norwich-watford-2ozLgUyq/'
Как я могу щелкнуть по каждому элементу в скрытом списке (<li class="r more">
).
Я могу нажать только по первой ссылке. Тогда я получаю ошибку selenium.common.exceptions.StaleElementReferenceException: Message: stale element reference: element is not attached to the page document
на второй итерации в строке if link.text == name: