From dfd1a421afda937b6b1ea2f9d3a9aa7614d502fa Mon Sep 17 00:00:00 2001 From: "hatem.hadrich" Date: Fri, 27 Oct 2017 11:51:06 +0100 Subject: [PATCH 1/5] Adapt the new architecture on google adwords module --- .../googleAdwords/1-CheckConfiguration.js | 18 ++++ test/clients/googleAdwords/gadwords-client.js | 88 +++++++++++++++++++ test/globals.webdriverio.js | 5 ++ 3 files changed, 111 insertions(+) create mode 100644 test/campaigns/googleAdwords/1-CheckConfiguration.js create mode 100644 test/clients/googleAdwords/gadwords-client.js diff --git a/test/campaigns/googleAdwords/1-CheckConfiguration.js b/test/campaigns/googleAdwords/1-CheckConfiguration.js new file mode 100644 index 0000000..128b06c --- /dev/null +++ b/test/campaigns/googleAdwords/1-CheckConfiguration.js @@ -0,0 +1,18 @@ +// @TODO: fix connecting with google account in FO when we buy product(error 502 bad gatway) +scenario('Test google adwords', client => { + scenario('Log in in Back Office', client => { + test('should open the browser', () => client.open()); + test('should log in successfully in BO', () => client.fillSignInForm()); + }, "googleAdwords/gadwords-client"); + scenario('Check the configuration in Back Office', client => { + test('should acces to module page', () => client.goToModule()); + test('should search the module', () => client.searchModule('gadwords')); + test('should click on configure button', () => client.clickOnConfigureButton()); + 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 is shown', () => client.checkGoogleAdwordsVoucher()); + }, "googleAdwords/gadwords-client"); + scenario('Log out from the Back Office', client => { + test('should log out successfully from the Back Office', () => client.signOutBO()); + }, "googleAdwords/gadwords-client"); +}, "googleAdwords/gadwords-client", true); \ No newline at end of file diff --git a/test/clients/googleAdwords/gadwords-client.js b/test/clients/googleAdwords/gadwords-client.js new file mode 100644 index 0000000..c8214ae --- /dev/null +++ b/test/clients/googleAdwords/gadwords-client.js @@ -0,0 +1,88 @@ +const {getClient} = require('../../common.webdriverio'); +const {selector} = require('../../globals.webdriverio.js'); + +class GoogleAdwords { + constructor() { + this.client = getClient(); + } + + fillSignInForm() { + return this.client.signinBO(); + } + + signOutBO() { + return this.client.signoutBO(); + } + close() { + return this.client.end(); + }; + + open() { + return this.client.init().windowHandleSize({width: 1280, height: 1024}); + } + + goToModule() { + return this.client + .click(selector.BO.ModulesPage.modules_subtab) + .waitForExist(selector.BO.ModulesPage.page_loaded, 60000) + .pause(5000); + } + + clickOnConfigureButton() { + return this.client + .waitForExist(selector.BO.ModulesPage.configuration_button, 90000) + .click(selector.BO.ModulesPage.configuration_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); + } + + 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"); + } + }) + .pause(5000); + } + + 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(5000); + } + + checkGoogleAdwordsVoucher() { + return this.client + .url() + .then((res) => { + var current_url = res.value; + expect(current_url).to.eql("http://www.google.com/intl/fr/ads/get/prestashop75/index.html"); + }) + .waitForExist(selector.BO.ModuleGoogleAdwords.google_adwords_voucher, 90000) + .then(() => this.client.isVisible(selector.BO.ModuleGoogleAdwords.google_adwords_voucher)) + .then((isVisible) => expect(isVisible).to.eql(true)) + .then(() => this.client.getTabIds()) + .then(ids => this.client.switchTab(ids[0])) + .pause(5000); + } + + takeScreenshot() { + return this.client.saveScreenshot(`test/screenshots/${this.client.desiredCapabilities.browserName}_exception_${global.date_time}.png`); + } +} + +module.exports = GoogleAdwords; + diff --git a/test/globals.webdriverio.js b/test/globals.webdriverio.js index 313c2ac..a4a11a7 100644 --- a/test/globals.webdriverio.js +++ b/test/globals.webdriverio.js @@ -159,6 +159,11 @@ module.exports = { save_button: '//*[@id="module_form_submit_btn_33"]' } }, + ModuleGoogleAdwords: { + voucher_input: '//pre[@id="adwords_voucher"]', + gadwords_start_button: '//*[@id="create-account-btn"]', + google_adwords_voucher: '//*[@id="right-content"]/div[1]/a' + }, SettingPage: { setting_subtab: '#subtab-ShopParameters', }, From 7b8f2da54dfe762eb978d154ea7fae5d18963a19 Mon Sep 17 00:00:00 2001 From: "hatem.hadrich" Date: Mon, 6 Nov 2017 09:52:25 +0100 Subject: [PATCH 2/5] Add some fixes to the script --- .../googleAdwords/1-CheckConfiguration.js | 29 +-- test/clients/common_client.js | 227 ++++++++++++++++++ .../{googleAdwords => }/gadwords-client.js | 50 +--- test/globals.webdriverio.js | 28 ++- 4 files changed, 262 insertions(+), 72 deletions(-) create mode 100644 test/clients/common_client.js rename test/clients/{googleAdwords => }/gadwords-client.js (52%) diff --git a/test/campaigns/googleAdwords/1-CheckConfiguration.js b/test/campaigns/googleAdwords/1-CheckConfiguration.js index 128b06c..0fc2056 100644 --- a/test/campaigns/googleAdwords/1-CheckConfiguration.js +++ b/test/campaigns/googleAdwords/1-CheckConfiguration.js @@ -1,18 +1,19 @@ -// @TODO: fix connecting with google account in FO when we buy product(error 502 bad gatway) -scenario('Test google adwords', client => { - scenario('Log in in Back Office', client => { +scenario('Check the configuration of "Google adwords" in the Back Office', client => { + scenario('Login in Back Office', client => { test('should open the browser', () => client.open()); - test('should log in successfully in BO', () => client.fillSignInForm()); - }, "googleAdwords/gadwords-client"); + test('should login successfully in BO', () => client.signInBO()); + }, "gadwords-client"); scenario('Check the configuration in Back Office', client => { - test('should acces to module page', () => client.goToModule()); - test('should search the module', () => client.searchModule('gadwords')); - test('should click on configure button', () => client.clickOnConfigureButton()); - 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 is shown', () => client.checkGoogleAdwordsVoucher()); - }, "googleAdwords/gadwords-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 is shown', () => client.checkGoogleAdwordsVoucher()); + }, "gadwords-client"); scenario('Log out from the Back Office', client => { test('should log out successfully from the Back Office', () => client.signOutBO()); - }, "googleAdwords/gadwords-client"); -}, "googleAdwords/gadwords-client", true); \ No newline at end of file + }, "gadwords-client"); +}, "gadwords-client", true); \ No newline at end of file diff --git a/test/clients/common_client.js b/test/clients/common_client.js new file mode 100644 index 0000000..1cb2b8a --- /dev/null +++ b/test/clients/common_client.js @@ -0,0 +1,227 @@ +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) + //.click(selector.BO.ModulesPage.installed_module_tabs) + } + + 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') + //.click(selector.FO.CheckoutPage.PersonalInformationSection.customer_privacy_checkbox) + .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; \ No newline at end of file diff --git a/test/clients/googleAdwords/gadwords-client.js b/test/clients/gadwords-client.js similarity index 52% rename from test/clients/googleAdwords/gadwords-client.js rename to test/clients/gadwords-client.js index c8214ae..6eb8156 100644 --- a/test/clients/googleAdwords/gadwords-client.js +++ b/test/clients/gadwords-client.js @@ -1,47 +1,7 @@ -const {getClient} = require('../../common.webdriverio'); -const {selector} = require('../../globals.webdriverio.js'); +const CommonClient = require('./common_client'); +var {selector} = require('../globals.webdriverio.js'); -class GoogleAdwords { - constructor() { - this.client = getClient(); - } - - fillSignInForm() { - return this.client.signinBO(); - } - - signOutBO() { - return this.client.signoutBO(); - } - close() { - return this.client.end(); - }; - - open() { - return this.client.init().windowHandleSize({width: 1280, height: 1024}); - } - - goToModule() { - return this.client - .click(selector.BO.ModulesPage.modules_subtab) - .waitForExist(selector.BO.ModulesPage.page_loaded, 60000) - .pause(5000); - } - - clickOnConfigureButton() { - return this.client - .waitForExist(selector.BO.ModulesPage.configuration_button, 90000) - .click(selector.BO.ModulesPage.configuration_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); - } +class GoogleAdwords extends CommonClient{ checkGoogleAdwordsPromotionalCode(){ return this.client @@ -78,10 +38,6 @@ class GoogleAdwords { .then(ids => this.client.switchTab(ids[0])) .pause(5000); } - - takeScreenshot() { - return this.client.saveScreenshot(`test/screenshots/${this.client.desiredCapabilities.browserName}_exception_${global.date_time}.png`); - } } module.exports = GoogleAdwords; diff --git a/test/globals.webdriverio.js b/test/globals.webdriverio.js index a4a11a7..84abfd8 100644 --- a/test/globals.webdriverio.js +++ b/test/globals.webdriverio.js @@ -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', @@ -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: { @@ -161,7 +167,7 @@ module.exports = { }, ModuleGoogleAdwords: { voucher_input: '//pre[@id="adwords_voucher"]', - gadwords_start_button: '//*[@id="create-account-btn"]', + gadwords_start_button: '//*[@id="content"]/div[5]/div[2]/div/div/div/p/a', google_adwords_voucher: '//*[@id="right-content"]/div[1]/a' }, SettingPage: { @@ -373,7 +379,7 @@ module.exports = { } }, - shouldExist: function(err, existing) { + shouldExist: function (err, existing) { should(err).be.not.defined; should(existing).be.true; } From cf39d954ac51def168be5fca177844d8fc96653b Mon Sep 17 00:00:00 2001 From: "hatem.hadrich" Date: Mon, 6 Nov 2017 10:40:00 +0100 Subject: [PATCH 3/5] Fixing description text --- test/campaigns/googleAdwords/1-CheckConfiguration.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/campaigns/googleAdwords/1-CheckConfiguration.js b/test/campaigns/googleAdwords/1-CheckConfiguration.js index 0fc2056..86d8b17 100644 --- a/test/campaigns/googleAdwords/1-CheckConfiguration.js +++ b/test/campaigns/googleAdwords/1-CheckConfiguration.js @@ -1,19 +1,19 @@ -scenario('Check the configuration of "Google adwords" in the Back Office', client => { +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 configuration in Back Office', 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 is shown', () => client.checkGoogleAdwordsVoucher()); + test('should click on "Start your campaign now with your promotional code" button', () => client.clickOnStartButton()); + test('should check "Google Adwords" voucher', () => client.checkGoogleAdwordsVoucher()); }, "gadwords-client"); - scenario('Log out from the Back Office', client => { - test('should log out successfully from the Back Office', () => client.signOutBO()); + scenario('Logout from the Back Office', client => { + test('should logout successfully from the Back Office', () => client.signOutBO()); }, "gadwords-client"); }, "gadwords-client", true); \ No newline at end of file From 66ecf1684e8da159df3a03e2bb619744b5239b0f Mon Sep 17 00:00:00 2001 From: "hatem.hadrich" Date: Mon, 6 Nov 2017 15:18:26 +0100 Subject: [PATCH 4/5] Add some fix for script --- .../googleAdwords/1-CheckConfiguration.js | 3 ++ test/clients/gadwords-client.js | 53 ++++++++++++++----- test/external_globals.webdriverio.js | 7 +++ test/globals.webdriverio.js | 3 +- 4 files changed, 52 insertions(+), 14 deletions(-) diff --git a/test/campaigns/googleAdwords/1-CheckConfiguration.js b/test/campaigns/googleAdwords/1-CheckConfiguration.js index 86d8b17..edfc95f 100644 --- a/test/campaigns/googleAdwords/1-CheckConfiguration.js +++ b/test/campaigns/googleAdwords/1-CheckConfiguration.js @@ -12,6 +12,9 @@ scenario('Check the voucher code of "Google adwords" module', client => { 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()); diff --git a/test/clients/gadwords-client.js b/test/clients/gadwords-client.js index 6eb8156..043c93e 100644 --- a/test/clients/gadwords-client.js +++ b/test/clients/gadwords-client.js @@ -1,18 +1,18 @@ const CommonClient = require('./common_client'); var {selector} = require('../globals.webdriverio.js'); +var {external} = require('../external_globals.webdriverio.js'); -class GoogleAdwords extends CommonClient{ +class GoogleAdwords extends CommonClient { - checkGoogleAdwordsPromotionalCode(){ + checkGoogleAdwordsPromotionalCode() { return this.client .waitForExist(selector.BO.ModuleGoogleAdwords.voucher_input, 90000) .then(() => this.client.getText(selector.BO.ModuleGoogleAdwords.voucher_input)) .then((voucher) => { - if(voucher == ""){ + if (voucher == "") { throw new Error("Google AdWords promotional code is empty"); } - }) - .pause(5000); + }); } clickOnStartButton() { @@ -21,6 +21,36 @@ class GoogleAdwords extends CommonClient{ .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); } @@ -29,14 +59,13 @@ class GoogleAdwords extends CommonClient{ .url() .then((res) => { var current_url = res.value; - expect(current_url).to.eql("http://www.google.com/intl/fr/ads/get/prestashop75/index.html"); + expect(current_url).to.eql("http://www.google.co.uk/ads/get/prestashop75/index.html"); }) - .waitForExist(selector.BO.ModuleGoogleAdwords.google_adwords_voucher, 90000) - .then(() => this.client.isVisible(selector.BO.ModuleGoogleAdwords.google_adwords_voucher)) - .then((isVisible) => expect(isVisible).to.eql(true)) - .then(() => this.client.getTabIds()) - .then(ids => this.client.switchTab(ids[0])) - .pause(5000); + .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) + }); } } diff --git a/test/external_globals.webdriverio.js b/test/external_globals.webdriverio.js index 849bef5..ec0f4a3 100644 --- a/test/external_globals.webdriverio.js +++ b/test/external_globals.webdriverio.js @@ -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]' } } diff --git a/test/globals.webdriverio.js b/test/globals.webdriverio.js index 84abfd8..19d27ea 100644 --- a/test/globals.webdriverio.js +++ b/test/globals.webdriverio.js @@ -167,8 +167,7 @@ module.exports = { }, ModuleGoogleAdwords: { voucher_input: '//pre[@id="adwords_voucher"]', - gadwords_start_button: '//*[@id="content"]/div[5]/div[2]/div/div/div/p/a', - google_adwords_voucher: '//*[@id="right-content"]/div[1]/a' + gadwords_start_button: '//*[@id="content"]/div[5]/div[2]/div/div/div/p/a' }, SettingPage: { setting_subtab: '#subtab-ShopParameters', From fd1a1fe595c743d1bb1471509d55982d4d6fad4e Mon Sep 17 00:00:00 2001 From: "hatem.hadrich" Date: Mon, 6 Nov 2017 15:22:45 +0100 Subject: [PATCH 5/5] Add some fix for script --- test/clients/common_client.js | 2 -- test/clients/gadwords-client.js | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/test/clients/common_client.js b/test/clients/common_client.js index 1cb2b8a..a10180b 100644 --- a/test/clients/common_client.js +++ b/test/clients/common_client.js @@ -34,7 +34,6 @@ class CommonClient { return this.client .click(selector.BO.ModulesPage.modules_subtub) .waitForExist(selector.BO.ModulesPage.modules_search_results, 90000) - //.click(selector.BO.ModulesPage.installed_module_tabs) } searchModule(moduleName) { @@ -184,7 +183,6 @@ class CommonClient { .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') - //.click(selector.FO.CheckoutPage.PersonalInformationSection.customer_privacy_checkbox) .scroll(selector.FO.CheckoutPage.PersonalInformationSection.continue_guest_personal_information_button, 90000) .click(selector.FO.CheckoutPage.PersonalInformationSection.continue_guest_personal_information_button) } diff --git a/test/clients/gadwords-client.js b/test/clients/gadwords-client.js index 043c93e..2b52344 100644 --- a/test/clients/gadwords-client.js +++ b/test/clients/gadwords-client.js @@ -9,7 +9,7 @@ class GoogleAdwords extends CommonClient { .waitForExist(selector.BO.ModuleGoogleAdwords.voucher_input, 90000) .then(() => this.client.getText(selector.BO.ModuleGoogleAdwords.voucher_input)) .then((voucher) => { - if (voucher == "") { + if (voucher === "") { throw new Error("Google AdWords promotional code is empty"); } });