sensiolabs / BehatPageObjectExtension

MIT License
117 stars 48 forks source link

Cannot autowire service ... "$factory" of method "SensioLabs\Behat\PageObjectExtension\PageObject\Page::__construct()" references interface "Sensi oLabs\Behat\PageObjectExtension\PageObject\Factory" #144

Open hopeseekr opened 2 years ago

hopeseekr commented 2 years ago

I am seriously stumped!

Cannot autowire service "Emitter\Page\Admin\Login": argument "$factory" of method "SensioLabs\Behat\PageObjectExtension\PageObject\Page::__construct()" references interface "Sensi
oLabs\Behat\PageObjectExtension\PageObject\Factory" but no such service exists. Did you create a class that implements this interface?

The application has worked fine for years. I have upgraded it from Symfony 4 to 5 and now, with Symfony 6, I am hitting this error.

There is nothing online about it. Please help.

jakzal commented 2 years ago

It seems that Symfony's container tries to register your page objects as a service. That would mean they're located in a directory that's autowired. Have you tried excluding the directory with page objects?

For example, if they're in src/Page:

services:
    App\:
        resource: '../src/*'
        exclude: '../src/{Page,DependencyInjection,Entity,Tests,Kernel.php}'