Behat / MinkExtension

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

ElementNotFoundException when i use javascript for step "I fill with" #357

Closed kevin-schmitt closed 4 years ago

kevin-schmitt commented 4 years ago

Hello and thanks for this project,

I use mink with symfony 4.4, debian, selenium and chromedriver.

The problem is when i use step "I fill in with" I have always exception ElementNotFoundException with all host. Form field with id|name|label|value|placeholder "searchform-search" not found. (Behat\Mink\Exception\ElementNotFoundException Example:

` Feature: TestBehat

  @javascript @api
  Scenario: Search
    Given I am on "https://hotexamples.com"
    And I wait 20 seconds
    When I fill in "searchform-search" with "behat"`

output console:

`vendor/bin/behat
Feature: TestBehat

  @javascript @api
  Scenario: Search                                  # tests/behat/authentication.feature:4
    Given I am on "https://hotexamples.com"         # Context\FeatureContext::visit()
    And I wait 20 seconds                           # Context\FeatureContext::iWaitSeconds()
    When I fill in "searchform-search" with "behat" # Context\FeatureContext::fillField()
      Form field with id|name|label|value|placeholder "searchform-search" not found. (Behat\Mink\Exception\ElementNotFoundException)

--- Scénarios échoués:

    tests/behat/authentication.feature:4

1 scénario (1 échecs)
3 étapes (2 succès, 1 éch`

If you test go to hotExample website you have field search with id searchform-search but same i try with other host and not id but name i have the same exception, mink don't find it :(.

Can you help me please?

Edit:

Problem solved, i has add option configuration for chrome in behat file `

default:

autoload:
    - "%paths.base%/tests/api/bootstrap"

calls:
    error_reporting: 16383 # E_ALL & ~E_USER_DREPRECATED

extensions:
    Behat\Symfony2Extension:
        kernel:
            bootstrap: tests/api/bootstrap/bootstrap.php
            class: App\Kernel
    Behat\MinkExtension:
        browser_name: chrome
        base_url: 'http://127.0.0.1:8080/'
        goutte: ~
        selenium2: ~
        sessions:
            default:
              selenium2:
                capabilities:
                  extra_capabilities:
                    chromeOptions:
                      args:
                        - "--disable-gpu"
                        - "--window-size=1920,1080"
                      w3c: false

suites:
    default:
        contexts:
            - Context\FeatureContext:
                kernel: '@kernel'
        paths: [ "%paths.base%/tests/api", "%paths.base%/tests/behat"]`
igronus commented 1 year ago

Only works if all three of w3c, disable-gpu and window-size are provied. Don't understand why.