jhedstrom / drupalextension

An integration layer between Behat, Mink Extension, and Drupal.
GNU General Public License v2.0
209 stars 192 forks source link

DrupalContext::assertAuthenticatedByRole Firefox ONLY failing with mouseMoveTo Error #394

Open hkorik opened 7 years ago

hkorik commented 7 years ago

I have just started to setup behat tests on my local Drupal 8 using MAMP as the local environment. It seems at any attempt to login using a browser with the pre built language for logging in as a user it fails with a mouseMoveTo exception error.

The error is occurring in any way I attempt to use the login context: Given I am logged in as a user with the "administrator" role # Drupal\DrupalExtension\Context\DrupalContext::assertAuthenticatedByRole()

or with: And I press "Log in" # Drupal\DrupalExtension\Context\MinkContext::pressButton() See below the error output in both the terminal running behat and the terminal running the selenium standalone server.

As I am new to this I'm wondering if I'm doing something wrong here or if there is a bug with some of the versions I am running together. I have googled and tried many options with changing the versions of some of the below systems or changing the wording of the feature tests with no luck.

Here is reference to a github issue filed in an angular project with the same exact issue I'm seeing in my drupal project (in case that helps..) - https://github.com/angular/protractor/issues/4177

Any assistance or guidance would be greatly appreciated.

Specs:

Output of behat features/drupal.feature:17

 @api
  Scenario: Create many nodes                                    # features/drupal.feature:17
    Given I am logged in as a user with the "administrator" role # Drupal\DrupalExtension\Context\DrupalContext::assertAuthenticatedByRole()
      mouseMoveTo
      Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'
      System info: host: 'Hershys-MacBook-Pro.local', ip: '2601:8c:4300:98dd:0:0:0:4472', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.12.5', java.version: '1.8.0_131'

Output of error in terminal running selenium server:

[translate(./@role, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz') = 'button'][((./@id = 'Log in' or ./@name = 'Log in') or ./@value = 'Log in' or ./@title = 'Log in' or normalize-space(string(.)) = 'Log in')])[1]]
10:42:59.082 INFO - Executing: [mousemove: 2 false])
10:42:59.082 WARN - Exception thrown
org.openqa.selenium.UnsupportedCommandException: mouseMoveTo
Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'
System info: host: 'Hershys-MacBook-Pro.local', ip: '2601:8c:4300:98dd:0:0:0:4472', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.12.5', java.version: '1.8.0_131'
Driver info: driver.version: RemoteWebDriver
    at org.openqa.selenium.remote.http.AbstractHttpCommandCodec.encode(AbstractHttpCommandCodec.java:220)
    at org.openqa.selenium.remote.http.AbstractHttpCommandCodec.encode(AbstractHttpCommandCodec.java:118)
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:637)
    at org.openqa.selenium.remote.RemoteExecuteMethod.execute(RemoteExecuteMethod.java:35)
    at org.openqa.selenium.remote.RemoteMouse.mouseMove(RemoteMouse.java:89)
    at org.openqa.selenium.support.events.internal.EventFiringMouse.mouseMove(EventFiringMouse.java:58)
    at org.openqa.selenium.remote.server.handler.interactions.MouseMoveToLocation.call(MouseMoveToLocation.java:59)
    at org.openqa.selenium.remote.server.handler.interactions.MouseMoveToLocation.call(MouseMoveToLocation.java:32)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at org.openqa.selenium.remote.server.DefaultSession$1.run(DefaultSession.java:176)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:748)
10:42:59.083 WARN - Exception: mouseMoveTo
Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'
System info: host: 'Hershys-MacBook-Pro.local', ip: '2601:8c:4300:98dd:0:0:0:4472', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.12.5', java.version: '1.8.0_131'
Driver info: driver.version: RemoteWebDriver
2017-07-14 10:43:04.026 firefox-bin[49672:18412646] IMKInputSession presentFunctionRowItemTextInputViewWithEndpoint:completionHandler: : [self textInputContext]=0x1243a4e20 *NO* NSRemoteViewController to client, NSError=Error Domain=NSCocoaErrorDomain Code=4097 "connection from pid 0" UserInfo={NSDebugDescription=connection from pid 0}, com.apple.inputmethod.EmojiFunctionRowItem
*************************
A coding exception was thrown and uncaught in a Task.

Full message: TypeError: NetworkError when attempting to fetch resource.
Full stack:
*************************

Behat.yml file details:

default:
  suites:
    default:
      paths:  [ %paths.base%/features ]
      contexts:
        - FeatureContext
        - Drupal\DrupalExtension\Context\DrupalContext
        - Drupal\DrupalExtension\Context\MinkContext
        - Drupal\DrupalExtension\Context\MessageContext
        - Drupal\DrupalExtension\Context\DrushContext
  extensions:
    Cjm\Behat\StepThroughExtension: ~
    Behat\MinkExtension:
      default_session: selenium2
      selenium2:
        wd_host: {base_url}:4444/wd/hub
      base_url: {placed my base url}
    Drupal\DrupalExtension:
      api_driver: 'drupal'
      drush:
        alias: '{placed my drush alias}'
      drupal:
        drupal_root: '{I placed path to my drupal root in here}'
      region_map:
        menu: '#main-menu__list'
      text:
       log_out: "Log out"
       log_in: "Log in"

.Feature file tests:

Feature: Content Management
When I log into the website
As an administrator
I should be able to create, edit, and delete page content

  @api
  Scenario: Create a node
    Given I am on "/user"
    When I fill in the following:
      | edit-name | sampleusername |
      | edit-pass | test |
    And I press the "edit-submit" button
    Given I am viewing a "page" content with the title "Becoming an Upsilon Member"
    Then I should see the heading "Becoming an Upsilon Member"

  @api
  Scenario: Create many nodes
    Given I am logged in as a user with the "administrator" role
    And "page" content:
      | title    |
      | Page one |
      | Page two |
    When I go to "admin/content"
    Then I should see "Page one"
    And I should see "Page two"

Drupal Extension info in composer.lock file:

{
            "name": "drupal/drupal-extension",
            "version": "v3.3.0",
            "source": {
                "type": "git",
                "url": "https://github.com/jhedstrom/drupalextension.git",
                "reference": "8610ab76130ae53b3e7522aff6e1ef61287612f2"
            },
            "dist": {
                "type": "zip",
                "url": "https://api.github.com/repos/jhedstrom/drupalextension/zipball/8610ab76130ae53b3e7522aff6e1ef61287612f2",
                "reference": "8610ab76130ae53b3e7522aff6e1ef61287612f2",
                "shasum": ""
            },
            "require": {
                "behat/behat": "~3.2",
                "behat/mink": "~1.5",
                "behat/mink-extension": "~2.0",
                "behat/mink-goutte-driver": "~1.0",
                "behat/mink-selenium2-driver": "~1.1",
                "drupal/drupal-driver": "~1.2",
                "symfony/dependency-injection": "~2.7|~3.0",
                "symfony/event-dispatcher": "~2.7|~3.0"
            },
            "require-dev": {
                "behat/mink-zombie-driver": "^1.2",
                "phpspec/phpspec": "~2.0",
                "phpunit/phpunit": "3.7.*"
            },
            "type": "behat-extension",
            "extra": {
                "branch-alias": {
                    "dev-master": "3.2.x-dev"
                }
            },
            "autoload": {
                "psr-0": {
                    "Drupal\\Drupal": "src/",
                    "Drupal\\Exception": "src/",
                    "Drupal\\DrupalExtension": "src/"
                }
            },
            "notification-url": "https://packagist.org/downloads/",
            "license": [
                "GPL-2.0+"
            ],
            "authors": [
                {
                    "name": "Jonathan Hedstrom",
                    "email": "jhedstrom@gmail.com"
                }
            ],
            "description": "Drupal extension for Behat",
            "homepage": "http://drupal.org/project/drupalextension",
            "keywords": [
                "drupal",
                "test",
                "web"
            ],
            "time": "2017-06-15T13:59:40+00:00"
        }
hkorik commented 7 years ago

I noticed this issue only occurring for me on a FireFox browser. When running the same test with a chromedriver using a chrome browser the authentication passed.

pfrenssen commented 7 years ago

This is probably not a bug in Drupal Extension, it seems to me that you are hitting https://github.com/mozilla/geckodriver/issues/159 - this was finally implemented in the geckodriver two months ago, maybe you can try updating to the latest dev version of your Selenium / Firefox stack?

See also https://github.com/mozilla/geckodriver/issues/233