に添付されていません。それは問題なく動作しましたが、ウェブサイトは何か変わってしまいました。今は、可能な解決策の前に、新しい方法で2通りのエラーに遭遇しています。selenium.common.exceptions.StaleElementReferenceException:メッセージ:古い要素参照:要素は、私がページにスクロールするクロムとActionChainsでページを開くには、DOM要素とSeleniumを移動するにはPythonの美しいスープを使用するページの文書
旧ソリューション:
submit_button = driver.find_element_by_name('quantity')
elementList = submit_button.find_elements_by_tag_name("option")
elementList[int(column)-1].click()
旧エラー:
Traceback (most recent call last):
File "C:/Users/Felix_P/PycharmProjects/Price_Tool/Combination_14_6_2016.py", line 205, in <module>
elementList[int(column)-1].click()
File "C:\Python35-32\lib\site-packages\selenium\webdriver\remote\webelement.py", line 75, in click
self._execute(Command.CLICK_ELEMENT)
File "C:\Python35-32\lib\site-packages\selenium\webdriver\remote\webelement.py", line 469, in _execute
return self._parent.execute(command, params)
File "C:\Python35-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 201, in execute
self.error_handler.check_response(response)
File "C:\Python35-32\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 193, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.ElementNotVisibleException: Message: element not visible: Element is not currently visible and may not be manipulated
(Session info: chrome=51.0.2704.103)
(Driver info: chromedriver=2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4),platform=Windows NT 6.1 SP1 x86_64)
新しいソリューション:
submit_button = driver.find_element_by_name('quantity')
elementList = submit_button.find_elements_by_tag_name("option")
actions.move_to_element(elementList[int(column)-1]).click().perform()
新しいエラー:
Traceback (most recent call last):
File "C:/Users/Felix_P/PycharmProjects/Price_Tool/Combination_14_6_2016.py", line 201, in <module>
actions.move_to_element(elementList[int(column)-1]).click().perform()
File "C:\Python35-32\lib\site-packages\selenium\webdriver\common\action_chains.py", line 72, in perform
action()
File "C:\Python35-32\lib\site-packages\selenium\webdriver\common\action_chains.py", line 217, in <lambda>
self._driver.execute(Command.MOVE_TO, {'element': to_element.id}))
File "C:\Python35-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 201, in execute
self.error_handler.check_response(response)
File "C:\Python35-32\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 193, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.StaleElementReferenceException: Message: stale element reference: element is not attached to the page document
(Session info: chrome=51.0.2704.103)
(Driver info: chromedriver=2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4),platform=Windows NT 6.1 SP1 x86_64)
私の推測では、タイミングの問題があるということです。これらの行の前に何らかのアクションをとったスクリプトがあると、
同じ種類の2つの製品ページバージョンでスクリプトを実行する場合。 「類似した」ウェブサイト作品での最初の試み。 2回目の試行は機能しません。それはより明確な問題の理解につながるでしょうか? –