【发布时间】:2021-04-02 21:30:59
【问题描述】:
我想学习使用 Selenium,但我真的不知道我做错了什么。 当我启动我的基本脚本时,Python shell 会立即打开和关闭,而不会出现任何错误消息。
我直接从https://pypi.org/project/selenium/下载了Selenium,解压后点击setup.py。没有错误消息,只是带有“请按任意按钮”的 CMD 窗口。
我下载了网络驱动程序:
-
Chrome - 版本 89。
-
Firefox 版本 78.6.1esr(64 位),刚刚下载了最新版本 0.29.0 - https://github.com/mozilla/geckodriver/releases
我把所有东西都按相同的顺序(驱动程序、Selenium、要执行的代码),看截图: Screenshot
这里是 Firefox 的代码:
from selenium import webdriver
browser = webdriver.Firefox()
browser.get('https://www.google.com')
我也试过直接给出驱动的路径没有成功:
from selenium import webdriver
browser = webdriver.Firefox('C:\Users\Bast01\Desktop\Python\Selenium Test\geckodriver.exe')
browser.get('https://www.google.com')
我什至不知道是否正确安装了 Selenium,例如:
Python 3.9.1 (tags/v3.9.1:1e5d33e, Dec 7 2020, 17:08:21) [MSC v.1927 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> help("selenium")
No Python documentation found for 'selenium'.
Use help() to get the interactive help utility.
Use help(str) for help on the str class.
>>> help("Selenium")
No Python documentation found for 'Selenium'.
Use help() to get the interactive help utility.
Use help(str) for help on the str class.
感谢您的帮助!
【问题讨论】:
-
这里似乎有很多不同的问题。您的第一个故障排除问题实际上是否类似于“如何检查 Selenium 是否正确安装?”
-
我的问题是:根据这些信息,谁能说出它为什么不起作用?谢谢!