Heikki Hannula
Heikki Hannula

Reputation: 101

Codeception autoload: 'WebDriver' is not defined

I have a Symfony2 project, but I cannot get WebDriver configured properly. I have installed facebook webdriver and codeception with composer:

facebook/webdriver: versions : * 1.1.3

codeception/codeception: versions : * 2.2.5

I followed these instructions (and when autoload failed, many other sources without success): http://codeception.com/11-20-2013/webdriver-tests-with-codeception.html

codeception.yml in project root:

actor: Tester
paths:
    tests: tests
    log: tests/_output
    data: tests/_data
    support: tests/_support
    envs: tests/_envs
settings:
    bootstrap: _bootstrap.php
    colors: true
    memory_limit: 1024M
extensions:
    enabled:
        - Codeception\Extension\RunFailed
        - WebDriver
    config:
        WebDriver:
            url: 'http://localhost/'
            browser: firefox
            port: 4444
modules:
    config:
        Db:
            dsn: ''
            user: ''
            password: ''
            dump: tests/_data/dump.sql

I have acceptance tests generated, and when I run codeception, following error occurs:

[Codeception\Exception\ConfigurationException]
Class `WebDriver` is not defined. Autoload it or include into '_bootstrap.php' file of 'tests' directory

I've tried adding this into tests/_bootstrap.php: require_once __DIR__.'/../vendor/codeception/codeception/src/Codeception/Module/WebDriver.php';

The path above is correct, the php file is found, but the problem persist. Exactly how the autoloading or bootstrap including should be done?

EDIT: I made the WebDriver enabling and configuration into tests/acceptance.suite.yml instead of root folder codeception.yml, and got over the problem.

Remains unclear why this happens?

Upvotes: 0

Views: 1301

Answers (1)

Naktibalda
Naktibalda

Reputation: 14110

WebDriver is not an extension, but a module.

You have to enable it in the modules section of acceptance.suite.yml file.

modules:
    enabled:
      - WebDriver
      - \Helper\Acceptance

https://github.com/Codeception/Codeception/blob/2.2/tests/web.suite.yml

Upvotes: 2

Related Questions