Behat / MinkExtension

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

Does not correctly fill in form fields #286

Open nietzscheson opened 7 years ago

nietzscheson commented 7 years ago

I have a form, with two fields. Username and password. I did some tests with the admin | admin, for each field. If I change the value admin by administrator (or any other value other than admin) the fields are not filled. There are so many things involved that I do not know what is failing. I’m using everything in Homestead, PHP7. Behat, Mink, Selenium2. Quartz.

behat-720

#composer.json

        "behat/mink": "^1.7",
        "behat/mink-extension": "^2.2",
        "behat/mink-browserkit-driver": "^1.3",
        "behat/mink-selenium2-driver": "^1.3",
        "behat/behat": "3.3.1",
        "behat/symfony2-extension": "^2.1@dev"
Feature: Login

  @javascript
  Scenario: Login
    Given I am on the homepage
    When I fill in "_username" with "administrador"
    And I fill in "_password" with "administrador"
    When I press "_submit"

default:
    formatters:
        pretty:
            verbose: true
            paths: false
            snippets: false

    extensions:
        Behat\Symfony2Extension: ~
        Behat\MinkExtension:
            base_url: "http://beauty.app/app_test.php/"
            default_session: symfony
            javascript_session: chrome
            sessions:
                symfony:
                    symfony2: ~
                chrome:
                    selenium2:
                        browser: chrome
                        capabilities:
                            browserName: chrome
                            browser: chrome
                            version: ""
                            chrome:
                                switches:
                                    - "start-fullscreen"
                                    - "start-maximized"
                                    - "no-sandbox"
                firefox:
                    selenium2:
                        browser: firefox
            show_auto: false
default:
    suites:
        default:
            contexts:
                - DefaultContext
<?php

use Behat\MinkExtension\Context\MinkContext;

class DefaultContext extends MinkContext
{
}
PatchRanger commented 7 years ago

@nietzscheson Your gif reproducing the bug is amazing!

I have the same problem with PhantomJS browser: it just skips filling a single form field - everytime skipped field is the same. I've applied a workaround: just doubled the filling command for this concrete field - it is very ugly, so I need this bug to be fixed.

pfleu commented 6 years ago

Same problem with this config, very annoying: "behat/behat": "^3.0", "behat/mink-extension": "^2.1", "behat/mink-goutte-driver": "^1.2", "behat/mink-selenium2-driver": "^1.3", "behat/symfony2-extension": "^2.1", "se/selenium-server-standalone": "2.45.0",

Using Chrome Driver 2.36.540470 extensions: Behat\Symfony2Extension: ~ Behat\MinkExtension: base_url: http://127.0.0.1/myurl browser_name: chrome selenium2: capabilities: chrome: switches:

dleute commented 6 years ago

I am having a possibly related problem:

Anytime I fill a field and the following step is something like "push a button" the focus is removed from the field before the full text is inserted into the field.

For example, If I have the fields username and password and something like this:

And I fill in "username" with "derrek"
And I fill in "password" with "password"
And I press "Login"

The password field will actually get filled in with something like "pass" or "passw" or "passwor".

I end up having to add a wait step:

And I fill in "username" with "derrek"
And I fill in "password" with "password"
And I press "Login"
And I wait "1" second

This usually solves the issue. Once in a while, 1 second isn't enough time.

I have also written my own definitions to solve this by finding the field myself and using setValue, but the effect is the same. I have even written "waitFor" loops that check that the getText() of the field is what I set it to, it says it is and it is still a truncated version of it when save is pushed. Same problem running chrome through selenium, chromedriver headless or not.

I would love to write something that could detect and wait for the entry to be finished, but I am at a loss as to how. Could this be solved with wait and javascript?

All these fields are angular material based. I haven't tried reproducing this with "normal" fields.

I also discovered that the test failures are directly linked to how busy the CPU is on my system. Many more field entries needed waits after them when my processor was overloaded.

Thoughts? Comments? Could it be related?

leymannx commented 6 years ago

Refs #307