“代码是无法到达的”但是代码仍然可以到达(Visual Studio代码)
我有以下代码访问网站并停止浏览器通知:
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.chrome.options import Options
option = webdriver.ChromeOptions()
***option.add_experimental_option("excludeSwitches", ["enable-automation"])
option.add_experimental_option('useAutomationExtension', False)
option.add_argument("--disable-infobars")
option.add_argument("start-maximized")
option.add_argument("--disable-extensions")
option.add_experimental_option("detach", True)
option.add_experimental_option("prefs", {
"profile.default_content_setting_values.notifications": 2
})
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()),options=option)
driver.get("https://www.reddit.com/r/AskReddit/")
该代码运行,但是我的IDE(Visual Studio Code)表示,从***开始,“代码是无法实现的塔属于”。有人知道我如何解决这个问题吗?这很烦人,因为它在***线之后弄清楚了所有内容。谢谢。
我所看到的视觉表示:
带警告:
I have the following code that accesses a website and stops browser notifications:
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.chrome.options import Options
option = webdriver.ChromeOptions()
***option.add_experimental_option("excludeSwitches", ["enable-automation"])
option.add_experimental_option('useAutomationExtension', False)
option.add_argument("--disable-infobars")
option.add_argument("start-maximized")
option.add_argument("--disable-extensions")
option.add_experimental_option("detach", True)
option.add_experimental_option("prefs", {
"profile.default_content_setting_values.notifications": 2
})
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()),options=option)
driver.get("https://www.reddit.com/r/AskReddit/")
The code runs, but my IDE (Visual Studio Code) says that from *** onwards the "Code is unreachable Pylance". Does anyone know how I could fix this? It's annoying since it grays out everything after the *** line. Thank you.
Visual representation of what I'm seeing:
With warning:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
更多
发布评论
评论(1)
解决方案:
这是一个错误。更新到最新版本的硒,以解决该问题。
我通过在此处讨论相同的问题来发现这一点: https:// github。 com/microsoft/pylance-release/essume/2807
Solution:
It's a bug. Update to the most recent version of selenium to fix the issue.
I found this out by finding the same issue also being discussed here: https://github.com/microsoft/pylance-release/issues/2807