私はpage1に行き、次にpage2に向かうための他のボタンをクリックしてからpage2にあるリンクをクリックします。 マイコード:リンクをクリックできません
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
import selenium.webdriver.support.ui as UI
d = webdriver.Firefox()
d.get("https://www.youtube.com/")
d.find_element_by_xpath('//*[@id="appbar-nav"]/ul/li[2]/a/span').click()
wait = UI.WebDriverWait(d, 20)
next_page_link = wait.until(
EC.element_to_be_clickable((By.LINK_TEXT, 'FACTS ABOUT ME')))
next_page_link.click()
私は待機を追加しましたが、それはまだエラーを与える:要素が全くDOMに単純ではありません
raise exception_class(message, screen, stacktrace) selenium.common.exceptions.StaleElementReferenceException: Message: Element is no longer attached to the DOM
リンクテキストに「FACTS ABOUT ME」の要素が見つかりませんでした。 –
私は 'find_element_by_css_selector(" a = title = 'FACTS ABOUT ME'] ') 'を試してみました。 'LINK_TEXT'の代わりに' find_by_css_selector'を使ってみてください。 –