Python Selenium-如何使用此基本代码?
我想学习使用硒,但我真的不知道我做错了什么当我启动基本脚本时,Python shell会立即打开和关闭,不会出现任何错误消息。 我直接从下载Selenium,将其解压缩并单击setup.py。没有错误消息,只显示带有“请按任意按钮”的CMD窗口 我下载的webdriver用于:Python Selenium-如何使用此基本代码?,python,selenium,Python,Selenium,我想学习使用硒,但我真的不知道我做错了什么当我启动基本脚本时,Python shell会立即打开和关闭,不会出现任何错误消息。 我直接从下载Selenium,将其解压缩并单击setup.py。没有错误消息,只显示带有“请按任意按钮”的CMD窗口 我下载的webdriver用于: Chrome-版本89 Firefox版本78.6.1esr(64位),刚刚下载了最新版本0.29.0- 我将所有内容按相同顺序排列(驱动程序、Selenium、要执行的代码),请参见屏幕截图: 以下是Firefo
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.
谢谢你的帮助 直接从pip存储库安装selenium,而不是从源代码构建它 使用 现在如果你真的帮助(“硒”) 你会得到: 如果仍要使用setup.py安装,请使用以下方法: 打开selenium-3.141.0\selenium-3.141.0(解压缩)文件夹,其中setup.py是cmd/terminal中的当前目录,然后运行
pip install .
或
这里似乎有很多不同的问题。您的第一个故障排除问题实际上类似于“如何检查Selenium是否正确安装?”我的问题是:根据这些信息,有人能告诉我为什么它不工作吗?谢谢
pip install .
python setup.py install