尝试使用此代码运行selenium,但它一直在说:
No module named 'options' found
代码:
import os
import sys
import subprocess
import pkg_resources
import selenium
from selenium import webdriver
#from selenium import options
import options
chromedriver = r"E:\Users\Yaseen Ahammed\Documents\Python Projects\chromedriver\chromedriver.exe"
#ChromeOptions = new ChromeOptions();
driver=webdriver.Chrome(chromedriver)
#binary_location
options.setBinary(r"E:\Users\Yaseen Ahammed\Documents\Python Projects\chromedriver\Chrome\Application\chrome.exe")
这个错误是为import options
行抛出的,但是如果没有它,我会在options.setBinary
行上得到options is not defined
的错误
我相信您可以为特定的webdriver导入选项,例如
from selenium.webdriver.chrome.options import Options
或from selenium.webdriver.firefox.options import Options
然后,您可以稍后执行
options = Options()
,然后选项的函数应该可用我想你需要为chrome驱动程序导入这个
在那之后,你应该这样做
我相信你的问题会解决的
此错误消息
…表示您尝试导入的模块,即
options
,如中所示:找不到,因为它不是有效的模块
此外,您需要使用
binary_location
属性,而不是使用setBinary()
方法解决方案
当您使用ChromeDriver/Chrome时,有以下两种解决方案:
由于您已经使用了
from selenium import webdriver
,您可以:您还可以:
参考资料
您可以在以下内容中找到一些相关讨论:
相关问题 更多 >
编程相关推荐