Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/321.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/247.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Symfony2 Selenium Behat base_url未加载_Java_Php_Symfony_Selenium - Fatal编程技术网

Java Symfony2 Selenium Behat base_url未加载

Java Symfony2 Selenium Behat base_url未加载,java,php,symfony,selenium,Java,Php,Symfony,Selenium,我正在为symfony2中的一个应用程序设置测试环境,但我遇到一些错误,我在网上找不到一致的答案 作曲家json behat.yml-旧的 behat.yml-新的 特征 我正在使用 selenium/selenium-server-standalone-2.50.1.jar Firefox 44安装在我的操作系统(Linux Mint)中 浏览器启动,但未触发url 正如您看到的,url输入为空,几秒钟后,浏览器关闭,测试失败 当我运行echo$this->getSession()->g

我正在为symfony2中的一个应用程序设置测试环境,但我遇到一些错误,我在网上找不到一致的答案

作曲家json

behat.yml-旧的

behat.yml-新的

特征

我正在使用

  • selenium/selenium-server-standalone-2.50.1.jar

  • Firefox 44安装在我的操作系统(Linux Mint)中

浏览器启动,但未触发url

正如您看到的,url输入为空,几秒钟后,浏览器关闭,测试失败

当我运行
echo$this->getSession()->getCurrentUrl()时
I get
about:blank
因此显然
base\u url
被忽略

如果我手动输入url,则一切正常


我没有安装虚拟机或其他东西,只是安装了最新版本的firefox/chrome和最新版本的selenium的linux机箱,这也是我的开发环境。

我可以确认这个示例对我有效。从你那里得到的

composer.json

{
    "require-dev": {
        "behat/behat" : "3.0.15",
        "behat/symfony2-extension" : "2.0.0",
        "behat/mink": "1.6.1",
        "behat/mink-extension": "2.0.1",
        "behat/mink-browserkit-driver": "1.2.0",
        "behat/mink-goutte-driver": "1.1.0",
        "behat/mink-selenium2-driver": "1.2.0"
    }
}
Feature: Visit pages and see contents

  Scenario: I visit home page and see welcome message
    Given I am on "/"
    Then I should see "Welcome to Application!"

  Scenario: I visit contact page and see contact message
    Given I am on "/contact"
    Then I should see "Contact me!"
behat.yml

default:
    extensions:
        Behat\Symfony2Extension: ~
        Behat\MinkExtension:
            base_url: http://myapp.lan/app_test.php
            browser_name: firefox
            sessions:
                goutte:
                    goutte: ~
                selenium2:
                    selenium2: ~
                symfony2:
                    symfony2: ~
    suites:
        backend:
            type: symfony_bundle
            bundle: ApplicationBackendBundle #Change this with your
            mink_session: symfony2
            contexts:
                - Application\BackendBundle\Features\Context\FeatureContext: #Change this with your
                    param1: hello
                    param2: world
功能上下文

namespace Application\BackendBundle\Features\Context;

use Behat\MinkExtension\Context\MinkContext;

class FeatureContext extends MinkContext
{
    private $param1;
    private $param2;

    public function __construct($param1, $param2)
    {
        $this->param1 = $param1;
        $this->param2 = $param2;
    }
}
小黄瓜

{
    "require-dev": {
        "behat/behat" : "3.0.15",
        "behat/symfony2-extension" : "2.0.0",
        "behat/mink": "1.6.1",
        "behat/mink-extension": "2.0.1",
        "behat/mink-browserkit-driver": "1.2.0",
        "behat/mink-goutte-driver": "1.1.0",
        "behat/mink-selenium2-driver": "1.2.0"
    }
}
Feature: Visit pages and see contents

  Scenario: I visit home page and see welcome message
    Given I am on "/"
    Then I should see "Welcome to Application!"

  Scenario: I visit contact page and see contact message
    Given I am on "/contact"
    Then I should see "Contact me!"
附加 Selenium和Firefox都有我以前遇到过的兼容性问题。如果你在谷歌上搜索,你会看到类似的帖子。请按以下顺序尝试:

  • 尝试
    selenium-server-standalone-2.43.1.jar
    version
  • 使用chromedriver尝试Chrome浏览器
    你真的应该举个例子。

    不,它不起作用。问题是浏览器启动了,但url没有填满。如果我手动输入它,测试就会运行,它会在*.feature中找到我正在搜索的一些文本。是的,浏览器已安装,我可以访问我的应用程序,我正在使用Behat3添加您的功能步骤。我更新了答案,使其适用于Behat3,对我来说效果良好。这是经典的Selenium和Firefox兼容性问题。请参阅上面的附加部分。今天早上我也尝试了第二点,我得到的数据不是url;。而不是url。
    namespace Application\BackendBundle\Features\Context;
    
    use Behat\MinkExtension\Context\MinkContext;
    
    class FeatureContext extends MinkContext
    {
        private $param1;
        private $param2;
    
        public function __construct($param1, $param2)
        {
            $this->param1 = $param1;
            $this->param2 = $param2;
        }
    }
    
    Feature: Visit pages and see contents
    
      Scenario: I visit home page and see welcome message
        Given I am on "/"
        Then I should see "Welcome to Application!"
    
      Scenario: I visit contact page and see contact message
        Given I am on "/contact"
        Then I should see "Contact me!"