私は文字列を検索するスクリプトを作成しますが、エラーがあります。 私は、問題の下に解決するにはどうすればよい:Selenium webdriver Python
links = driver.find_elements_by_xpath("xpath")
for x in range(0, len(links)):
driver.implicitly_wait(2)
links[x].click()
try:
driver.implicitly_wait(3)
DO something
driver.back()
print("Mission completed!!")
except (ElementNotVisibleException, NoSuchElementException):
driver.back()
print("No action")
Error:
selenium.common.exceptions.StaleElementReferenceException: Message: The element reference is stale. Either the element is no longer attached to the DOM or the page has been refreshed.
in line: links[x].click()
THX男に各ページを取得できるようにする必要があり
!あなたは私に多くの良いコードを教えています:)これはこれを行うには最高のワットですか?私のウェブサイトは、20のリンクで検索した後、Googleのように見えます。 – PythonLearn
リンクが20個あるページが1つしかない場合はそのまま使用できますが、ページ番号が付いている場合(それぞれ20個のリンクがある複数のページ)、[次へ]ボタンをクリックして各ページのリンクを追加することができます提供されたループを通過します。 1つのループ - リンクを集める、1つは参照リストからのリンクをたどる – Andersson