Merge pull request #15033 from jasson99/resizeBrowserSizeForTests

Specify window size for tests run
This commit is contained in:
Laurent Destailleur 2020-10-15 20:12:20 +02:00 committed by GitHub
commit 4662402a40
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 12 additions and 11 deletions

View File

@ -18,7 +18,7 @@ module.exports = {
browserName : 'chrome', browserName : 'chrome',
javascriptEnabled : true, javascriptEnabled : true,
chromeOptions : { chromeOptions : {
args : ['disable-gpu'], args : ['disable-gpu', 'window-size=1280,1024'],
w3c : false w3c : false
} }
} }

View File

@ -26,7 +26,8 @@ module.exports = {
}, },
userIsLoggedIn: async function (login) { userIsLoggedIn: async function (login) {
await this.useXpath() await this.waitForElementNotPresent('@loginTable')
.useXpath()
.waitForElementVisible('@userLogin') .waitForElementVisible('@userLogin')
.expect.element('@userLogin') .expect.element('@userLogin')
.text.to.equal(login); .text.to.equal(login);

View File

@ -30,7 +30,7 @@ Before(async function getDolApiKey() {
const params = new URLSearchParams() const params = new URLSearchParams()
params.set('login', adminUsername) params.set('login', adminUsername)
params.set('password', adminPassword) params.set('password', adminPassword)
const apiKey = `http://localhost/dolibarr/htdocs/api/index.php/login?${params.toString()}`; const apiKey = client.globals.backend_url + `api/index.php/login?${params.toString()}`;
header['Accept'] = 'application/json' header['Accept'] = 'application/json'
await fetch(apiKey, { await fetch(apiKey, {
method: 'GET', method: 'GET',

View File

@ -5,12 +5,6 @@ const assert = require('assert');
let response; let response;
let Login = {}; let Login = {};
Given('the administrator has logged in using the webUI', async function () {
await client.page.loginPage().navigate().waitForLoginPage();
await client.page.loginPage().userLogsInWithUsernameAndPassword(client.globals.adminUsername, client.globals.adminPassword);
return client.page.loginPage().userIsLoggedIn(client.globals.adminUsername);
});
Given('the administrator has browsed to the new users page', function () { Given('the administrator has browsed to the new users page', function () {
return client.page.homePage().browsedToNewUserPage(); return client.page.homePage().browsedToNewUserPage();
}); });

View File

@ -1,6 +1,12 @@
const { Given, When, Then } = require('cucumber') const { Given, When, Then } = require('cucumber')
const { client } = require('nightwatch-api') const { client } = require('nightwatch-api')
Given('the administrator has logged in using the webUI', async function () {
await client.page.loginPage().navigate().waitForLoginPage();
await client.page.loginPage().userLogsInWithUsernameAndPassword(client.globals.adminUsername, client.globals.adminPassword);
return client.page.loginPage().userIsLoggedIn(client.globals.adminUsername);
});
Given('the user has browsed to the login page', function () { Given('the user has browsed to the login page', function () {
return client.page.loginPage().navigate(); return client.page.loginPage().navigate();
}); });