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
22 changes: 22 additions & 0 deletions test/campaigns/googleAdwords/1-CheckConfiguration.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
scenario('Check the voucher code of "Google adwords" module', client => {
scenario('Login in Back Office', client => {
test('should open the browser', () => client.open());
test('should login successfully in BO', () => client.signInBO());
}, "gadwords-client");
scenario('Check the voucher code in "Google Adwords" module configuration page', client => {
test('should go to "Installed modules" page', () => client.goToModulesPage());
test('should search "gadwords" module', () => client.searchModule('gadwords'));
test('should check "gadwords" module', () => client.getInstalledModulesNumber());
test('should check "Configure" button', () => client.getModuleButtonName());
test('should click on "Configure" button', () => client.clickConfigureModuleButton('gadwords'));
test('should check "Google AdWords" promotional code', () => client.checkGoogleAdwordsPromotionalCode());
test('should click on "Start your campaign now with your promotional code" button', () => client.clickOnStartButton());
test('should check "Google Adwords" voucher', () => client.checkGoogleAdwordsVoucher());
test('should click on "Get Started" button', () => client.clickOnGetStartedButton());
test('should fill "Welcome to Google Adwords" form', () => client.fillWelcomeForm('prestotests@gmail.com'));
test('should fill "SignIn" form', () => client.fillSignInForm('presto_tests'));
}, "gadwords-client");
scenario('Logout from the Back Office', client => {
test('should logout successfully from the Back Office', () => client.signOutBO());
}, "gadwords-client");
}, "gadwords-client", true);
225 changes: 225 additions & 0 deletions test/clients/common_client.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,225 @@
var {getClient} = require('../common.webdriverio.js');
var {selector} = require('../globals.webdriverio.js');
var buttonText;
var nbr_module;

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

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

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

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

open() {
return this.client.init().windowHandleMaximize();
}

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

goToModulesPage() {
return this.client
.click(selector.BO.ModulesPage.modules_subtub)
.waitForExist(selector.BO.ModulesPage.modules_search_results, 90000)
}

searchModule(moduleName) {
return this.client
.setValue(selector.BO.ModulesPage.modules_search_input, moduleName)
.click(selector.BO.ModulesPage.modules_search_button)
}

getInstalledModulesNumber() {
return this.client.getText(selector.BO.ModulesPage.module_number_span).then(function (text) {
nbr_module = parseInt(text[0]);
})
}

getModuleButtonName() {
if (nbr_module === 1)
return this.client.getText(selector.BO.ModulesPage.action_module_installed_button).then(function (text) {
buttonText = text;
})
else return this.client.getText(selector.BO.ModulesPage.action_module_built_button).then(function (text) {
buttonText = text;
})
}

clickConfigureModuleButton(module_tech_name) {
if (buttonText === "CONFIGURE")
return this.client
.waitForExist(selector.BO.ModulesPage.configure_module_button.replace("%module_tech_name", module_tech_name), 90000)
.click(selector.BO.ModulesPage.configure_module_button.replace("%module_tech_name", module_tech_name))
else return this.client
.waitForExist(selector.BO.ModulesPage.actions_module_dropdown, 90000)
.click(selector.BO.ModulesPage.actions_module_dropdown)
.waitForExist(selector.BO.ModulesPage.configure_module_button.replace("%module_tech_name", module_tech_name), 90000)
.click(selector.BO.ModulesPage.configure_module_button.replace("%module_tech_name", module_tech_name))
}

clickEnableModuleButton(module_tech_name) {
if (buttonText === "ENABLE")
return this.client
.click(selector.BO.ModulesPage.enable_module_button.replace("%module_tech_name", module_tech_name))
.waitForExist(selector.BO.Common.close_validation_button, 90000)
else return this.client
.waitForExist(selector.BO.ModulesPage.actions_module_dropdown, 90000)
.click(selector.BO.ModulesPage.actions_module_dropdown)
.waitForExist(selector.BO.ModulesPage.enable_module_button.replace("%module_tech_name", module_tech_name), 90000)
.click(selector.BO.ModulesPage.enable_module_button.replace("%module_tech_name", module_tech_name))
.waitForExist(selector.BO.Common.close_validation_button, 90000)
}

clickDisableModuleButton(module_tech_name) {
if (buttonText === "DISABLE")
return this.client
.click(selector.BO.ModulesPage.disable_module_button.replace("%module_tech_name", module_tech_name))
.waitForVisible(selector.BO.ModulesPage.disable_module_confirm_button, 90000)
.click(selector.BO.ModulesPage.disable_module_confirm_button)
.waitForExist(selector.BO.Common.close_validation_button, 90000)
else return this.client
.waitForExist(selector.BO.ModulesPage.actions_module_dropdown, 90000)
.click(selector.BO.ModulesPage.actions_module_dropdown)
.waitForExist(selector.BO.ModulesPage.disable_module_button.replace("%module_tech_name", module_tech_name), 90000)
.click(selector.BO.ModulesPage.disable_module_button.replace("%module_tech_name", module_tech_name))
.waitForVisible(selector.BO.Common.disable_module_confirm_button, 90000)
.click(selector.BO.ModulesPage.disable_module_confirm_button)
.waitForExist(selector.BO.Common.close_validation_button, 90000)
}

goToOrdersPage() {
return this.client
.click(selector.BO.Common.orders_settings_button)
.waitForExist(selector.BO.OrdersPage.add_new_order_button, 90000)
}

searchOrderById() {
return this.client
.setValue(selector.BO.OrdersPage.id_input, global.order_id)
.click(selector.BO.OrdersPage.search_button)
}

goToOrderPage() {
return this.client
.waitForExist(selector.BO.OrdersPage.first_order_select, 9000)
.click(selector.BO.OrdersPage.first_order_select)
}

changeOrderStatus(status) {
return this.client
.click(selector.BO.OrderPage.order_status_dropdown)
.click(selector.BO.OrderPage.order_status_from_list.replace("%s", status))
.click(selector.BO.OrderPage.update_status_button)
.pause(2000)
}

//FO functions
signInFO() {
return this.client.signinFO();
}

signOutFO() {
return this.client.signoutFO();
}

openShop() {
return this.client
.url('http://' + URL)
.waitForExist(selector.FO.HomePage.logo_home_page)
}

selectFirstProduct() {
return this.client
.click(selector.FO.HomePage.logo_home_page)
.waitForExist(selector.FO.HomePage.first_product_home_page, 90000)
.click(selector.FO.HomePage.first_product_home_page)
.pause(2000)
}

clickAddToCartButton() {
return this.client
.waitForExist(selector.FO.ProductPage.add_to_cart_button, 90000)
.click(selector.FO.ProductPage.add_to_cart_button)
}

clickContinueShoppingButton() {
return this.client
.pause(2000)
.waitForExist(selector.FO.ProductPage.continue_shopping_button, 90000)
.click(selector.FO.ProductPage.continue_shopping_button)
}

goToCartPage() {
return this.client
.pause(2000)
.waitForExist(selector.FO.HomePage.cart_button)
.click(selector.FO.HomePage.cart_button)
.waitForExist(selector.FO.CartPage.proceed_to_checkout_button, 90000)
}

clickProceedCheckoutButton() {
return this.client
.click(selector.FO.CartPage.proceed_to_checkout_button)
.waitForExist(selector.FO.CheckoutPage.PersonalInformationSection.header, 90000)
}

fillPersonnelInformationForm() {
return this.client
.click(selector.FO.CheckoutPage.PersonalInformationSection.order_as_a_guest_button)
.click(selector.FO.CheckoutPage.PersonalInformationSection.social_title_mr_radio_button)
.setValue(selector.FO.CheckoutPage.PersonalInformationSection.first_name_input, 'John')
.setValue(selector.FO.CheckoutPage.PersonalInformationSection.last_name_input, 'Doe')
.setValue(selector.FO.CheckoutPage.PersonalInformationSection.email_guest_input, 'pub@prestashop.com')
.scroll(selector.FO.CheckoutPage.PersonalInformationSection.continue_guest_personal_information_button, 90000)
.click(selector.FO.CheckoutPage.PersonalInformationSection.continue_guest_personal_information_button)
}

fillAddressForm() {
return this.client
.setValue(selector.FO.CheckoutPage.AddressesSection.address_input, '12 Rue d\'Amsterdam')
.setValue(selector.FO.CheckoutPage.AddressesSection.postcode_input, '75009')
.setValue(selector.FO.CheckoutPage.AddressesSection.city_input, 'Paris')
.click(selector.FO.CheckoutPage.AddressesSection.country_checkbox + '/option[2]')
.scroll(selector.FO.CheckoutPage.AddressesSection.continue_addresses_button)
.click(selector.FO.CheckoutPage.AddressesSection.continue_addresses_button)
}

fillShippingForm() {
return this.client
.scroll(selector.FO.CheckoutPage.DeliverySection.continue_shipping_button)
.click(selector.FO.CheckoutPage.DeliverySection.continue_shipping_button)
}

fillPaymentForm() {
return this.client
.click(selector.FO.CheckoutPage.PaymentSection.pay_by_check_radio_button)
.click(selector.FO.CheckoutPage.PaymentSection.terms_of_service_checkbox)
.scroll(selector.FO.CheckoutPage.PaymentSection.order_with_an_obligation_to_pay_button)
.click(selector.FO.CheckoutPage.PaymentSection.order_with_an_obligation_to_pay_button)
}

getOrderId() {
return this.client
.url()
.then((res) => {
var current_url = res.value;
var temp1 = current_url.split("id_order=");
var temp2 = temp1[1].split("&");
global.order_id = temp2[0];
})
}
}
module.exports = CommonClient;
73 changes: 73 additions & 0 deletions test/clients/gadwords-client.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
const CommonClient = require('./common_client');
var {selector} = require('../globals.webdriverio.js');
var {external} = require('../external_globals.webdriverio.js');

class GoogleAdwords extends CommonClient {

checkGoogleAdwordsPromotionalCode() {
return this.client
.waitForExist(selector.BO.ModuleGoogleAdwords.voucher_input, 90000)
.then(() => this.client.getText(selector.BO.ModuleGoogleAdwords.voucher_input))
.then((voucher) => {
if (voucher === "") {
throw new Error("Google AdWords promotional code is empty");
}
});
}

clickOnStartButton() {
return this.client
.waitForExist(selector.BO.ModuleGoogleAdwords.gadwords_start_button, 90000)
.click(selector.BO.ModuleGoogleAdwords.gadwords_start_button, 90000)
.then(() => this.client.getTabIds())
.then(ids => this.client.switchTab(ids[1]))
.pause(3000);
}

fillWelcomeForm(email) {
return this.client
.waitForExist(external.FO.GoogleAdwords.email_input, 90000)
.setValue(external.FO.GoogleAdwords.email_input, email)
.waitForExist(external.FO.GoogleAdwords.website_input, 90000)
.setValue(external.FO.GoogleAdwords.website_input, URL)
.click(external.FO.GoogleAdwords.continue_button, 90000);
}

fillSignInForm(password) {
return this.client
.waitForExist(external.FO.Google.identifier_next_button, 90000)
.click(external.FO.Google.identifier_next_button)
.pause(5000)
.waitForVisible(external.FO.Google.password_input, 90000)
.setValue(external.FO.Google.password_input, password)
.waitForExist(external.FO.Google.password_next_button, 90000)
.click(external.FO.Google.password_next_button)
.pause(5000)
.then(() => this.client.getTabIds())
.then(ids => this.client.switchTab(ids[0]));
}

clickOnGetStartedButton() {
return this.client
.waitForExist(external.FO.GoogleAdwords.get_started_button, 90000)
.click(external.FO.GoogleAdwords.get_started_button, 90000)
.pause(5000);
}

checkGoogleAdwordsVoucher() {
return this.client
.url()
.then((res) => {
var current_url = res.value;
expect(current_url).to.eql("http://www.google.co.uk/ads/get/prestashop75/index.html");
})
.waitForExist(external.FO.GoogleAdwords.google_adwords_voucher, 90000)
.then(() => this.client.isVisible(external.FO.GoogleAdwords.google_adwords_voucher))
.then((isVisible) => {
expect(isVisible).to.eql(true)
});
}
}

module.exports = GoogleAdwords;

7 changes: 7 additions & 0 deletions test/external_globals.webdriverio.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,13 @@ module.exports = {
delete_base_domain_icon: '//*[@id="apps_edit_domain_cont"]/div/div[1]/div[1]/div/a/div',
domain_input: '//*[@id="apps_edit_domain_cont"]/div/div[1]/div[2]/input',
save_button: '//*[@id="app_save_btn"]'
},
GoogleAdwords: {
google_adwords_voucher: '//*[@id="right-content"]',
get_started_button: '//a[@class="maia-button"]',
email_input: '//*[@id="gwt-debug-about-page-email"]/input',
website_input: '//*[@id="gwt-debug-about-page-website"]/input',
continue_button: '//*[@id="gwt-debug-about-page-continue-button"]/div/div/div/div[2]'
}
}

Expand Down
30 changes: 20 additions & 10 deletions test/globals.webdriverio.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ global.listNameInput = 'Test_list_MailChimp' + date_time;
module.exports = {
selector: {

BO:{
BO: {
Common: {
menu: '#nav-sidebar',
close_validation_button: '.growl-close',
Expand All @@ -28,17 +28,23 @@ module.exports = {
password_input: '#passwd',
login_button: '[name="submitLogin"]'
},
//Modules page selectors
ModulesPage: {
modules_subtab: '#subtab-AdminParentModulesSf',
search_input: 'div.pstaggerAddTagWrapper > input',
search_button: '.btn.btn-primary.pull-right.search-button',
modules_subtub: '#subtab-AdminParentModulesSf',
installed_module_tabs: '(//div[@class="page-head-tabs"]/a)[2]',
modules_search_results: '.module-search-result-wording',
modules_search_input: '.pstaggerAddTagInput.module-tags-input',
modules_search_button: '//*[@id="main-div"]/div[3]/div[2]/div/div[2]/div/div[5]/div/div[1]/div/button',
module_number_span: '//*[@id="main-div"]/div[3]/div[2]/div/div[2]/div/div[7]/span[1]',
page_loaded: '.module-search-result-wording',
installed_modules_tabs: '(//div[@class="page-head-tabs"]/a)[2]',
module_number_span: '[class="module-sorting-search-wording"]',
number_of_module_found:'//*[@id="main-div"]/div[3]/div/div/div[2]/div/div[7]/span[1]',
configuration_button:'//*[@id="modules-list-container-all"]/div/div/div/div[5]/div[2]/form/button',
module_menu_button: '[class="btn btn-primary-outline dropdown-toggle"]',
enable_module_button: '[class="dropdown-item module_action_menu_enable"]'
configure_module_button: '[data-confirm_modal="module-modal-confirm-%module_tech_name-configure"]',
enable_module_button: '[data-confirm_modal="module-modal-confirm-%module_tech_name-enable"]',
disable_module_button: '[data-confirm_modal="module-modal-confirm-%module_tech_name-disable"]',
disable_module_confirm_button: '[class="btn btn-primary uppercase module_action_modal_disable"]',
actions_module_dropdown: '//*[@class="btn btn-primary-outline dropdown-toggle"]',
action_module_installed_button: '//*[@id="modules-list-container-all"]/div[1]/div/div/div[5]/div[2]/form/button',
action_module_built_button: '//*[@id="modules-list-container-native"]/div/div/div/div[5]/div[2]/form/button'
},
//Customer page selectors
CustomersPage: {
Expand Down Expand Up @@ -159,6 +165,10 @@ module.exports = {
save_button: '//*[@id="module_form_submit_btn_33"]'
}
},
ModuleGoogleAdwords: {
voucher_input: '//pre[@id="adwords_voucher"]',
gadwords_start_button: '//*[@id="content"]/div[5]/div[2]/div/div/div/p/a'
},
SettingPage: {
setting_subtab: '#subtab-ShopParameters',
},
Expand Down Expand Up @@ -368,7 +378,7 @@ module.exports = {

}
},
shouldExist: function(err, existing) {
shouldExist: function (err, existing) {
should(err).be.not.defined;
should(existing).be.true;
}
Expand Down