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: