Unable to find page elements with Behat / Mink using Selenium 3.5.x

1.3k Views Asked by At

I am working on setting up behavioral tests for our current website. I have used Behat in the past with Selenium standalone server and now have updated to the latest Behat 3 and Selenium 3.5. I am having a multitude of issues though. Using Selenium 3.5 I cannot get xpath selectors to work at all. It is not able to find elements by id, name, class etc. With Selenium 3.4.x it seems to work fine but I cannot get button presses to work. I receive this error:

Then I click button "loginBtn"                                                              # FeatureContext::iClickButton()
  mouseMoveTo
  Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'
  System info: host: 'matt-VirtualBox', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.0-59-generic', java.version: '1.8.0_131'
  Driver info: driver.version: RemoteWebDriver (WebDriver\Exception\UnknownCommand)

This seems to be something that was fixed in 3.5.x with enablePassThrough set to true. Here is my behat.yml configuration.

default:
suites:
    default:
        contexts:
            - FeatureContext:
                screenshots_path: '%paths.base%/screenshots/firefox/'
extensions:
    Behat\MinkExtension:
        base_url:  'http://localhost:8080/customer_portal/'
        default_session: selenium2
        browser_name: 'firefox'
        selenium2:
            browser: 'firefox'
            capabilities:
                browserName: 'firefox'
                browser: 'firefox'
                version: ''
            wd_host: 'localhost:5555/wd/hub'

And inside of my composer.json file

{
"require": {
    "behat/behat": "3.*@stable",
    "behat/mink": "1.7.*@stable",
    "behat/mink-selenium2-driver": "@stable",
    "behat/mink-goutte-driver": "@stable",
    "behat/mink-extension": "@stable",
        "phpmd/phpmd" : "@stable"
},
"config": {
    "bin-dir": "bin/"
}

}

I am using Firefox 55 and geckodriver v18. Has anyone successfully configured selenium to work with Behat 3 and Firefox?

2

There are 2 best solutions below

1
On

It seems to be an issue from Selenium. I also have the issue when working with FF and could not get the Element clicked.

7
On

mouseMoveTo error is well known issue when using selenium3. This error happens only for firefox browser with gecko driver. To fix this issue you can use chrome or update the MinkSelenium2Driver library. Should be master branch of MinkSelenium2Driver which requires behat/mink: ~1.7@dev. Here is the point of the problem MinkSelenium2Driver So if its ok for you to use all the latest behat versions, then composer.json could looks like this:

"require": {
    "behat/behat": "v3.3.1",
    "behat/mink": "v1.7.1",
    "behat/mink-extension": "v2.2",
    "behat/mink-selenium2-driver": "dev-master",
}