php selenium webdriver在centos7.2上运行firefox
我的代码
# the bootstrap.php file
function create_browser()
{
$desired_capabilities = DesiredCapabilities::firefox();
// $desired_capabilities->setCapability('firefox_binary', "D:Program Files (x86)Mozilla Firefoxfirefox.exe");
$browser = RemoteWebDriver::create('http://localhost:4444/wd/hub', $desired_capabilities, 5000);
//窗口最大化
$browser->manage()->window()->maximize();
//隐性等待 15 秒
$browser->manage()->timeouts()->implicitlyWait(15);
return $browser;
}
# the tests file
namespace TestsInstanceDetail;
class ModifyNameTest extends PHPUnit_Framework_TestCase {
public function testModifyName()
{
// 创建一个浏览器
$browser = create_browser();
// 打开百度
$browser->get(config('url'));
// 检查下标题
$this->assertEquals('百度一下,你就知道', $browser->getTitle());
// 检查下URL
$this->assertEquals('https://www.baidu.com/', $browser->getCurrentURL());
// 关闭浏览器
$browser->quit();
}
}
问题
[root @ test webdriver]#java -version openjdk version“1.8.0_131”OpenJDK Runtime Environment(build 1.8.0_131-b12)OpenJDK 64位服务器虚拟机(build 25.131-b12,混合模式)[root @ test webdriver]# firefox -version Mozilla Firefox 52.2.0 [root @ test webdriver]#whereis firefox firefox:/ usr / bin / firefox / usr / lib64 / firefox / etc / firefox /usr/share/man/man1/firefox.1.gz [ root @ test webdriver]#php -v PHP 5.4.16(cli)(built:Nov 6 2016 00:29:02)Copyright(c)1997-2013 The PHP Group Zend Engine v2.4.0,Copyright(c)1998- 2013 Zend Technologies [root @ test webdriver]#phpunit由Sebastian Bergmann和贡献者撰写的PHPUnit 4.8.36。
Ë
时间:30.46秒,内存:12.25MB
有1个错误:
1)Tests Instance Detail ModifyNameTest :: testModifyName Facebook WebDriver Exception WebDriverCurlException:将HTTP POST引发至/ session为params:{“desiredCapabilities”:{“browserName”:“firefox”,“platform”: “ANY”, “firefox_profile”: “UEsDBBQAAAAIACck20rf9RXUNAAAADIAAAAHAAAAdXNlci5qcystTi2KLyhKTdNQKkpNTEkt0itILCpO1c3P083JT0zRS81LTMpJTVHSUUhLzClO1bTmAgBQSwECAAAUAAAACAAnJNtK3 / UV1DQAAAAyAAAABwAAAAAAAAAAAAAAAAAAAAAAdXNlci5qc1BLBQYAAAAAAQABADUAAABZAAAAAAA =”}}
30007毫秒后操作超时,接收的字节数为0
/var/www/html/webdriver/vendor/facebook/webdriver/lib/Remote/HttpCommandExecutor.php:286 /var/www/html/webdriver/vendor/facebook/webdriver/lib/Remote/RemoteWebDriver.php:126 / var /www/html/webdriver/bootstrap.php:17 /var/www/html/webdriver/tests/instance/detail/ModifyNameTest.php:9
FAILURES! 测试:1,断言:0,错误:1。