2017-04-21 67 views
1

我在PhantomJS上运行Behat测试没有问题。我是这样开始的:奔跑behat铬无头(不含硒?)

bin/phantomjs --webdriver=8643 

它的工作原理,但我想运行一个Chrome headless而不是PhantomJS。要做到这一点,我试过这个:

google-chrome --headless --remote-debugging-port=8643 

但Behat似乎并没有在这个Chrome上启动任何东西。我在Selenium上发现了很多针对Chrome的文档,但我想知道是否可以像Selenium驱动程序运行PhantomJS一样运行它,但是没有Selenium服务器?

default: 
    suites: 
    default: 
     contexts: 
     - FeatureContext 
     - Behat\MinkExtension\Context\MinkContext 
    extensions: 
    Behat\MinkExtension: 
     base_url: 'http://myurl.com/' 
     sessions: 
     default: 
      selenium2: 
      wd_host: 'http://localhost:8643' 

回答

0

要运行在谷歌浏览器的测试,你将需要chromedriver
然后你可以使用的端口chromedriver是(默认9515)听的,而不是PhantomJs 8643.您不需要再硒然后。
最后,您将--headless标志传递给chrome,因此您不需要xfvb。

一个配置例子:

# behat.yml 
default: 
    extensions: 
     # ... 
     Behat\MinkExtension: 
      base_url: 'http://myurl.com/' 
      sessions: 
       default: 
        selenium2: 
         browser: chrome 
         # Note: I'm not totally sure you still need the /wd/hub path 
         wd_host: http://localhost:9515/wd/hub 
         capabilities: 
          chrome: 
           switches: 
            - "--headless" 

更多文档:https://developers.google.com/web/updates/2017/04/headless-chrome