2
"get"関数の呼び出し中にセレンのfirefox webdriverがクラッシュしています。このエラーは、firefox_profileを使用しているときにのみ発生し、firefox_profile = Noneの場合はすべて正常に動作します。私は私は私のコードの下Selenium Firefox WebdriverがFirefoxProfileを使用しているときにGetを呼び出すと失敗する
from selenium import webdriver
import os
downloadsDir = os.path.join(os.getenv('HOMEPATH'),"Downloads")
geckoDriverPath = ""
for file in os.listdir(downloadsDir):
if file.startswith("geckodriver") and not file.endswith(".log"):
geckoDriverPath = os.path.join(downloadsDir, file)
break
profilesDir = os.path.join(os.getenv('APPDATA') , "Mozilla", "Firefox", "Profiles")
ffProfileDir = ""
for profile in os.listdir(profilesDir):
if profile.endswith(".default"):
ffProfileDir = os.path.join(profilesDir, profile)
break
firefoxDeskopProfile = webdriver.FirefoxProfile(profile_directory=ffProfileDir)
#If I change the line below to "firefoxDesktopDriver = webdriver.Firefox(executable_path=geckoDriverPath)" then the code succeeds
firefoxDesktopDriver = webdriver.Firefox(firefox_profile=firefoxDeskopProfile, executable_path=geckoDriverPath)
firefoxDesktopDriver.get("https://www.google.com")
がエラーです以下のWindows 10は、Firefox 53.0.2 64ビット、Geckoのドライバv0.16.1のwin64の、セレン3.4.1とPython 3.5.1
を使用しています
C:\Users\username\Downloads>python test.py
Traceback (most recent call last):
File "test.py", line 20, in <module>
firefoxDesktopDriver.get("https://www.google.com")
File "C:\Program Files (x86)\Python35-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 264, in get
self.execute(Command.GET, {'url': url})
File "C:\Program Files (x86)\Python35-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 252, in execute
self.error_handler.check_response(response)
File "C:\Program Files (x86)\Python35-32\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 194, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchWindowException: Message: No such content frame; perhaps the listener was not registered?