我如何使用php webdriver获得chrome与硒的协同工作? [英] How do I get chrome working with selenium, using php webdriver?

查看:203
本文介绍了我如何使用php webdriver获得chrome与硒的协同工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Firefox一切正常,但我无法启动Chrome。

  require_once/ usr / local / src / selenium / php-webdriver-绑定-0.9.0 / phpwebdriver / WebDriver.php; 
putenv(PATH =。getenv(PATH)。':'。'/ usr / local / src / selenium / chrome_webdriver /'); //准备chrome

$ webdriver = new WebDriver(localhost,4444);
// $ webdriver-> connect(chrome);
$ webdriver-> connect(chrome,,array(
'webdriver.chrome.driver'=>'/ usr / local / src / selenium / chrome_webdriver / chromedriver',
));

我得到的错误信息是 chromedriver可执行文件的路径必须由webdriver.chrome.driver系统属性。正如你所看到的,我已经尝试在desiredCapabilities数组中设置它,但那必须是错误的地方。

 信息 - 执行:[新会话:URL:/ session){{javascriptEnabled = true,webdriver.chrome.driver = / usr / local / src / selenium / chrom ...,browserName = chrome,nativeEvents = false,version =}] 

我使用来启动selenium-java -jar selenium-server-standalone-2.21.0.jar

我使用Chromium v​​.18。



我创建了一个快捷方式/ usr / bin / google-chrome指向/ usr / bin / chromium-browser



我可以手动启动chromedriver而不会出现任何问题。它说:

  port = 9515 
version = 20.0.1133.0



运行或不运行对selenium给我的错误信息没有任何影响。



更新:相关问题: selenium 2铬驱动程序(答案有java,不是php)

解决方案

在启动selenium服务器时,您可以尝试从命令行传递webdriver.chrome.driver属性。像这样:

  java -Dwebdriver.chrome.driver = pathtochromedriver -jar selenium-server.jar 

我不确定另一个不工作的原因。您需要检查确实是否从代码中设置系统属性..


Everything works fine with Firefox, but I can't start chrome. I'm on linux, using php webdriver bindings.

require_once "/usr/local/src/selenium/php-webdriver-bindings-0.9.0/phpwebdriver/WebDriver.php";
putenv("PATH=".getenv("PATH").':'.'/usr/local/src/selenium/chrome_webdriver/'); //Prepare for chrome

$webdriver = new WebDriver("localhost", "4444");
//$webdriver->connect("chrome");
$webdriver->connect("chrome","",array(
    'webdriver.chrome.driver'=>'/usr/local/src/selenium/chrome_webdriver/chromedriver',
    ));

The error message I get is "The path to the chromedriver executable must be set by the webdriver.chrome.driver system property". As you can see, I've tried setting that in the desiredCapabilities array, but that must be the wrong place. I can see in the selenium logs that my setting is getting through as this log line shows:

INFO - Executing: [new session: {javascriptEnabled=true, webdriver.chrome.driver=/usr/local/src/selenium/chrom..., browserName=chrome, nativeEvents=false, version=}] at URL: /session)

I start selenium with java -jar selenium-server-standalone-2.21.0.jar

I'm using Chromium v.18.

I created a shortcut /usr/bin/google-chrome that points to /usr/bin/chromium-browser

I can start chromedriver manually with no problems. It says:

port=9515
version=20.0.1133.0

Having that running, or not, does not make any difference to the error message selenium gives me.

UPDATE: Related question: selenium 2 chrome driver (answer there is for java, not php)

解决方案

You can try passing the webdriver.chrome.driver property from commandline while starting the selenium server. Like this:

 java -Dwebdriver.chrome.driver = pathtochromedriver -jar selenium-server.jar

I am not sure about the reason why the other one is not working. You need to check whether its really setting the system property from code..

这篇关于我如何使用php webdriver获得chrome与硒的协同工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆