CodeceptJS
CodeceptJS copied to clipboard
userDataDir and locale config options show error this.browser.contexts is not a function (Playwright)
What are you trying to achieve?
Change default browser language. For that, I set config options userDataDir and locale in codecept.conf.js
What do you get instead?
It works and changes the browser language correctly (Chrome 90.0.4430.0 and Firefox 87.0), but after finishing the execution of the tests (at the moment the browser is closed), a CodeceptJS internal error is showed in the console (although all test pass successfully):
Provide console output if related. Use
--verbose
mode for more details.
[Browser:Error] JSHandle@cannot get token JSHandle@error= JSHandle@error
[1] Retrying... Attempt #3
✔ OK in 30147ms
TypeError: this.browser.contexts is not a function
at Playwright._after (/node_modules/codeceptjs/lib/helper/Playwright.js:337:43)
at /node_modules/codeceptjs/lib/listener/helpers.js:26:69
› [Session] cleaning cookies and localStorage
Provide test source code if related
import { UserType } from './user-type'
Feature('Login and Logout').retry(3)
Scenario(
'Login, Verify GoToContent is Visible, Logout and Verify Landing Page is Displayed',
async ({ I, LoginComponent }) => {
const user = await I.getUser(UserType.gotoAppUserWithoutAvatar)
LoginComponent.login(user)
LoginComponent.acceptTos()
LoginComponent.verifyGoToContentVisible()
LoginComponent.logout()
LoginComponent.verifyLandingPageDisplayed()
},
)
Details
- CodeceptJS version: 3.0.6
- NodeJS Version: v12.19.0
- Operating System: macOS BigSur 11.2.3
- Playwright version: 1.10.0
- Configuration file:
const { DEFAULT_HOST, USER_DATA_PATH } = require('./host.config')
const { setHeadlessWhen } = require('@codeceptjs/configure')
setHeadlessWhen(process.env.baseUrl)
require('ts-node/register')
exports.config = {
tests: './*.e2e-spec.ts',
output: './output',
helpers: {
Playwright: {
url: process.env.baseUrl || DEFAULT_HOST,
show: true,
browser: 'chromium',
waitForAction: 250,
waitForNavigation: 'networkidle0',
chromium: {
userDataDir: `${USER_DATA_PATH}${process.env.BROWSER}`,
channel: process.env.BROWSER,
locale: 'fr-CA',
},
firefox: {
userDataDir: `${USER_DATA_PATH}firefox`,
locale: 'fr-CA',
},
},
LoginHelper: {
require: './login-helper.ts',
},
BrowserHelper: {
require: './browser-helper.ts',
},
},
include: {
I: './steps-file.ts',
LoginComponent: './login-component.ts',
},
bootstrap: null,
mocha: {},
multiple: {
parallel: {
browsers: ['chromium', 'firefox'],
},
},
name: 'e2e',
plugins: {
pauseOnFail: {},
retryFailedStep: {
enabled: true,
retries: 6,
},
tryTo: {
enabled: true,
},
screenshotOnFail: {
enabled: false,
},
},
}
Any resolution to this , I am also facing this issue...
Did anyone find a solution for this? I am facing the same issue.
I am still seeing this issue with codeceptjs 3.5.3.