[4.x]: Codeception Acceptance testing - Javascript must be enabled to access control panel
What happened?
I've been trying to get Acceptance testing working with Codeception v5.1.2.
I followed the setup guide: https://craftcms.com/docs/4.x/testing/testing-craft/setup.html
Then got past various issues:
- Output path is not defined by key "paths: output"
- # Added "paths: output: tests/_output" in Codeception.yml
- PHP Fatal error: Uncaught Error: Class "Codeception\Module\Yii2" not found
- # composer require codeception/module-yii2 --dev
- Suite 'unit' could not be found
- # Unit should be capitalised
- No primary site exists
- # Set dbSetup:clean and dbSetup:setupCraft to false in Codeception.yml and use a copy of the production db
But I'm stuck now on a basic Acceptance test for the control panel login page.
In my test class, I have:
public function loginpageWorks(AcceptanceTester $I)
{
$I->amOnPage('/admin/login');
$I->see('Forgot your password?');
}
And output says "JavaScript must be enabled to access the Craft CMS control panel":
1) FirstCest: Loginpage works
Test tests/Acceptance/FirstCest.php:loginpageWorks
Step See "Forgot your password?"
Fail Failed asserting that on page /admin/login
--> Sign In - MyCraftCMS body:not(.userlevel-admin) #nav-assets { display: none !important; } #nav-dashboard {display: none !important;} JavaScript must be enabled to access the Craft CMS control panel.
--> contains "Forgot your password?".
How can I get JS to run?
Craft CMS version
4.10.7
PHP version
8.1.29
Operating system and version
Linux 5.15.133.1-microsoft-standard-WSL2
Database type and version
MySQL 8.0.36
Image driver and version
No response
Installed plugins and versions
No response
I tried briefly adding WebDriver as an enabled module in Acceptance.suite.yml but that gave the following error:
Codeception PHP Testing Framework v5.1.2 https://stand-with-ukraine.pp.ua
In ModuleContainer.php line 486:
craft\test\Craft module conflicts with WebDriver
--
This usually happens when you enable two modules with the same actions but with different backends.
For instance, you can't run PhpBrowser, WebDriver, Laravel5 modules in one suite,
as they implement similar methods but use different drivers to execute them.
You can load a part of module (like: ORM) to avoid conflict.
Hi @brandonkelly and @angrybrad ,
Adding the craft and webdriver module is giving me the same error:
Setup:
actor: AcceptanceTester
modules:
enabled:
- \craft\test\Craft
- WebDriver:
url: http://website.test
browser: chrome
capabilities:
goog:chromeOptions:
args: [ "--headless" ]
Error:
Codeception PHP Testing Framework v5.1.2 https://stand-with-ukraine.pp.ua
In ModuleContainer.php line 486:
craft\test\Craft module conflicts with WebDriver
--
This usually happens when you enable two modules with the same actions but with different backends.
For instance, you can't run PhpBrowser, WebDriver, Laravel5 modules in one suite,
as they implement similar methods but use different drivers to execute them.
You can load a part of module (like: ORM) to avoid conflict.
Any updates on this?