Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"parsed-url": "0.0.0",
"q": "1.4",
"req": "0.1",
"rgb-hex": "^2.1.0",
"should": "13.1.0",
"webdriverio": "4.0",
"window": "4.2.0"
Expand Down
70 changes: 70 additions & 0 deletions test/campaigns/cookieBanner/1-Check_cookie_banner_position.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
scenario('Check the cookie banner in front office', client => {
scenario('Test case 1 : Check the cookie banner in the bottom of front office', () => {
test('should open the browser', () => client.open());
test('should access to front office', () => client.accessToFrontOffice());
test('should check the cookie banner on the bottom', () => client.checkPositionBanner('bottom'));
}, "cookie-banner/cookieBanner-client", true);
scenario('Test case 2 : Check the cookie banner in the top of front office', client => {
scenario('Log in in Back Office', client => {
test('should open the browser', () => client.open());
test('should log in successfully in BO', () => client.signInBO());
}, "cookie-banner/cookieBanner-client");
scenario('Configure the cookie banner in the top', client => {
test('should access to module page', () => client.goToModulePage());
test('should search the module page', () => client.searchModule("pscookiebanner"));
test('should go to the module configuration page', () => client.clickOnConfigureButton());
test('should switch the position of banner in the top', () => client.positionBanner("top"));
test('should click on save button', () => client.clickOnSaveButton());
}, "cookie-banner/cookieBanner-client");
scenario('Logout from Back Office', client => {
test('should logout', () => client.signOutBO());
}, "cookie-banner/cookieBanner-client", true);
scenario('Check the cookie banner in the top of front office', () => {
test('should open the browser', () => client.open());
test('should access to front office', () => client.accessToFrontOffice());
test('should check the cookie banner on the bottom', () => client.checkPositionBanner('fixedtop'));
}, "cookie-banner/cookieBanner-client");
}, "cookie-banner/cookieBanner-client", true);
scenario('Test case 3 : Check the cookie banner in the bottom right of front office', client => {
scenario('Log in in Back Office', client => {
test('should open the browser', () => client.open());
test('should log in successfully in BO', () => client.signInBO());
}, "cookie-banner/cookieBanner-client");
scenario('Configure the cookie banner in the bottom right', client => {
test('should access to module page', () => client.goToModulePage());
test('should search the module page', () => client.searchModule("pscookiebanner"));
test('should go to the module configuration page', () => client.clickOnConfigureButton());
test('should switch the position of the banner in bottom right', () => client.positionBanner("bottomright"));
test('should click on save button', () => client.clickOnSaveButton());
}, "cookie-banner/cookieBanner-client");
scenario('Logout from Back Office', client => {
test('should logout', () => client.signOutBO());
}, "cookie-banner/cookieBanner-client", true);
scenario('Check the cookie banner in the bottom right of front office', () => {
test('should open the browser', () => client.open());
test('should access to front office', () => client.accessToFrontOffice());
test('should check the cookie banner in the bottom right', () => client.checkPositionBanner('bottomright'));
}, "cookie-banner/cookieBanner-client");
}, "cookie-banner/cookieBanner-client", true);
scenario('Test case 4 : Check the cookie banner in the bottom left of front office', client => {
scenario('Log in in Back Office', client => {
test('should open the browser', () => client.open());
test('should log in successfully in BO', () => client.signInBO());
}, "cookie-banner/cookieBanner-client");
scenario('Configure the cookie banner in the bottom left', client => {
test('should access to module page', () => client.goToModulePage());
test('should search the module page', () => client.searchModule("pscookiebanner"));
test('should go to the module configuration page', () => client.clickOnConfigureButton());
test('should switch the position of banner in the bottom left', () => client.positionBanner("bottomleft"));
test('should click on save button', () => client.clickOnSaveButton());
}, "cookie-banner/cookieBanner-client");
scenario('Logout from Back Office', client => {
test('should logout', () => client.signOutBO());
}, "cookie-banner/cookieBanner-client", true);
scenario('Check the cookie banner in the top of front office', () => {
test('should open the browser', () => client.open());
test('should access to front office', () => client.accessToFrontOffice());
test('should check the cookie banner in the bottom left', () => client.checkPositionBanner('bottomleft'));
}, "cookie-banner/cookieBanner-client");
}, "cookie-banner/cookieBanner-client", true);
}, "cookie-banner/cookieBanner-client", true);
32 changes: 32 additions & 0 deletions test/campaigns/cookieBanner/2-Edit_and_check_configuration.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
scenario('Edit and check configuration of cookie banner', client => {
scenario('Log in in Back Office', client => {
test('should open the browser', () => client.open());
test('should log in successfully in BO', () => client.signInBO());
}, "cookie-banner/cookieBanner-client");
scenario('Configure the cookie banner', client => {
test('should access to module page', () => client.goToModulePage());
test('should search the module page', () => client.searchModule("pscookiebanner"));
test('should go to the module configuration page', () => client.clickOnConfigureButton());
test('should switch the position of banner in the bottom', () => client.positionBanner());
test('should edit the background color', () => client.editBackgroundColor("#ff0000"));
test('should edit the text', () => client.editText());
test('should edit the text color', () => client.editTextColor("#0000ff"));
test('should edit the text for "Learn more"', () => client.editLearnMoreText());
test('should select CMS page for "Learn more"', () => client.selectCmsPage());
test('should edit the text button', () => client.editTextButton("Agree"));
test('should edit the background button color', () => client.editBackgroundButtonColor("#8b8b8b"));
test('should edit on mouse over color', () => client.editOnMouseOverColor("#ff4cc3"));
test('should edit the text button color', () => client.editTextButtonColor("#ffd550"));
test('should click on save button', () => client.clickOnSaveButton());
}, "cookie-banner/cookieBanner-client");
scenario('Logout from Back Office', client => {
test('should logout', () => client.signOutBO());
}, "cookie-banner/cookieBanner-client", true);
scenario('Check the configuration of cookie banner in the front office', () => {
test('should open the browser', () => client.open());
test('should access to front office', () => client.accessToFrontOffice());
test('should check the cookie banner', () => client.checkBanner());
test('should click on view cookies', () => client.clickOnViewCookiesLink());
test('should conditions of use page is shown', () => client.waitForConditionsPage());
}, "cookie-banner/cookieBanner-client");
}, "cookie-banner/cookieBanner-client", true);
231 changes: 231 additions & 0 deletions test/clients/cookie-banner/cookieBanner-client.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,231 @@
var {getClient} = require('../../common.webdriverio');
var {selector} = require('../../globals.webdriverio.js');
const rgbHex = require('rgb-hex');

class CookieBanner {
constructor() {
this.client = getClient();
}

signInBO() {
return this.client.signinBO();
}

signOutBO() {
return this.client.signoutBO();
}

accessToFrontOffice() {
return this.client
.url(`https://${URL}/`)
.waitForExist(selector.FO.AccessPage.logo_home_page, 90000)
.pause(3000)
}

close() {
return this.client.end();
};

open() {
return this.client.init().windowHandleSize({width: 1280, height: 1024});
}

checkPositionBanner(position){
return this.client
.waitForExist(selector.FO.CookieBanner.configuration_banner, 90000)
.then(() => this.client.getAttribute(selector.FO.CookieBanner.configuration_banner, 'class'))
.then((classElement) => {
var checkPosition = classElement.split('eupopup-container eupopup-container-').pop().split(' eupopup-color-default').shift();
expect(checkPosition).to.eql(position);
})
.pause(5000);
}

goToModulePage() {
return this.client
.waitForExist(selector.BO.ModulesPage.modules_subtab, 90000)
.click(selector.BO.ModulesPage.modules_subtab)
.pause(5000);
}

clickOnConfigureButton() {
return this.client
.click(selector.BO.ModulesPage.actions_module_dropdown)
.click(selector.BO.ModulesPage.configure_module_button)
.pause(5000);
}

searchModule(name) {
return this.client
.waitForExist(selector.BO.ModulesPage.search_input, 60000)
.setValue(selector.BO.ModulesPage.search_input, name)
.click(selector.BO.ModulesPage.search_button)
.pause(5000);
}

clickOnSearchButton() {
return this.client
.pause(3000)
.waitForExist(selector.BO.CustomersPage.customer_search_button, 90000)
.click(selector.BO.CustomersPage.customer_search_button)
}

positionBanner(position) {
switch (position){
case "top": {
return this.client
.pause(3000)
.waitForExist(selector.BO.ModulePageCookieBanner.banner_position_top, 90000)
.click(selector.BO.ModulePageCookieBanner.banner_position_top);
}
case "bottomright": {
return this.client
.pause(3000)
.waitForExist(selector.BO.ModulePageCookieBanner.banner_position_bottomright, 90000)
.click(selector.BO.ModulePageCookieBanner.banner_position_bottomright);
}
case "bottomleft": {
return this.client
.pause(3000)
.waitForExist(selector.BO.ModulePageCookieBanner.banner_position_bottomleft, 90000)
.click(selector.BO.ModulePageCookieBanner.banner_position_bottomleft);
}
default: {
return this.client
.pause(3000)
.waitForExist(selector.BO.ModulePageCookieBanner.banner_position_bottom, 90000)
.click(selector.BO.ModulePageCookieBanner.banner_position_bottom);
}
}
}

editBackgroundColor(color) {
return this.client
.waitForExist(selector.BO.ModulePageCookieBanner.background_color_input, 90000)
.setValue(selector.BO.ModulePageCookieBanner.background_color_input, color);
}

editText() {
return this.client
.waitForExist(selector.BO.ModulePageCookieBanner.text_textarea, 90000)
.setValue(selector.BO.ModulePageCookieBanner.text_textarea, "This site uses cookies. Using your site means your agree to our use of cookies. We have published a new cookies policy, which you should need to find out more about the cookies we use.");
}

editTextColor(color) {
return this.client
.waitForExist(selector.BO.ModulePageCookieBanner.color_text_input, 90000)
.setValue(selector.BO.ModulePageCookieBanner.color_text_input, color);
}

editLearnMoreText() {
return this.client
.waitForExist(selector.BO.ModulePageCookieBanner.text_learn_more_input, 90000)
.setValue(selector.BO.ModulePageCookieBanner.text_learn_more_input, "View cookies.");
}

clickOnSaveButton() {
return this.client
.pause(3000)
.waitForExist(selector.BO.ModulePageCookieBanner.save_button, 90000)
.click(selector.BO.ModulePageCookieBanner.save_button);
}

selectCmsPage() {
return this.client
.waitForExist(selector.BO.ModulePageCookieBanner.cms_page_select, 90000)
.selectByValue(selector.BO.ModulePageCookieBanner.cms_page_select, 3);
}

editTextButton(text_button) {
return this.client
.waitForExist(selector.BO.ModulePageCookieBanner.accept_button_text_input, 90000)
.setValue(selector.BO.ModulePageCookieBanner.accept_button_text_input, text_button);
}

editBackgroundButtonColor(color) {
return this.client
.waitForExist(selector.BO.ModulePageCookieBanner.background_button_color_input, 90000)
.setValue(selector.BO.ModulePageCookieBanner.background_button_color_input, color);
}

editOnMouseOverColor(color) {
return this.client
.waitForExist(selector.BO.ModulePageCookieBanner.on_mouse_over_input, 90000)
.setValue(selector.BO.ModulePageCookieBanner.on_mouse_over_input, color);
}

editTextButtonColor(color) {
return this.client
.waitForExist(selector.BO.ModulePageCookieBanner.button_text_color_input, 90000)
.setValue(selector.BO.ModulePageCookieBanner.button_text_color_input, color);
}

clickOnViewCookiesLink() {
return this.client
.waitForExist(selector.FO.CookieBanner.configuration_banner_body_link, 90000)
.click(selector.FO.CookieBanner.configuration_banner_body_link)
.then(() => this.client.getTabIds())
.then(ids => this.client.switchTab(ids[1]))
}

waitForConditionsPage() {
return this.client
.waitForExist(selector.FO.CookieBanner.page_title, 90000)
.then(() => this.client.getTabIds())
.then(ids => this.client.switchTab(ids[0]))
}

checkBanner() {
return this.client
//check background color
.waitForExist(selector.FO.CookieBanner.configuration_banner, 90000)
.then(() => this.client.getAttribute(selector.FO.CookieBanner.configuration_banner, 'style'))
.then((style) => {
var checkColor = '#'+(rgbHex(style.split('background-color: ').pop().split('; display: block;').shift())).substr(0,6);
expect(checkColor).to.eql("#ff0000");
})
//check text color
.waitForExist(selector.FO.CookieBanner.configuration_banner_body, 90000)
.then(() => this.client.getAttribute(selector.FO.CookieBanner.configuration_banner_body, 'style'))
.then((style) => {
var checkColor = '#'+(rgbHex(style.split('color: ').pop().split('; font-size').shift())).substr(0,6);
expect(checkColor).to.eql("#0000ff");
})
//check text link
.moveToObject(selector.FO.CookieBanner.configuration_banner_body_link, 90000)
.then(() => this.client.getText(selector.FO.CookieBanner.configuration_banner_body_link))
.then((text) => {expect(text).to.eql("View cookies.")})
//check text button
.waitForExist(selector.FO.CookieBanner.configuration_banner_body_button, 90000)
.then(() => this.client.getText(selector.FO.CookieBanner.configuration_banner_body_button))
.then((text) => {expect(text).to.eql("Agree")})
//check background button color
.waitForExist(selector.FO.CookieBanner.configuration_banner_body_button, 90000)
.then(() => this.client.getAttribute(selector.FO.CookieBanner.configuration_banner_body_button, 'style'))
.then((style) => {
var checkColor = '#'+(rgbHex(style.split('background-color: ').pop().split('; border').shift())).substr(0,6);
expect(checkColor).to.eql("#8b8b8b");
})
//check on mouse over button color
.moveToObject(selector.FO.CookieBanner.configuration_banner_body_button, 90000)
.then(() => this.client.getAttribute(selector.FO.CookieBanner.configuration_banner_body_button, 'style'))
.then((style) => {
var checkColor = '#'+(rgbHex(style.split('background-color: ').pop().split('; border').shift())).substr(0,6);
expect(checkColor).to.eql("#ff4cc3");
})
//check text button color
.waitForExist(selector.FO.CookieBanner.configuration_banner_body_button, 90000)
.then(() => this.client.getAttribute(selector.FO.CookieBanner.configuration_banner_body_button, 'style'))
.then((style) => {
var checkColor = '#'+(rgbHex(style.split('color: ').pop().split('; font-size').shift())).substr(0,6);
expect(checkColor).to.eql("#ffd550");
})
}

takeScreenshot() {
return this.client.saveScreenshot(`test/screenshots/${this.client.desiredCapabilities.browserName}_exception_${global.date_time}.png`);
}
}

module.exports = CookieBanner;

Loading