如何在带有Firefox的CentOS 6.10中使用Python运行Selenium Webdriver

时间:2018-08-13 04:11:31

标签: python selenium selenium-webdriver centos geckodriver

我正在尝试在CentOS服务器中运行Python脚本。但是,我一直无法安装Google Chrome(我已经阅读到CentOS不再支持它),所以我决定尝试使用Firefox。但是,尝试在Firefox中运行它时出现以下错误。

Traceback (most recent call last):
File "/home/uscomplianceserv/public_html/scrapdata/FMCSAScraper.py", line 73, in <module>
init_selenium()
File "/home/uscomplianceserv/public_html/scrapdata/FMCSAScraper.py", line 40, in init_selenium
webdriver.Firefox(firefox_options = options, executable_path='/home/uscomplianceserv/public_html/scrapdata/geckodriver')
File "/usr/local/lib/python2.7/site-packages/selenium/webdriver/firefox/webdriver.py", line 133, in __init__
if options.binary is not None:
AttributeError: 'Options' object has no attribute 'binary'

这就是我正在使用的:

  • Centos 6.10
  • Python 2.7
  • 硒3.14.0
  • Firefox 45
  • Geckodriver v0.21.0

这是Selenium Webdriver初始化函数:

def init_selenium():
    global driver, page
    options = Options()
    options.add_argument("-headless")
    driver = webdriver.Firefox(firefox_options = options, executable_path='/home/uscomplianceserv/public_html/scrapdata/geckodriver')
    driver.get(url)

0 个答案:

没有答案