php – Selenium2 firefox:使用默认配置文件
Selenium2,默认情况下,启动一个新的配置文件的Firefox.我喜欢这个默认,但由于一些很好的原因(访问我的书签,保存的密码,使用我的附加组件等)我想从我的默认配置文件开始.
有supposed to be属性控制这个,但我认为文档与源不同步,因为我可以告诉webdriver.firefox.bin是唯一的工作.例如.开始硒: java -jar selenium-server-standalone-2.5.0.jar -Dwebdriver.firefox.bin=not-there 作品(即它抱怨).但这没有效果: java -jar selenium-server-standalone-2.5.0.jar -Dwebdriver.firefox.profile=default (“default”是profiles.ini中的名称,但我也尝试了“Profile0”,它是profiles.ini中的部分的名称). 我使用PHPWebdriver(使用JsonWireProtocol)访问: $webdriver = new WebDriver("localhost","4444"); $webdriver->connect("firefox"); 我试过从PHP方面做: $webdriver->connect("firefox","",array('profile'=>'default') ); 要么: $webdriver->connect("firefox",array('profile'=>'Profile0') ); 没有成功(firefox启动,但不使用我的配置文件). 我还尝试了黑客创建批处理文件的方法: #!/bin/bash /usr/bin/firefox -P default 然后开始硒: Firefox启动,但不使用默认配置文件,更糟糕的是,一切都挂起来:当以这种方式启动时,硒似乎无法与firefox通信. 附:我看到Selenium – Custom Firefox profile我试过这个: java -jar selenium-server-standalone-2.5.0.jar -firefoxProfileTemplate "not-there" 而且它拒绝运行!兴奋的,以为我可能在做某事,我试过: java -jar selenium-server-standalone-2.5.0.jar -firefoxProfileTemplate /path/to/0abczyxw.default/ 这什么都不做.即它仍然从一个新的配置文件开始:-(
西蒙·斯图尔特
answered this on the mailing list给我
总结一下他的答复:你把你的firefox档案,拉链(zip,而不是tgz),base64编码,然后发送整个东西作为一个/session json request(把base64字符串放在firefox_profile键的Capabilities对象). 在Linux上执行此操作的一个示例方法: cd /your/profile zip -r profile * base64 profile.zip > profile.zip.b64 然后如果你在连接时使用PHPWebDriver做: $webdriver->connect("firefox",array("firefox_profile" => file_get_contents("/your/profile/profile.zip.b64"))) 注意:它仍然不会是我的真实个人资料,而不是它的副本.所以书签不会被记住,缓存不会被填充等. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |