这是我的全部脚本
from selenium import webdriver
driver = webdriver.Firefox()
driver.get("http://www.python.org")
运行时产生:
Traceback (most recent call last):
File "wat.py", line 4, in <module>
driver.get("http://www.python.org")
File "/home/brevzin/.local/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 333, in get
self.execute(Command.GET, {'url': url})
File "/home/brevzin/.local/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "/home/brevzin/.local/lib/python3.6/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchWindowException: Message: Browsing context has been discarded
我刚刚更新了所有内容:
我已经搜索了几个关于同一错误的问题,但仍然完全不知道这里的问题是什么。我什至几乎什么都不做。这是Selenium Python的开篇,或者至少是开篇的开篇。
答案 0 :(得分:0)
我最终通过把所有东西都烧毁来解决这个问题,并在我的主机上完全重新安装了所有东西:我将 Ubuntu 从 18.04 更新到 20.04,然后删除了 Python 和所有库,然后重新安装了所有库。< /p>
我不知道实际问题是什么,但现在至少我的琐碎示例按预期工作。我仍然不知道问题是什么/曾经是什么,但也许这种描述会在某个时候对某些人有所帮助。