javascript - 在 Mac 上将 Behat 和 Mink 与 Selenium 和 Chrome 或 Safari 或 Firefox 连接

标签 javascript macos selenium testing behat

编辑:感谢mykbas's answer ,我的系统启动并运行了!我写了一个 pretty thorough how-to对于任何想要逐步了解的 Mac 用户,包括使用 Docker 容器的选项:)


我看了又看,在任何地方都找不到这个精确的问题,所以我要继续问...我对编程很陌生,所以我不确定什么信息是显而易见的/冗余的,哪些信息是至关重要的。我会尽量避免犯太多错误。

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

我正在尝试关注 BDD, Behat, Mink and other Wonderful Things教程。在我们到达涉及 Selenium 的部分之前一切顺利。

我正在运行 Mac OS 10.12.6

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

composer require behat/mink-extension behat/mink-goutte-driver
behat/mink-selenium2-driver facebook/webdriver

(当我输入这个时,我意识到我的部分问题可能是我正在尝试使用 Selenium 2 驱动程序来驱动 Selenium 3... minkphp/MinkSelenium2Driver: Selenium 3 support #254 呃。我应该去下载最新的吗Selenium 2 的版本?除了我读到一些关于 Selenium 2 不支持最新版本浏览器的信息,这将是一个无赖,因为它们都会自动更新到我计算机上的最新版本...)

我下载了Selenium Standalone Server 3.8.1并将其粘贴在 ~/Applications 中。它不在我的 $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

(此时我只是在谷歌上搜索并下载听起来适用的任何内容,并希望某些内容有效...:sigh:)

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

  • Chrome 版本 63.0.3239.84(正式版)(64 位)
  • Firefox Quantum 版本 63.0.3239.84(正式版)(64 位)
  • Safari 版本 11.0.2 (12604.4.7.1.4)

如果 Behat 能够成功地与上述任何交谈,我将非常高兴。

我的 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

我的 FeatureContext.php 包含:

<?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()
    {
    }
}

我的/features/search.feature 包含:

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 服务器已启动并正在运行”听起来很有前途!访问两者http://127.0.0.1:4444/http://0.0.0.0:4444/在我的浏览器中将我带到一个漂亮的 Selenium Standalone v.3.8.1 页面(只有当 Selenium 在我的终端中运行时才可用),所以 Selenium jar 文件似乎在做某事 ...

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

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

  Scenario: Searching for a product that exists # features/search.feature:7
    Given I am on "/"                           # FeatureContext::visit()
    When I fill in "searchTerm" with "Samsung"  # FeatureContext::fillField()
    And I press "search_submit"                 # FeatureContext::pressButton()
    Then I should see "Samsung Galaxy"          # FeatureContext::assertPageContainsText()

1 scenario (1 passed)
4 steps (4 passed)
0m3.15s (14.27Mb)

但是,当我将@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)

如果你们中有人有过让 Behat 在 Mac 上与浏览器对话的经验,我将非常非常感谢你们的帮助。如果您需要更多信息(如日志或其他信息),我会完全提供,但您可能需要给我“白痴指南”说明如何找到它...

无论如何,感谢您辛苦地完成所有这些工作,并提前感谢您提供的任何帮助:)

最佳答案

遇到同样的问题,有一个known issue with new mink-extension 2.3您只需要设置 marionette: 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

关于javascript - 在 Mac 上将 Behat 和 Mink 与 Selenium 和 Chrome 或 Safari 或 Firefox 连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47842262/

相关文章:

javascript - 不允许使用 Gulp、Restangular、Java EE 和 Wildfly 8 访问 Origin 'http://localhost:8888'

javascript - 无法设置 null 的属性 'innerHTML' - 似乎没有办法修复它

objective-c - 旧版本 iOS 和 OS X 上的 ARC

javascript - 断言元素列表遵循 JavaScript Promise 的规则

php - 如何在javascript中使用 anchor 的OnClick关闭弹出窗口?

javascript - 如何在保持渐进增强的同时隐藏要使用 jquery 切换的元素

macos - 为什么我的 MAMP PRO 本地开发站点在 Firefox 和 Chrome 中运行缓慢?

objective-c - NSPreferencePane 中的 NSToolbar

c# - Selenium PhantomJsDriver、C#、SendKeys 无法正常工作

java - 如何使用 Selenium 获取 css 类名?