Summary
We have smoke tests that run shortly after deployment on our web application. Sometimes it takes the login page takes a while for its first load.
Error
- Error in Role initializer -
Failed to complete a request to "https://myurl.com/account/login/" within the
timeout period. The problem may be related to local machine's network or firewall settings, server outage, or network problems that make the server inaccessible.
Possible Solutions
I'm hoping that adding a setPageTimeout
in my Roles will solve this issue, however, I can't confirm until Tuesday.
Can anyone confirm if setPageTimeout
is the way to go? If not, is there a solution available?
Example Solution
import { Role } from 'testcafe';
import { config, pageWait } './config/config';
import { loginPage } from '../pages'
const defaultPageTimeout = 5000;
export const orgAdminRole: Role = Role(config.baseUrl, async t => {
await t
.setPageLoadTimeout(pageWait.extraLongPoll)
.typeText(loginPage.userNameInput, config.orgAdminUser)
.typeText(loginPage.passwordInput, config.orgAdminPass)
.click(loginPage.loginButton)
.setPageLoadTimeout(defaultPageTimeout);
}, { preserveUrl: true });
export const userRole: Role = Role(config.baseUrl, async t => {
await t
.setPageLoadTimeout(pageWait.extraLongPoll)
.typeText(loginPage.userNameInput, config.user)
.typeText(loginPage.passwordInput, config.userPass)
.click(loginPage.loginButton)
.setPageLoadTimeout(defaultPageTimeout);
}, { preserveUrl: true });