Behat / MinkExtension

Mink extension (tight integration and configuration) for Behat
MIT License
636 stars 277 forks source link

fillField failing for good "field" #345

Open crossan007 opened 5 years ago

crossan007 commented 5 years ago

Seeing a weird issue when running ChromeDriver 75, Behat 3.5.0, MinkExtension 2.3.1 on Windows with Selenium

Every call to MinkContext::fillField fails because Behat\Mink\Element::findAll returns null, and I get an ElementNotFoundException.

The referenced field is valid, and works in my CI tests (running older versions of dependencies and via SauceLabs)

I took a look at the generated xPath, and it looked really over-complicated(but might still have been valid).

I don't see anything in the selenium console logs to indicate a failed "find", but I'm not sure it would show there anyway.

Any pointers where to dig deeper?

SirPL commented 5 years ago

I'm facing similar issue which may be related to this one – the $page->getContent() returns valid HTML code, but $page->find('css', 'html') returns null. The same occurs for every other valid tag and id.

crossan007 commented 5 years ago

yes; $page->getContent() does return the DOM

crossan007 commented 5 years ago

I reverted my Chrome browser from Version 75 to Version 74, and also reverted my version of ChromeDriver.exe, and the problem appears to have gone away.

It would appear that something in the upgrade from Chrome 74 to Chrome 75 (or ChromeDriver) causes this issue

crossan007 commented 5 years ago

I seem to get this error on Firefox 68 with GeckoDriver as well.

Still digging in to see if I can figure out the culprit.

crossan007 commented 5 years ago

I think this is documented as in issue in the GeckoDriver repository: https://github.com/mozilla/geckodriver/issues/1581

It's odd that it seems to affect both Chrome and Firefox equally

crossan007 commented 5 years ago

Ah ha. I think I uncovered some more details here.

It looks like, starting with Chrome 75, the selenium mode defaults to w3c, and the MinkSelenium2Driver is considering switching from instaclick/php-webdriver to facebook/php-webdriver, but is holding off because of PHP7 support: https://github.com/minkphp/MinkSelenium2Driver/issues/293#issuecomment-499405228

crossan007 commented 5 years ago

And a solution! (Or at least a temporary workaround):

In the thread above, they suggested turning off W3C mode for chrome.

So, adding that to my behat.yml file, I get this (note the extra_capabilities, chromeOptions, w3c:false)

default:
  suites:
        default:
            contexts:
                - nwcontext:form
                - nwcontext:formstone
                - nwcontext:select2
                - FeatureContext
  extensions:
    Novaway\CommonContexts\Extension: ~
    Behat\MinkExtension:
      base_url: http://localhost/crm
      selenium2:
        browser: chrome
        capabilities:
          browserName: "chrome"
          extra_capabilities:
            chromeOptions:
              w3c: false
crossan007 commented 5 years ago

also related: https://github.com/instaclick/php-webdriver/issues/84