Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/8.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
Javascript 在Mac上将Behat和Mink与Selenium和Chrome、Safari或Firefox连接_Javascript_Macos_Selenium_Testing_Behat - Fatal编程技术网

Javascript 在Mac上将Behat和Mink与Selenium和Chrome、Safari或Firefox连接

Javascript 在Mac上将Behat和Mink与Selenium和Chrome、Safari或Firefox连接,javascript,macos,selenium,testing,behat,Javascript,Macos,Selenium,Testing,Behat,编辑:多亏了,我的系统已经启动并运行了!我已经为任何希望逐步使用Docker容器的Mac用户编写了一个示例,包括使用Docker容器的选项:) 我看了又看,我在任何地方都找不到这个精确的问题,所以我要继续问。。。我对编程相当陌生,所以我不确定哪些信息是明显的/多余的,哪些信息是关键的。我会试着犯太多的错误 我的最终目标是能够在我的Mac电脑上为使用javascript的网站编写和运行Behat测试。如果我完全走错了方向,请随时向其他方向发送 我想学一门教程。在我们谈到硒元素之前,一切都很顺利

编辑:多亏了,我的系统已经启动并运行了!我已经为任何希望逐步使用Docker容器的Mac用户编写了一个示例,包括使用Docker容器的选项:)


我看了又看,我在任何地方都找不到这个精确的问题,所以我要继续问。。。我对编程相当陌生,所以我不确定哪些信息是明显的/多余的,哪些信息是关键的。我会试着犯太多的错误

我的最终目标是能够在我的Mac电脑上为使用javascript的网站编写和运行Behat测试。如果我完全走错了方向,请随时向其他方向发送

我想学一门教程。在我们谈到硒元素之前,一切都很顺利

我正在运行MacOS10.12.6

我使用composer安装了Behat和一些扩展

composer require behat/mink-extension behat/mink-goutte-driver
behat/mink-selenium2-driver facebook/webdriver
(当我键入此内容时,我意识到我的部分问题可能是我试图使用Selenium 2驱动程序来驱动Selenium 3…呃。我应该下载最新版本的Selenium 2吗?除非我读到一些关于Selenium 2不支持最新版本的浏览器的内容,这将是一个令人不快的问题,因为它们都会自动更新到最新版本。)我电脑上的t版本…)

我下载了它,并将它放在~/应用程序中。它不在我的$PATH中,但因为我直接调用它,所以我想它不需要

我还下载了chromedriver和geckodriver,并将它们放在/usr/local/bin/,它位于我的$PATH中

$ ./behat --version
behat version 3.4.3

$ chromedriver --version
ChromeDriver 2.34.522932 (4140ab217e1ca1bec0c4b4d1b148f3361eb3a03e)

$ geckodriver --version
geckodriver 0.19.1
(此时,我只是在谷歌上搜索和下载任何听起来合适的东西,并希望它能起作用……:叹气:)

就浏览器版本而言,我有:

  • Chrome版本63.0.3239.84(官方版本)(64位)
  • Firefox Quantum版本63.0.3239.84(官方版本)(64位)
  • Safari版本11.0.2(12604.4.7.1.4)
如果Behat能成功地与上述任何人交谈,我将非常高兴

My behat.yml包含:

default:
  extensions:
    Behat\MinkExtension:
      base_url: http://127.0.0.1:8000/
      goutte: ~
      selenium2:
        wd_host: 127.0.0.1:4444/wd/hub
<?php

use Behat\Behat\Context\Context;
use Behat\Behat\Context\SnippetAcceptingContext;
use Behat\Gherkin\Node\PyStringNode;
use Behat\Gherkin\Node\TableNode;
use Behat\MinkExtension\Context\MinkContext;

/**
 * Defines application features from the specific context.
 */
class FeatureContext extends MinkContext implements Context, SnippetAcceptingContext
{
    /**
     * Initializes context.
     *
     * Every scenario gets its own context instance.
     * You can also pass arbitrary arguments to the
     * context constructor through behat.yml.
     */
    public function __construct()
    {
    }
}
Feature: Search
  In order to find products dinosaurs love
  As a web user
  I need to be able to search for products

  @javascript
  Scenario: Searching for a product that exists
    Given I am on "/"
    When I fill in "searchTerm" with "Samsung"
    And I press "search_submit"
    Then I should see "Samsung Galaxy"
My FeatureContext.php包含:

default:
  extensions:
    Behat\MinkExtension:
      base_url: http://127.0.0.1:8000/
      goutte: ~
      selenium2:
        wd_host: 127.0.0.1:4444/wd/hub
<?php

use Behat\Behat\Context\Context;
use Behat\Behat\Context\SnippetAcceptingContext;
use Behat\Gherkin\Node\PyStringNode;
use Behat\Gherkin\Node\TableNode;
use Behat\MinkExtension\Context\MinkContext;

/**
 * Defines application features from the specific context.
 */
class FeatureContext extends MinkContext implements Context, SnippetAcceptingContext
{
    /**
     * Initializes context.
     *
     * Every scenario gets its own context instance.
     * You can also pass arbitrary arguments to the
     * context constructor through behat.yml.
     */
    public function __construct()
    {
    }
}
Feature: Search
  In order to find products dinosaurs love
  As a web user
  I need to be able to search for products

  @javascript
  Scenario: Searching for a product that exists
    Given I am on "/"
    When I fill in "searchTerm" with "Samsung"
    And I press "search_submit"
    Then I should see "Samsung Galaxy"
在浏览器的单独选项卡中,我启动了Selenium独立服务器:

$ java -jar /Users/noxlady/Applications/selenium-server-standalone-3.8.1.jar
19:04:54.801 INFO - Selenium build info: version: '3.8.1', revision: '6e95a6684b'
19:04:54.801 INFO - Launching a standalone Selenium Server
2017-12-15 19:04:55.246:INFO::main: Logging initialized @1087ms to org.seleniumhq.jetty9.util.log.StdErrLog
19:04:55.386 INFO - Using `new FirefoxOptions()` is preferred to `DesiredCapabilities.firefox()`
19:04:55.443 INFO - Using `new ChromeOptions()` is preferred to `DesiredCapabilities.chrome()`
19:04:55.458 INFO - Using `new EdgeOptions()` is preferred to `DesiredCapabilities.edge()`
19:04:55.463 INFO - Driver class not found: com.opera.core.systems.OperaDriver
19:04:55.463 INFO - Using `new OperaOptions()` is preferred to `DesiredCapabilities.operaBlink()`
19:04:55.467 INFO - Using `new SafariOptions()` is preferred to `DesiredCapabilities.safari()`
19:04:55.469 INFO - Driver class not found: org.openqa.selenium.phantomjs.PhantomJSDriver
19:04:55.570 INFO - Driver provider class org.openqa.selenium.ie.InternetExplorerDriver registration is skipped:
 registration capabilities Capabilities {browserName: internet explorer, ensureCleanSession: true, platform: WINDOWS, version: } does not match the current platform MAC
19:04:55.570 INFO - Driver provider class org.openqa.selenium.edge.EdgeDriver registration is skipped:
 registration capabilities Capabilities {browserName: MicrosoftEdge, platform: WINDOWS, version: } does not match the current platform MAC
19:04:55.703 INFO - Using `new ChromeOptions()` is preferred to `DesiredCapabilities.chrome()`
19:04:55.703 INFO - Using `new EdgeOptions()` is preferred to `DesiredCapabilities.edge()`
19:04:55.703 INFO - Using `new FirefoxOptions()` is preferred to `DesiredCapabilities.firefox()`
19:04:55.704 INFO - Using `new OperaOptions()` is preferred to `DesiredCapabilities.operaBlink()`
19:04:55.704 INFO - Using `new SafariOptions()` is preferred to `DesiredCapabilities.safari()`
19:04:55.731 INFO - Using the passthrough mode handler
2017-12-15 19:04:55.805:INFO:osjs.Server:main: jetty-9.4.7.v20170914
2017-12-15 19:04:55.870:WARN:osjs.SecurityHandler:main: ServletContext@o.s.j.s.ServletContextHandler@1a75e76a{/,null,STARTING} has uncovered http methods for path: /
2017-12-15 19:04:55.879:INFO:osjsh.ContextHandler:main: Started o.s.j.s.ServletContextHandler@1a75e76a{/,null,AVAILABLE}
2017-12-15 19:04:55.964:INFO:osjs.AbstractConnector:main: Started ServerConnector@79207381{HTTP/1.1,[http/1.1]}{0.0.0.0:4444}
2017-12-15 19:04:55.965:INFO:osjs.Server:main: Started @1806ms
19:04:55.965 INFO - Selenium Server is up and running
“Selenium服务器已启动并运行”这一点听起来很有希望!在我的浏览器中访问这两个页面会让我看到一个很好的Selenium Standalone v.3.8.1页面(仅当Selenium在我的终端中运行时才可用),因此Selenium jar文件似乎正在做一些事情

当我删除@javascript并运行我的测试(使用Goutte)时,我得到:

然而,当我把@javascript放回去(所以它使用的是Selenium)时,Firefox启动了,然后就好像坐在那里一样。大约45秒后,我的终端感到厌烦,并吐出以下内容:

./behat --verbose
Feature: Search
  In order to find products dinosaurs love
  As a web user
  I need to be able to search for products

  @javascript
  Scenario: Searching for a product that exists # features/search.feature:7
    Given I am on "/"                           # FeatureContext::visit()
      WebDriver\Exception\UnknownError: Timed out waiting 45 seconds for Firefox to start.
      Build info: version: '3.8.1', revision: '6e95a6684b', time: '2017-12-01T19:05:32.194Z'
      System info: host: 'Megs-MacBook.local', ip: 'fe80:0:0:0:1057:7410:918d:cd36%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.12.6', java.version: '9.0.1'
      Driver info: driver.version: unknown in vendor/instaclick/php-webdriver/lib/WebDriver/Exception.php:155
      Stack trace:
      #0 vendor/instaclick/php-webdriver/lib/WebDriver/AbstractWebDriver.php(157): WebDriver\Exception::factory(13, 'Timed out waiti...')
      #1 vendor/instaclick/php-webdriver/lib/WebDriver/WebDriver.php(70): WebDriver\AbstractWebDriver->curl('POST', '/session', Array, Array)
      #2 vendor/behat/mink-selenium2-driver/src/Selenium2Driver.php(287): WebDriver\WebDriver->session(Array, Array)
      #3 vendor/behat/mink/src/Session.php(70): Behat\Mink\Driver\Selenium2Driver->start()
      #4 vendor/behat/mink/src/Mink.php(117): Behat\Mink\Session->start()
      #5 vendor/behat/mink-extension/src/Behat/MinkExtension/Context/RawMinkContext.php(108): Behat\Mink\Mink->getSession(NULL)
      #6 vendor/behat/mink-extension/src/Behat/MinkExtension/Context/RawMinkContext.php(131): Behat\MinkExtension\Context\RawMinkContext->getSession(NULL)
      #7 vendor/behat/mink-extension/src/Behat/MinkExtension/Context/MinkContext.php(49): Behat\MinkExtension\Context\RawMinkContext->visitPath('/')
      #8 [internal function]: Behat\MinkExtension\Context\MinkContext->visit('/')
      #9 vendor/behat/behat/src/Behat/Testwork/Call/Handler/RuntimeCallHandler.php(109): call_user_func_array(Array, Array)
      #10 vendor/behat/behat/src/Behat/Testwork/Call/Handler/RuntimeCallHandler.php(64): Behat\Testwork\Call\Handler\RuntimeCallHandler->executeCall(Object(Behat\Behat\Definition\Call\DefinitionCall))
      #11 vendor/behat/behat/src/Behat/Testwork/Call/CallCenter.php(140): Behat\Testwork\Call\Handler\RuntimeCallHandler->handleCall(Object(Behat\Behat\Definition\Call\DefinitionCall))
      #12 vendor/behat/behat/src/Behat/Testwork/Call/CallCenter.php(96): Behat\Testwork\Call\CallCenter->handleCall(Object(Behat\Behat\Definition\Call\DefinitionCall))
      #13 vendor/behat/behat/src/Behat/Behat/Tester/Runtime/RuntimeStepTester.php(125): Behat\Testwork\Call\CallCenter->makeCall(Object(Behat\Behat\Definition\Call\DefinitionCall))
      #14 vendor/behat/behat/src/Behat/Behat/Tester/Runtime/RuntimeStepTester.php(73): Behat\Behat\Tester\Runtime\RuntimeStepTester->testDefinition(Object(Behat\Behat\Context\Environment\InitializedContextEnvironment), Object(Behat\Gherkin\Node\FeatureNode), Object(Behat\Gherkin\Node\StepNode), Object(Behat\Behat\Definition\SearchResult), false)
      #15 vendor/behat/behat/src/Behat/Behat/Hook/Tester/HookableStepTester.php(74): Behat\Behat\Tester\Runtime\RuntimeStepTester->test(Object(Behat\Behat\Context\Environment\InitializedContextEnvironment), Object(Behat\Gherkin\Node\FeatureNode), Object(Behat\Gherkin\Node\StepNode), false)
      #16 vendor/behat/behat/src/Behat/Behat/EventDispatcher/Tester/TickingStepTester.php(59): Behat\Behat\Hook\Tester\HookableStepTester->test(Object(Behat\Behat\Context\Environment\InitializedContextEnvironment), Object(Behat\Gherkin\Node\FeatureNode), Object(Behat\Gherkin\Node\StepNode), false)
      #17 vendor/behat/behat/src/Behat/Behat/EventDispatcher/Tester/EventDispatchingStepTester.php(73): Behat\Behat\EventDispatcher\Tester\TickingStepTester->test(Object(Behat\Behat\Context\Environment\InitializedContextEnvironment), Object(Behat\Gherkin\Node\FeatureNode), Object(Behat\Gherkin\Node\StepNode), false)
      #18 vendor/behat/behat/src/Behat/Behat/Tester/StepContainerTester.php(59): Behat\Behat\EventDispatcher\Tester\EventDispatchingStepTester->test(Object(Behat\Behat\Context\Environment\InitializedContextEnvironment), Object(Behat\Gherkin\Node\FeatureNode), Object(Behat\Gherkin\Node\StepNode), false)
      #19 vendor/behat/behat/src/Behat/Behat/Tester/Runtime/RuntimeScenarioTester.php(76): Behat\Behat\Tester\StepContainerTester->test(Object(Behat\Behat\Context\Environment\InitializedContextEnvironment), Object(Behat\Gherkin\Node\FeatureNode), Object(Behat\Gherkin\Node\ScenarioNode), false)
      #20 vendor/behat/behat/src/Behat/Behat/Hook/Tester/HookableScenarioTester.php(74): Behat\Behat\Tester\Runtime\RuntimeScenarioTester->test(Object(Behat\Behat\Context\Environment\InitializedContextEnvironment), Object(Behat\Gherkin\Node\FeatureNode), Object(Behat\Gherkin\Node\ScenarioNode), false)
      #21 vendor/behat/behat/src/Behat/Behat/EventDispatcher/Tester/EventDispatchingScenarioTester.php(103): Behat\Behat\Hook\Tester\HookableScenarioTester->test(Object(Behat\Behat\Context\Environment\InitializedContextEnvironment), Object(Behat\Gherkin\Node\FeatureNode), Object(Behat\Gherkin\Node\ScenarioNode), false)
      #22 vendor/behat/behat/src/Behat/Behat/Tester/Runtime/IsolatingScenarioTester.php(69): Behat\Behat\EventDispatcher\Tester\EventDispatchingScenarioTester->test(Object(Behat\Behat\Context\Environment\InitializedContextEnvironment), Object(Behat\Gherkin\Node\FeatureNode), Object(Behat\Gherkin\Node\ScenarioNode), false)
      #23 vendor/behat/behat/src/Behat/Behat/Tester/Runtime/RuntimeFeatureTester.php(84): Behat\Behat\Tester\Runtime\IsolatingScenarioTester->test(Object(Behat\Behat\Context\Environment\UninitializedContextEnvironment), Object(Behat\Gherkin\Node\FeatureNode), Object(Behat\Gherkin\Node\ScenarioNode), false)
      #24 vendor/behat/behat/src/Behat/Behat/Hook/Tester/HookableFeatureTester.php(72): Behat\Behat\Tester\Runtime\RuntimeFeatureTester->test(Object(Behat\Behat\Context\Environment\UninitializedContextEnvironment), Object(Behat\Gherkin\Node\FeatureNode), false)
      #25 vendor/behat/behat/src/Behat/Behat/EventDispatcher/Tester/EventDispatchingFeatureTester.php(71): Behat\Behat\Hook\Tester\HookableFeatureTester->test(Object(Behat\Behat\Context\Environment\UninitializedContextEnvironment), Object(Behat\Gherkin\Node\FeatureNode), false)
      #26 vendor/behat/behat/src/Behat/Testwork/Tester/Runtime/RuntimeSuiteTester.php(63): Behat\Behat\EventDispatcher\Tester\EventDispatchingFeatureTester->test(Object(Behat\Behat\Context\Environment\UninitializedContextEnvironment), Object(Behat\Gherkin\Node\FeatureNode), false)
      #27 vendor/behat/behat/src/Behat/Testwork/Hook/Tester/HookableSuiteTester.php(73): Behat\Testwork\Tester\Runtime\RuntimeSuiteTester->test(Object(Behat\Behat\Context\Environment\UninitializedContextEnvironment), Object(Behat\Testwork\Specification\GroupedSpecificationIterator), false)
      #28 vendor/behat/behat/src/Behat/Testwork/EventDispatcher/Tester/EventDispatchingSuiteTester.php(72): Behat\Testwork\Hook\Tester\HookableSuiteTester->test(Object(Behat\Behat\Context\Environment\UninitializedContextEnvironment), Object(Behat\Testwork\Specification\GroupedSpecificationIterator), false)
      #29 vendor/behat/behat/src/Behat/Testwork/Tester/Runtime/RuntimeExercise.php(71): Behat\Testwork\EventDispatcher\Tester\EventDispatchingSuiteTester->test(Object(Behat\Behat\Context\Environment\UninitializedContextEnvironment), Object(Behat\Testwork\Specification\GroupedSpecificationIterator), false)
      #30 vendor/behat/behat/src/Behat/Testwork/EventDispatcher/Tester/EventDispatchingExercise.php(70): Behat\Testwork\Tester\Runtime\RuntimeExercise->test(Array, false)
      #31 vendor/behat/behat/src/Behat/Testwork/Ordering/OrderedExercise.php(80): Behat\Testwork\EventDispatcher\Tester\EventDispatchingExercise->test(Array, false)
      #32 vendor/behat/behat/src/Behat/Testwork/Tester/Cli/ExerciseController.php(149): Behat\Testwork\Ordering\OrderedExercise->test(Array, false)
      #33 vendor/behat/behat/src/Behat/Testwork/Tester/Cli/ExerciseController.php(108): Behat\Testwork\Tester\Cli\ExerciseController->testSpecifications(Object(Symfony\Component\Console\Input\ArgvInput), Array)
      #34 vendor/behat/behat/src/Behat/Testwork/Cli/Command.php(63): Behat\Testwork\Tester\Cli\ExerciseController->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
      #35 vendor/symfony/symfony/src/Symfony/Component/Console/Command/Command.php(242): Behat\Testwork\Cli\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
      #36 vendor/symfony/symfony/src/Symfony/Component/Console/Application.php(842): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
      #37 vendor/symfony/symfony/src/Symfony/Component/Console/Application.php(193): Symfony\Component\Console\Application->doRunCommand(Object(Behat\Testwork\Cli\Command), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
      #38 vendor/behat/behat/src/Behat/Testwork/Cli/Application.php(124): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
      #39 vendor/symfony/symfony/src/Symfony/Component/Console/Application.php(117): Behat\Testwork\Cli\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
      #40 vendor/behat/behat/bin/behat(34): Symfony\Component\Console\Application->run()
      #41 {main}

      Next Behat\Mink\Exception\DriverException: Could not open connection: Timed out waiting 45 seconds for Firefox to start.
      Build info: version: '3.8.1', revision: '6e95a6684b', time: '2017-12-01T19:05:32.194Z'
      System info: host: 'Megs-MacBook.local', ip: 'fe80:0:0:0:1057:7410:918d:cd36%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.12.6', java.version: '9.0.1'
      Driver info: driver.version: unknown in vendor/behat/mink-selenium2-driver/src/Selenium2Driver.php:290
      Stack trace:
      #0 vendor/behat/mink/src/Session.php(70): Behat\Mink\Driver\Selenium2Driver->start()
      #1 vendor/behat/mink/src/Mink.php(117): Behat\Mink\Session->start()
      #2 vendor/behat/mink-extension/src/Behat/MinkExtension/Context/RawMinkContext.php(108): Behat\Mink\Mink->getSession(NULL)
      #3 vendor/behat/mink-extension/src/Behat/MinkExtension/Context/RawMinkContext.php(131): Behat\MinkExtension\Context\RawMinkContext->getSession(NULL)
      #4 vendor/behat/mink-extension/src/Behat/MinkExtension/Context/MinkContext.php(49): Behat\MinkExtension\Context\RawMinkContext->visitPath('/')
      #5 [internal function]: Behat\MinkExtension\Context\MinkContext->visit('/')
      #6 vendor/behat/behat/src/Behat/Testwork/Call/Handler/RuntimeCallHandler.php(109): call_user_func_array(Array, Array)
      #7 vendor/behat/behat/src/Behat/Testwork/Call/Handler/RuntimeCallHandler.php(64): Behat\Testwork\Call\Handler\RuntimeCallHandler->executeCall(Object(Behat\Behat\Definition\Call\DefinitionCall))
      #8 vendor/behat/behat/src/Behat/Testwork/Call/CallCenter.php(140): Behat\Testwork\Call\Handler\RuntimeCallHandler->handleCall(Object(Behat\Behat\Definition\Call\DefinitionCall))
      #9 vendor/behat/behat/src/Behat/Testwork/Call/CallCenter.php(96): Behat\Testwork\Call\CallCenter->handleCall(Object(Behat\Behat\Definition\Call\DefinitionCall))
      #10 vendor/behat/behat/src/Behat/Behat/Tester/Runtime/RuntimeStepTester.php(125): Behat\Testwork\Call\CallCenter->makeCall(Object(Behat\Behat\Definition\Call\DefinitionCall))
      #11 vendor/behat/behat/src/Behat/Behat/Tester/Runtime/RuntimeStepTester.php(73): Behat\Behat\Tester\Runtime\RuntimeStepTester->testDefinition(Object(Behat\Behat\Context\Environment\InitializedContextEnvironment), Object(Behat\Gherkin\Node\FeatureNode), Object(Behat\Gherkin\Node\StepNode), Object(Behat\Behat\Definition\SearchResult), false)
      #12 vendor/behat/behat/src/Behat/Behat/Hook/Tester/HookableStepTester.php(74): Behat\Behat\Tester\Runtime\RuntimeStepTester->test(Object(Behat\Behat\Context\Environment\InitializedContextEnvironment), Object(Behat\Gherkin\Node\FeatureNode), Object(Behat\Gherkin\Node\StepNode), false)
      #13 vendor/behat/behat/src/Behat/Behat/EventDispatcher/Tester/TickingStepTester.php(59): Behat\Behat\Hook\Tester\HookableStepTester->test(Object(Behat\Behat\Context\Environment\InitializedContextEnvironment), Object(Behat\Gherkin\Node\FeatureNode), Object(Behat\Gherkin\Node\StepNode), false)
      #14 vendor/behat/behat/src/Behat/Behat/EventDispatcher/Tester/EventDispatchingStepTester.php(73): Behat\Behat\EventDispatcher\Tester\TickingStepTester->test(Object(Behat\Behat\Context\Environment\InitializedContextEnvironment), Object(Behat\Gherkin\Node\FeatureNode), Object(Behat\Gherkin\Node\StepNode), false)
      #15 vendor/behat/behat/src/Behat/Behat/Tester/StepContainerTester.php(59): Behat\Behat\EventDispatcher\Tester\EventDispatchingStepTester->test(Object(Behat\Behat\Context\Environment\InitializedContextEnvironment), Object(Behat\Gherkin\Node\FeatureNode), Object(Behat\Gherkin\Node\StepNode), false)
      #16 vendor/behat/behat/src/Behat/Behat/Tester/Runtime/RuntimeScenarioTester.php(76): Behat\Behat\Tester\StepContainerTester->test(Object(Behat\Behat\Context\Environment\InitializedContextEnvironment), Object(Behat\Gherkin\Node\FeatureNode), Object(Behat\Gherkin\Node\ScenarioNode), false)
      #17 vendor/behat/behat/src/Behat/Behat/Hook/Tester/HookableScenarioTester.php(74): Behat\Behat\Tester\Runtime\RuntimeScenarioTester->test(Object(Behat\Behat\Context\Environment\InitializedContextEnvironment), Object(Behat\Gherkin\Node\FeatureNode), Object(Behat\Gherkin\Node\ScenarioNode), false)
      #18 vendor/behat/behat/src/Behat/Behat/EventDispatcher/Tester/EventDispatchingScenarioTester.php(103): Behat\Behat\Hook\Tester\HookableScenarioTester->test(Object(Behat\Behat\Context\Environment\InitializedContextEnvironment), Object(Behat\Gherkin\Node\FeatureNode), Object(Behat\Gherkin\Node\ScenarioNode), false)
      #19 vendor/behat/behat/src/Behat/Behat/Tester/Runtime/IsolatingScenarioTester.php(69): Behat\Behat\EventDispatcher\Tester\EventDispatchingScenarioTester->test(Object(Behat\Behat\Context\Environment\InitializedContextEnvironment), Object(Behat\Gherkin\Node\FeatureNode), Object(Behat\Gherkin\Node\ScenarioNode), false)
      #20 vendor/behat/behat/src/Behat/Behat/Tester/Runtime/RuntimeFeatureTester.php(84): Behat\Behat\Tester\Runtime\IsolatingScenarioTester->test(Object(Behat\Behat\Context\Environment\UninitializedContextEnvironment), Object(Behat\Gherkin\Node\FeatureNode), Object(Behat\Gherkin\Node\ScenarioNode), false)
      #21 vendor/behat/behat/src/Behat/Behat/Hook/Tester/HookableFeatureTester.php(72): Behat\Behat\Tester\Runtime\RuntimeFeatureTester->test(Object(Behat\Behat\Context\Environment\UninitializedContextEnvironment), Object(Behat\Gherkin\Node\FeatureNode), false)
      #22 vendor/behat/behat/src/Behat/Behat/EventDispatcher/Tester/EventDispatchingFeatureTester.php(71): Behat\Behat\Hook\Tester\HookableFeatureTester->test(Object(Behat\Behat\Context\Environment\UninitializedContextEnvironment), Object(Behat\Gherkin\Node\FeatureNode), false)
      #23 vendor/behat/behat/src/Behat/Testwork/Tester/Runtime/RuntimeSuiteTester.php(63): Behat\Behat\EventDispatcher\Tester\EventDispatchingFeatureTester->test(Object(Behat\Behat\Context\Environment\UninitializedContextEnvironment), Object(Behat\Gherkin\Node\FeatureNode), false)
      #24 vendor/behat/behat/src/Behat/Testwork/Hook/Tester/HookableSuiteTester.php(73): Behat\Testwork\Tester\Runtime\RuntimeSuiteTester->test(Object(Behat\Behat\Context\Environment\UninitializedContextEnvironment), Object(Behat\Testwork\Specification\GroupedSpecificationIterator), false)
      #25 vendor/behat/behat/src/Behat/Testwork/EventDispatcher/Tester/EventDispatchingSuiteTester.php(72): Behat\Testwork\Hook\Tester\HookableSuiteTester->test(Object(Behat\Behat\Context\Environment\UninitializedContextEnvironment), Object(Behat\Testwork\Specification\GroupedSpecificationIterator), false)
      #26 vendor/behat/behat/src/Behat/Testwork/Tester/Runtime/RuntimeExercise.php(71): Behat\Testwork\EventDispatcher\Tester\EventDispatchingSuiteTester->test(Object(Behat\Behat\Context\Environment\UninitializedContextEnvironment), Object(Behat\Testwork\Specification\GroupedSpecificationIterator), false)
      #27 vendor/behat/behat/src/Behat/Testwork/EventDispatcher/Tester/EventDispatchingExercise.php(70): Behat\Testwork\Tester\Runtime\RuntimeExercise->test(Array, false)
      #28 vendor/behat/behat/src/Behat/Testwork/Ordering/OrderedExercise.php(80): Behat\Testwork\EventDispatcher\Tester\EventDispatchingExercise->test(Array, false)
      #29 vendor/behat/behat/src/Behat/Testwork/Tester/Cli/ExerciseController.php(149): Behat\Testwork\Ordering\OrderedExercise->test(Array, false)
      #30 vendor/behat/behat/src/Behat/Testwork/Tester/Cli/ExerciseController.php(108): Behat\Testwork\Tester\Cli\ExerciseController->testSpecifications(Object(Symfony\Component\Console\Input\ArgvInput), Array)
      #31 vendor/behat/behat/src/Behat/Testwork/Cli/Command.php(63): Behat\Testwork\Tester\Cli\ExerciseController->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
      #32 vendor/symfony/symfony/src/Symfony/Component/Console/Command/Command.php(242): Behat\Testwork\Cli\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
      #33 vendor/symfony/symfony/src/Symfony/Component/Console/Application.php(842): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
      #34 vendor/symfony/symfony/src/Symfony/Component/Console/Application.php(193): Symfony\Component\Console\Application->doRunCommand(Object(Behat\Testwork\Cli\Command), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
      #35 vendor/behat/behat/src/Behat/Testwork/Cli/Application.php(124): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
      #36 vendor/symfony/symfony/src/Symfony/Component/Console/Application.php(117): Behat\Testwork\Cli\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
      #37 vendor/behat/behat/bin/behat(34): Symfony\Component\Console\Application->run()
      #38 {main}
    When I fill in "searchTerm" with "Samsung"  # FeatureContext::fillField()
    And I press "search_submit"                 # FeatureContext::pressButton()
    Then I should see "Samsung Galaxy"          # FeatureContext::assertPageContainsText()

--- Failed scenarios:

    features/search.feature:7

1 scenario (1 failed)
4 steps (1 failed, 3 skipped)
0m46.70s (13.28Mb)
同时,在运行Selenium Server的终端选项卡中添加了以下内容:

2017-12-15 19:14:05.837:INFO:osjshC.ROOT:qtp1021436681-16: org.openqa.selenium.remote.server.WebDriverServlet-49049a04: Initialising WebDriverServlet
19:14:05.975 INFO - Found handler: org.openqa.selenium.remote.server.commandhandler.BeginSession@a667021
19:14:05.990 INFO - /session: Executing POST on /session (handler: BeginSession)
19:14:06.197 INFO - Capabilities are: Capabilities {browser: firefox, browserName: firefox, ignoreZoomSetting: false, marionette: false, name: Behat feature suite, tags: [Megs-MacBook.local, PHP 7.0.24]}
19:14:06.202 INFO - Capabilities {browser: firefox, browserName: firefox, ignoreZoomSetting: false, marionette: false, name: Behat feature suite, tags: [Megs-MacBook.local, PHP 7.0.24]} matched class org.openqa.selenium.remote.server.ServicedSession$Factory (provider: org.openqa.selenium.firefox.XpiDriverService)
如果你们中的任何人有在Mac上与浏览器对话的经验,我将非常感谢你们的帮助。如果你们需要更多信息(如日志或其他),我完全会提供,但你们可能需要给我“白痴指南”,说明如何找到它


无论如何,感谢您努力完成这一切,并提前感谢您提供的任何帮助:)

您需要在启动selenium服务器时设置驱动程序

java -Dwebdriver.chrome.driver=path_to_chrome_driver -jar path_to_selenium_server.jar
我建议将它们(selenium服务器和浏览器驱动程序)放在同一个目录中,并使用bash脚本启动服务器。
如果本地计算机上的服务器具有默认端口
4444
,则不必指定
wd\u主机

我没有试过firefox,chrome很好用。 当您使用浏览器时,您应该让
@javascript
在功能级别进行标记,您也可以使用
@insulated
,这样您的浏览器就可以在没有cookie和缓存的情况下干净地启动

@insulated @javascript
Feature: Feature name


  @my_tag
  Scenario: Feature name - scenario summary
试试behat.yml,比如:

default: suites: default: contexts: - FeatureContext formatters: pretty: junit: html: output_path: %paths.base%/report extensions: Behat\MinkExtension: goutte: ~ selenium2: browser: chrome capabilities: chrome: switches: - "start-maximized" base_url: 'base_url' dev: extensions: Behat\MinkExtension: base_url: 'base_url_dev' 违约: 套房: 违约: 上下文: -特性上下文 格式化程序: 漂亮的: 朱尼特: html: 输出路径:%path.base%/报告 扩展: 行为\MinkExtension: 痛风:~ 硒M2: 浏览器:chrome 能力: 铬: 开关: -“开始最大化” 基本url:“基本url” 开发人员: 扩展: 行为\MinkExtension: 基本url:“基本url\u开发”
使用其他浏览器时,还应使用该驱动程序启动selenium服务器,并更改behat.yml中的名称。对于firefox,您需要geckdriver,并使用gecko.driver而不是chrome。

另一种解决方案是跳过selenium,直接通过ChromeExtension D.More使用chrome驱动程序。使用Chrome驱动程序可以在窗口和无头环境下工作。使用无头版本的chrome和该驱动程序也比使用selenium快得多。请参考my behat.yml:

default:
translation:
    locale: nl
extensions:
    DMore\ChromeExtension\Behat\ServiceContainer\ChromeExtension: ~
    Behat\MinkExtension:
        browser_name: chrome
        base_url: https://www.yoursite.com
        sessions:
            default:
                chrome:
                    api_url: "http://127.0.0.1:9222"
                    download_behavior: allow
                    download_path: ~/Downloads
                    validate_certificate: false
还有我的composer.json:

{
"require-dev": {
    "behat/behat": "^3.4",
    "behat/mink-extension": "^2.3",
    "behat/mink-selenium2-driver": "^1.3"
},
"require": {
    "behat/mink-goutte-driver": "^1.2",
    "dmore/chrome-mink-driver": "^2.5",
    "dmore/behat-chrome-extension": "^1.1"
}
}

请注意,在运行behat之前,您需要启动chrome(无头或无头)。为此,我在.bash_配置文件中创建了三个别名(在我的主目录中:

alias chrome='/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome'
alias chromedriver='chrome --disable-gpu --remote-debugging-address=127.0.0.1 --remote-debugging-port=9222'
alias chromedriverheadless='chrome --disable-gpu --headless --remote-debugging-address=127.0.0.1 --remote-debugging-port=9222'
chromedriver(检查您在$PATH某处的位置)应该与安装的Chrome版本匹配。如果它停止工作,Chrome通常会自动更新,但chromedriver不会。
我在我的mac电脑上使用了这个解决方案。

遇到了同样的问题,您只需设置
木偶:null

extensions:
    Behat\MinkExtension:
        base_url: http://127.0.0.1:8000
        javascript_session: selenium2

        browser_name: chrome
        selenium2:
            capabilities:
                # required by mink-extension 2.3
                marionette: null
                browserName: chrome
                browser: chrome
                version: 63

嘿,劳达,谢谢你的建议。不幸的是,它对我不起作用,但也许你有更多的想法。我将selenium jar文件移到了/usr/local/bin,这样它就可以与chromedriver和geckodriver一起使用了。我根据你的建议更改了我的behat.yml,然后在另一个选项卡中使用“java-Dwebdriver.chrome.driver=/usr/local/bin/chromedriver-jar/usr/local/bin/selenium-server-standalone-3.8.1.jar”。当我尝试运行behat时,发生了和以前一样的事情。也就是说,Firefox打开后挂在那里……没有chrome。想法???附带问题