php selenium webdriver run firefox on centos7.2

  • I'm Chinese.
  • the operating environment
  • vagrant + centos7.2_x64
  • selenium-server-standalone-3.4.0.jar
  • Mozilla Firefox 52.2.0
  • php5.4.16 + "facebook/webdriver": "^1.4"
  • my code

    # 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();
    }
    }
    
  • problems

  • [root@test webdriver]# java -version openjdk version "1.8.0_131" OpenJDK Runtime Environment (build 1.8.0_131-b12) OpenJDK 64-Bit Server VM (build 25.131-b12, mixed mode) [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 PHPUnit 4.8.36 by Sebastian Bergmann and contributors.

    E

    Time: 30.46 seconds, Memory: 12.25MB

    There was 1 error:

    1) TestsInstanceDetailModifyNameTest::testModifyName FacebookWebDriverExceptionWebDriverCurlException: Curl error thrown for http POST to /session with params: {"desiredCapabilities":{"browserName":"firefox","platform":"ANY","firefox_profile":"UEsDBBQAAAAIACck20rf9RXUNAAAADIAAAAHAAAAdXNlci5qcystTi2KLyhKTdNQKkpNTEkt0itILCpO1c3P083JT0zRS81LTMpJTVHSUUhLzClO1bTmAgBQSwECAAAUAAAACAAnJNtK3/UV1DQAAAAyAAAABwAAAAAAAAAAAAAAAAAAAAAAdXNlci5qc1BLBQYAAAAAAQABADUAAABZAAAAAAA="}}

    Operation timed out after 30007 milliseconds with 0 out of -1 bytes received

    /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! Tests: 1, Assertions: 0, Errors: 1.

  • I tried other versions of selenium-server,but the problems are same
  • the same code and same environment on win8.1 is ok.
  • I also tried Xvfb reference http://chandrewz.github.io/blog/selenium-on-centos ,still same problems
  • I want your help, Thanks !
  • 链接地址: http://www.djcxy.com/p/62758.html

    上一篇: Selenium脚本从控制台工作,不在CRON中工作

    下一篇: php selenium webdriver在centos7.2上运行firefox