Symfony2 + Behat + Selenium2移动测试不起作用

时间:2016-04-20 16:27:31

标签: symfony google-chrome selenium behat

尝试在Symfony2项目中为移动设备设置behat测试。

我正在使用chromedriver运行selenium独立服务器

这是我的配置文件behat.yml

 default:
  suites:
    default:
      contexts:
        - FeatureContext:
          simpleArg: '%%kernel.environment%%'
          session:   '@session'
      mink_session: default
      mink_javascript_session: selenium_chrome_mobile_session

  extensions:
    Behat\Symfony2Extension: ~
    Behat\MinkExtension:
      base_url: http://frontend.local
      show_cmd: open -a Google\ Chrome %s
      sessions:
        default:
          symfony2: ~
        selenium2:
          selenium2:
            wd_host: http://127.0.0.1:4444/wd/hub
        selenium_chrome_mobile_session:
          selenium2:
            browser: chrome
            capabilities:
              extra_capabilities:
                chromeOptions:
                  mobileEmulation:
                    deviceName: "Google Nexus 5"
        selenium_chrome_session:
          selenium2:
            browser: chrome
            capabilities:
              extra_capabilities:
                chromeOptions:
                  args:
                    - "--start-maximized"
                    - "--test-type"

    emuse\BehatHTMLFormatter\BehatHTMLFormatterExtension:
      name: html
      renderer: Twig,Behat2
      file_name: behat_report
      print_args: true
      print_outp: true
      loop_break: true

  formatters:
    html:
      output_path: %paths.base%/web

chrome_mobile:
  extensions:
    Behat\MinkExtension:
      default_session: selenium_chrome_mobile_session

chrome:
  extensions:
    Behat\MinkExtension:
      default_session: selenium_chrome_session

该网站具有适应性(无响应),当我运行移动功能时,响应是针对桌面浏览器的响应。

我的behat.yml中缺少什么?

1 个答案:

答案 0 :(得分:0)

由于某些原因,运行behat with profile不适用于chrome会话

behat -p chrome_mobile -f pretty

相反,我在会话中添加了一个标签来执行。像这样:

Feature: This is my feature

@mink:selenium_chrome_session
Scenario: This is first scenario
When I am in homepage

现在可以使用