Mink / behat javascript error not found element for simple scenario

can you help me please?

I have a problem for simple scenario gerkins that don’t find fields with error

Form field with id|name|label|value|placeholder “searchform-search” not found. (BehatMinkExceptionElementNotFoundException)

but selecium launches chrome correctly.
I use mink/behat symfony, selecium, chrome-driver.

For example my scenario i use https://hotexamples.com/.

behat.yml

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

extensions:
    BehatSymfony2Extension:
        kernel:
            bootstrap: tests/api/bootstrap/bootstrap.php
            class: AppKernel
    BehatMinkExtension:
        base_url: https://hotexamples.com
        goutte: ~
        selenium2: ~
        browser_name: chrome

suites:
    default:
        contexts:
            - ContextFeatureContext:
                kernel: '@kernel'
        paths: [ "%paths.base%/tests/api", "%paths.base%/tests/behat"]

FeatureContext:

  <?php

declare(strict_types=1);

namespace Context;

use BehatBehatContextContext;
use BehatBehatContextSnippetAcceptingContext;
use BehatMinkExtensionContextMinkContext;
use SymfonyComponentHttpFoundationRequest;
use SymfonyComponentHttpFoundationResponse;
use SymfonyComponentHttpKernelKernelInterface;

/**
 * This context class contains the definitions of the steps used by the demo
 * feature file. Learn how to get started with Behat and BDD on Behat's website.
 *
 * @see http://behat.org/en/latest/quick_start.html
 */
class FeatureContext extends MinkContext implements Context, SnippetAcceptingContext
{
    /**
     * @var KernelInterface
     */
    private $kernel;

    /**
     * @var Response|null
     */
    private $response;

    public function __construct(KernelInterface $kernel)
    {
        $this->kernel = $kernel;
    }

     /**
     * @Given I wait for the page to be loaded
     */
    public function iWaitForThePageToBeLoaded()
    {
        $this->getSession()->wait(5000, "document.readyState === 'complete'");
    }


    /**
     * @Given I wait :time seconds
     */
    public function iWaitSeconds(int $time)
    {
        sleep($time);
    }

}

Scenario:

  Feature: TestBehat

  @javascript @api
  Scenario: Search
    Given I am on the homepage
    When I fill in "searchform-search" with "behat"

composer.json

"require-dev": {
    "behat/behat": "^3.5",
    "behat/mink": "[email protected]",
    "behat/mink-browserkit-driver": "^1.3",
    "behat/mink-extension": "^2.3",
    "behat/mink-goutte-driver": "^1.2",
    "behat/mink-selenium2-driver": "^1.3",
    "behat/symfony2-extension": "^2.1",
    "behatch/contexts": "^3.2",
    "doctrine/instantiator": "^1.3",
    "hautelook/alice-bundle": "^2.5",
    "nikic/php-parser": "^4.3",
    "phpstan/phpstan": "^0.12.3",
    "phpunit/phpunit": "^8.5",
    "symfony/maker-bundle": "^1.11",
    "symfony/var-dumper": "4.2.*"
}

And output of console

   vendor/bin/behat 
Feature: TestBehat

  @javascript @api
  Scenario: Search                                  # tests/behat/authentication.feature:4
12:09:24.452 INFO [ActiveSessionFactory.apply] - Capabilities are: {
  "browser": "firefox",
  "browserName": "chrome",
  "ignoreZoomSetting": false,
  "name": "Behat feature suite",
  "tags": [
    "debian",
    "PHP 7.3.12-1+0~20191128.49+debian9~1.gbp24559b"
  ]
}
12:09:24.453 INFO [ActiveSessionFactory.lambda$apply$11] - Matched factory org.openqa.selenium.grid.session.remote.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService)
Starting ChromeDriver 79.0.3945.36 (3582db32b33893869b8c1339e8f4d9ed1816f143-refs/branch-heads/[email protected]{#614}) on port 31246
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
12:09:24.796 INFO [ProtocolHandshake.createSession] - Detected dialect: W3C
12:09:24.797 INFO [RemoteSession$Factory.lambda$performHandshake$0] - Started new session db80a68bb2beb001693480d14ffa7b1f (org.openqa.selenium.chrome.ChromeDriverService)
    Given I am on the homepage                      # ContextFeatureContext::iAmOnHomepage()
    When I fill in "searchform-search" with "behat" # ContextFeatureContext::fillField()
      Form field with id|name|label|value|placeholder "searchform-search" not found. (BehatMinkExceptionElementNotFoundException)

--- Scénarios échoués:

    tests/behat/authentication.feature:4

1 scénario (1 échecs)
2 étapes (1 succès, 1 échecs)
0m2.11s (19.49Mb)
12:09:26.573 INFO [ActiveSessions$1.onStop] - Removing session db80a68bb2beb001693480d14ffa7b1f (org.openqa.selenium.chrome.ChromeDriverService)

Thanks

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *