Selenium-Python Webbrowser公开问题

时间:2019-03-15 18:27:42

标签: python selenium selenium-webdriver

浏览器打开后立即关闭,出现以下错误。有人可以帮忙吗。

Traceback (most recent call last):
  File "C:/Program Files/Python36/Sri_test/browser.py", line 5, in <module>
    driver = webdriver.Firefox()
  File "C:\Program Files\Python36\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 174, in __init__
    keep_alive=True)
  File "C:\Program Files\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 157, in __init__
    self.start_session(capabilities, browser_profile)
  File "C:\Program Files\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 252, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "C:\Program Files\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "C:\Program Files\Python36\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: newSession

使用以下代码使用硒打开浏览器

  from selenium import webdriver

  driver = webdriver.Firefox()
  driver.get("http://www.python.org")

0 个答案:

没有答案