douqiao2008 2016-08-03 14:15
浏览 77
已采纳

Behat-Mink,强制Selenium驱动程序使用Chrome而不是Firefox

So I want to run my tests in Chrome instead of Firefox (because Chrome offers mobile emulation capability) when using Selenium driver with Behat's Mink extension.

I'm running Selenium stand alone on a testing server, and running tests on a local machine.

So after running Behat tests, a Chrome session is created but is not used, instead, another parallel Firefox session also get created and gets used to run the test scenarios.

I tried that also in an environment with graphical display abilities, so a new Chrome window opens but only data;; is displayed in the address bar, then afterwards a Firefox window opens and tests are run there.

I'm running the latest version of Chrome (52.0.2743.82), Selenium standalone server (2.53.1 - Java version) and Chromedriver (2.22.397932)

My behat.yml contains the following:

default:
    extensions:
        Behat\MinkExtension:
            browser_name: chrome
            base_url: "<url to website>"
            default_session: selenium_chrome_session
            goutte: ~
            sessions:
                selenium_chrome_session:
                    selenium2:
                        browser: chrome
                        wd_host: "http://<testing server host>:4444/wd/hub"
                        capabilities:
                            extra_capabilities:
                                chromeOptions:
                                    args:
                                        - "--start-maximized"
                                        - "--test_type"

After looking at Selenium standalone server's logfile, I get the following output:

15:44:47.677 INFO [45] org.openqa.selenium.remote.server.DriverServlet - Executing: [new session: Capabilities [{chrome.switches=[--no-sandbox], browser=chrome, name=Behat feature suite, browserName=chrome, chrome.extensions=[], ignoreZoomSetting=false, chromeOptions={args=[--no-sandbox], extensions=[]}, version=, tags=[PHP 5.6.21-1~dotdeb+7.1]}]])
15:44:47.678 INFO [113] org.openqa.selenium.remote.server.DefaultDriverProvider - Creating a new session for Capabilities [{chrome.switches=[--no-sandbox], browser=chrome, name=Behat feature suite, browserName=chrome, chrome.extensions=[], ignoreZoomSetting=false, chromeOptions={args=[--no-sandbox], extensions=[]}, version=, tags=[PHP 5.6.21-1~dotdeb+7.1]}]
15:44:48.021 INFO [45] org.openqa.selenium.remote.server.DriverServlet - Done: [new session: Capabilities [{chrome.switches=[--no-sandbox], browser=chrome, name=Behat feature suite, browserName=chrome, chrome.extensions=[], ignoreZoomSetting=false, chromeOptions={args=[--no-sandbox], extensions=[]}, version=, tags=[PHP 5.6.21-1~dotdeb+7.1]}]]
15:44:48.035 INFO [45] org.openqa.selenium.remote.server.DriverServlet - Executing: [new session: Capabilities [{deviceType=tablet, selenium-version=2.31.0, browserVersion=9, browser=firefox, name=Behat Test, browserName=firefox, deviceOrientation=portrait, version=9, platform=ANY}]])
15:44:48.036 INFO [120] org.openqa.selenium.remote.server.FirefoxDriverProvider - Creating a new session for Capabilities [{deviceType=tablet, selenium-version=2.31.0, browserVersion=9, browser=firefox, name=Behat Test, browserName=firefox, deviceOrientation=portrait, version=9, platform=ANY}]

As you can see, Chrome session is successfully created, and then a new Firefox session is created afterwards and is used to conduct tests.

  • 写回答

3条回答 默认 最新

  • dtkz3186 2016-08-04 10:16
    关注

    If the issues is not from the yml setup then you might have some custom code in the FeatureContext class that overrides your desired session and starts a new one.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?