selenium+firefox(geckodriver marionetteProtocol)

selenium+firefox(geckodriver marionetteProtocol)



环境:
CentOS7
python-3.5.2
selenium-3.0.1
firefox-38.3.0-2.el7.centos.x86_64

报错1 'geckodriver':
selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH

原因:
selenium 3.x开始,webdriver/firefox/webdriver.py的__init__中,executable_path="geckodriver";而2.x是executable_path="wires"
firefox 47以上版本,需要下载第三方driver,即geckodriver

解决:
到geckodriver官网找到对应运行平台的驱动,解压至PATH路径即可
https://github.com/mozilla/geckodriver/releases

curl -sSL https://github.com/mozilla/geckodriver/releases/download/v0.11.1/geckodriver-v0.11.1-linux64.tar.gz|tar -xvf - -C /usr/local/bin --gzip



报错2 'marionetteProtocol' :
selenium.common.exceptions.WebDriverException: Message: Missing 'marionetteProtocol' field in handshake

解决:
升级到firefox-45.5 LTS后正常
firefox升级略




环境:
win8.1
python-2.7.12
selenium-3.0.1
firefox-49.0.2
报错3 no 'moz:firefoxOptions.binary' :
selenium+firefox(geckodriver <wbr>marionetteProtocol)

原因:
在PATH路径中没找到firefox的二进制文件

解决:
添加firefox到PATH路径
selenium+firefox(geckodriver <wbr>marionetteProtocol)



环境:
macOS 10.12.1
python-2.7.12
selenium-3.0.1
firefox-47.0.1

读取指定profile:
当测试需要用到插件或者已经导入的证书(比如银行金融和安全加密行业)时,需要事先安装好相应的加密插件。
而selenium启动firefox时会打开一个全新的实例,不含有任何插件和个人证书的firefox(等同于全新安装后第一次打开的那个firefox),这种情况下就要用firefoxprofile了。

先新建一个profile或者直接使用默认,最快捷的方法就是把默认的profile拷贝一份出来。
关于firefox的profile 管理用户配置文件 
selenium+firefox(geckodriver <wbr>marionetteProtocol)

selenium+firefox(geckodriver <wbr>marionetteProtocol)

/Users/jlive/Library/Application Support/Firefox/Profiles/683p874u.default
python版selenium只需修改如下两行
profile = webdriver.FirefoxProfile(’/Users/jlive/Library/Application Support/Firefox/Profiles/683p874u.default’)  # 指定profile
driver = webdriver.Firefox(profile)  # 打开浏览器


原文地址:https://www.cnblogs.com/lixuebin/p/10814000.html