From f1a029e687937b31fefdd20162b58bccd76eb66e Mon Sep 17 00:00:00 2001 From: sallemiines Date: Tue, 31 Oct 2017 18:01:34 +0100 Subject: [PATCH 1/4] Working on scenarios --- .../googleAnalytics/GoogleAnalytics.js | 31 +++ .../MailChimp-Integration.js | 2 +- .../googleAnalytics-client.js | 177 ++++++++++++++++++ test/common.webdriverio.js | 2 +- test/external_globals.webdriverio.js | 51 ++--- test/globals.webdriverio.js | 20 +- 6 files changed, 254 insertions(+), 29 deletions(-) create mode 100644 test/campaigns/googleAnalytics/GoogleAnalytics.js create mode 100644 test/clients/google-analytics/googleAnalytics-client.js diff --git a/test/campaigns/googleAnalytics/GoogleAnalytics.js b/test/campaigns/googleAnalytics/GoogleAnalytics.js new file mode 100644 index 0000000..5b5e685 --- /dev/null +++ b/test/campaigns/googleAnalytics/GoogleAnalytics.js @@ -0,0 +1,31 @@ +scenario('Test google analytics', client => { + scenario('Test case 1 : Configure "Google analytics" module ', () => { + scenario('Log in in Back Office', client => { + test('should open the browser', () => client.open()); + test('should log in successfully in BO', () => client.signInBO()); + test('should go to the installed module page', () => client.goToModulePage()); + test('should search the "ps_googleanalytics" module page', () => client.searchModule()); + test('should go to the module configuration page', () => client.goToModuleConfigurationPage()); + }, "google-analytics/googleAnalytics-client"); + }, "google-analytics/googleAnalytics-client"); + scenario('Test case 2 : Configure google analytics account', () => { + scenario('Go to google analytics account', client => { + test('should go to creat account link', () => client.goToCreateAccountLink()); + test('should log in successfully in google account', () => client.fillGoogleSignInForm()); + test('should go to administration setting', () => client.clickOnAdministration()); + test('should select the Property Settings', () => client.selectPropertySettings()); + test('should check the existance of id ', () => client.checkId()); + }, "google-analytics/googleAnalytics-client"); + scenario('Configure the module in shop', client => { + test('should back to shop', () => client.backToShop()); + test('should enter Google Analytics Tracking ID', () => client.addGoogleTrackingId()); + test('should Enable User ID tracking', () => client.enableUserTrackingId()); + test('should click on button Save', () => client.clickOnSaveButton()); + test('should check the account ID', () => client.checkAccountId()); + test('should check the user ID', () => client.checkUserId()); + }, "google-analytics/googleAnalytics-client"); + scenario('Logout from Back Office', client => { + test('should logout', () => client.signOutBO()); + }, "google-analytics/googleAnalytics-client"); + }, "google-analytics/googleAnalytics-client"); +}, "google-analytics/googleAnalytics-client", true); diff --git a/test/campaigns/mailchimpIntegration/MailChimp-Integration.js b/test/campaigns/mailchimpIntegration/MailChimp-Integration.js index b13d36a..954d8ec 100644 --- a/test/campaigns/mailchimpIntegration/MailChimp-Integration.js +++ b/test/campaigns/mailchimpIntegration/MailChimp-Integration.js @@ -20,7 +20,7 @@ scenario('Test mailChimp-integration', client => { test('should disconnect from list', () => client.disconnectFromList()); test('should select list', () => client.selectList()); }, "mailchimp-integration/mailChimpintegration-client"); - scenario('Logout from Back Office', client => { + scenario('Logout from Back Office', client => { test('should logout', () => client.signOutBO()); }, "mailchimp-integration/mailChimpintegration-client"); }, "mailchimp-integration/mailChimpintegration-client", true); \ No newline at end of file diff --git a/test/clients/google-analytics/googleAnalytics-client.js b/test/clients/google-analytics/googleAnalytics-client.js new file mode 100644 index 0000000..02507d1 --- /dev/null +++ b/test/clients/google-analytics/googleAnalytics-client.js @@ -0,0 +1,177 @@ +const {getClient} = require('../../common.webdriverio.js'); +const {selector} = require('../../globals.webdriverio.js'); +const {external} = require('../../external_globals.webdriverio.js'); + +class GoogleAnalytics { + constructor() { + this.client = getClient(); + } + + signInBO() { + return this.client.signinBO(); + } + + signOutBO() { + return this.client.signoutBO(); + } + + close() { + return this.client.end(); + } + + takeScreenshot() { + return this.client.saveScreenshot(`test/screenshots/${this.client.desiredCapabilities.browserName}_exception_${global.date_time}.png`); + } + + open() { + return this.client.init().windowHandleMaximize(); + } + + goToModulePage() { + + return this.client + .waitForExist(selector.BO.ModulesPage.modules_subtab, 90000) + .click(selector.BO.ModulesPage.modules_subtab) + .pause(5000); + } + + goToModuleConfigurationPage() { + + return this.client + .waitForExist(selector.BO.GoogleAnalyticsPage.config_module_button, 90000) + .click(selector.BO.GoogleAnalyticsPage.config_module_button) + + } + + fillGoogleSignInForm(login = "prestotests@gmail.com", password = "presto_tests") { + + return this.client + .waitForExist(external.FO.GoogleAnalytics.connect_button, 90000) + .click(external.FO.GoogleAnalytics.connect_button) + .waitForExist(external.FO.GoogleAnalytics.google_analytics_choice, 9000) + .click(external.FO.GoogleAnalytics.google_analytics_choice) + .waitForExist(external.FO.Google.username_input, 90000) + .setValue(external.FO.Google.username_input, login) + .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(9000) + } + + goToCreateAccountLink() { + + return this.client + .moveToObject(selector.BO.GoogleAnalyticsPage.creat_account_link, 9000) + .then(() => this.client.getAttribute(selector.BO.GoogleAnalyticsPage.creat_account_link, 'href')) + .then((href) => { + this.client.newWindow(href) + }) + .pause(3000) + .waitForVisible(external.FO.GoogleAnalytics.google_analytics_link, 90000) + .click(external.FO.GoogleAnalytics.google_analytics_link) + .then(() => this.client.getTabIds()) + .then((ids) => this.client.switchTab(ids[ids.length - 1])) + } + + backToShop() { + + return this.client + .waitForExist(external.FO.GoogleAnalytics.reset_button, 90000) + .then(() => this.client.getTabIds()) + .then((ids) => this.client.switchTab(ids[0])) + .pause(20000); + } + + clickOnAdministration() { + + return this.client + .waitForExist(external.FO.GoogleAnalytics.administration_button, 90000) + .click(external.FO.GoogleAnalytics.administration_button) + .pause(3000) + } + + selectPropertySettings() { + + return this.client + .waitForExist(external.FO.GoogleAnalytics.property_settings_button, 90000) + .click(external.FO.GoogleAnalytics.property_settings_button) + .pause(3000) + } + + checkId() { + + return this.client + .waitForExist(external.FO.GoogleAnalytics.google_analytics_id, 90000) + .getText(external.FO.GoogleAnalytics.google_analytics_id).then(function (id) { + global.tracking_id = id; + should(global.tracking_id).be.equal("UA-105026510-1"); + }) + .waitForExist(external.FO.GoogleAnalytics.google_analytics_url_input, 9000) + .setValue(external.FO.GoogleAnalytics.google_analytics_url_input, URL) + .waitForExist(external.FO.GoogleAnalytics.save_button, 3000) + .click(external.FO.GoogleAnalytics.save_button) + .pause(9000) + } + + searchModule() { + + return this.client + .waitForExist(selector.BO.ModulesPage.search_input, 90000) + .setValue(selector.BO.ModulesPage.search_input, module_tech_name_googleAnalytics) + .waitForExist(selector.BO.ModulesPage.search_button, 3000) + .click(selector.BO.ModulesPage.search_button) + .pause(3000) + .waitForExist(selector.BO.ModulesPage.page_loaded, 90000) + .then(() => this.client.getText(selector.BO.ModulesPage.page_loaded)) + .then((nbr) => { + global.nbr = parseInt(nbr[0].charAt(0)) + }) + .pause(3000); + } + + addGoogleTrackingId() { + + return this.client + .waitForExist(selector.BO.GoogleAnalyticsPage.googleanalytics_tracking_id, 90000) + .setValue(selector.BO.GoogleAnalyticsPage.googleanalytics_tracking_id, global.tracking_id) + } + + enableUserTrackingId() { + + return this.client + .waitForExist(selector.BO.GoogleAnalyticsPage.enable_user_id_tracking, 90000) + .click(selector.BO.GoogleAnalyticsPage.enable_user_id_tracking, 90000) + } + + clickOnSaveButton() { + + return this.client + .waitForExist(selector.BO.GoogleAnalyticsPage.googleanalytics_submit_btn, 90000) + .click(selector.BO.GoogleAnalyticsPage.googleanalytics_submit_btn, 90000) + } + + checkAccountId() { + + return this.client + .waitForExist(selector.BO.GoogleAnalyticsPage.account_id_green_block, 90000) + .getText(selector.BO.GoogleAnalyticsPage.account_id_green_block).then(function (text) { + should(text).be.equal('×\nAccount ID updated successfully'); + }) + } + + checkUserId() { + + return this.client + .waitForExist(selector.BO.GoogleAnalyticsPage.user_id_green_block, 90000) + .getText(selector.BO.GoogleAnalyticsPage.user_id_green_block).then(function (text) { + should(text).be.equal('×\nSettings for User ID updated successfully'); + }) + } + +} + +module.exports = GoogleAnalytics; diff --git a/test/common.webdriverio.js b/test/common.webdriverio.js index 7c2f339..fc13753 100644 --- a/test/common.webdriverio.js +++ b/test/common.webdriverio.js @@ -40,7 +40,7 @@ function initCommands(client) { return client .url('https://' + URL + '/backoffice/') .waitForExist(this.selector.BO.LoginPage.login_input, 90000) - .setValue(this.selector.BO.LoginPage.login_input, 'remi.gaillard@prestashop.com') + .setValue(this.selector.BO.LoginPage.login_input, 'testmodule@prestashop.com') .setValue(this.selector.BO.LoginPage.password_input, 'abcd1234') .click(this.selector.BO.LoginPage.login_button) .waitForExist(this.selector.BO.Common.menu, 90000) diff --git a/test/external_globals.webdriverio.js b/test/external_globals.webdriverio.js index 849bef5..8f8eaa5 100644 --- a/test/external_globals.webdriverio.js +++ b/test/external_globals.webdriverio.js @@ -12,7 +12,7 @@ module.exports = { username_input: '//*[@id="email"]', password_input: '//*[@id="pass"]', signin_button: '//*[@id="loginbutton"]', - app_link : '//*[@id="js_en"]/span', + app_link: '//*[@id="js_en"]/span', customer_api_key: '//*[@id="u_0_5t"]/div[1]/div/table/tbody/tr[1]/td[1]/div/div', show_secret_button: '//*[@id="u_0_5u"]/div/button', customer_api_secret: '//*[@id="u_0_5u"]/div/span', @@ -22,23 +22,21 @@ module.exports = { }, Twitter: { signein_button: '//*[@id="gaz-content-body"]/div[2]/div/a', - signein_login_input : '//*[@id="page-container"]/div/div[1]/form/fieldset/div[1]/input', - signein_password_input : '//*[@id="page-container"]/div/div[1]/form/fieldset/div[2]/input', - signein_connect_input : '//*[@id="page-container"]/div/div[1]/form/div[2]/button', + signein_login_input: '//*[@id="page-container"]/div/div[1]/form/fieldset/div[1]/input', + signein_password_input: '//*[@id="page-container"]/div/div[1]/form/fieldset/div[2]/input', + signein_connect_input: '//*[@id="page-container"]/div/div[1]/form/div[2]/button', - app_link : '//*[@id="gaz-content-body"]/div[3]/div/ul/li[1]/div/div[2]/h2/a', - settings_tab : '//*[@id="gaz-content-body"]/div[2]/ul/li[2]/a', - key_and_access_tokens_tab : '//*[@id="gaz-content-body"]/div[2]/ul/li[3]/a', - website_url_input : '//*[@id="edit-url"]', - callback_url_input : '//*[@id="edit-callback-url"]', - update_settings_button : '//*[@id="edit-submit"]', + app_link: '//*[@id="gaz-content-body"]/div[3]/div/ul/li[1]/div/div[2]/h2/a', + settings_tab: '//*[@id="gaz-content-body"]/div[2]/ul/li[2]/a', + key_and_access_tokens_tab: '//*[@id="gaz-content-body"]/div[2]/ul/li[3]/a', + website_url_input: '//*[@id="edit-url"]', + callback_url_input: '//*[@id="edit-callback-url"]', + update_settings_button: '//*[@id="edit-submit"]', customer_api_key: '//*[@id="gaz-content-body"]/div[3]/div/div[2]/div[1]/span[2]', customer_api_secret: '//*[@id="gaz-content-body"]/div[3]/div/div[2]/div[2]/span[2]' }, //@TODO - Amazon: { - - }, + Amazon: {}, Google: { username_input: '//*[@id="identifierId"]', identifier_next_button: '//*[@id="identifierNext"]', @@ -75,9 +73,7 @@ module.exports = { save_button: '.small.primary.two.columns' }, //@TODO - Yahoo: { - - }, + Yahoo: {}, Paypal: { username_input: '//*[@id="email"]', password_input: '//*[@id="password"]', @@ -198,12 +194,12 @@ module.exports = { signin_button: '//*[@id="signup_forms_submit"]/span[6]', app_link: '//*[@id="dashboard_account_oauth_apps"]/div[4]/div/div/div[2]/a[2]', - website_url_input:'//*[@id="oac_url"]', - callback_url_input:'//*[@id="oac_default_callback_url"]', - save_button:'//*[@id="save_button"]', - customer_key:'//*[@id="dashboard_account_register_oauth_app"]/div[4]/div/div/span[1]', - customer_secret:'//*[@id="secret"]', - show_secret_button:'//*[@id="secret_toggle"]' + website_url_input: '//*[@id="oac_url"]', + callback_url_input: '//*[@id="oac_default_callback_url"]', + save_button: '//*[@id="save_button"]', + customer_key: '//*[@id="dashboard_account_register_oauth_app"]/div[4]/div/div/span[1]', + customer_secret: '//*[@id="secret"]', + show_secret_button: '//*[@id="secret_toggle"]' }, Vkontakte: { username_input: '//*[@id="email"]', @@ -219,6 +215,17 @@ 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"]' + }, + GoogleAnalytics: { + connect_button:'/html/body/header/nav/div/a', + google_analytics_choice:'/html/body/header/nav/div/div/ul/li[1]/a', + property_settings_button:'//*[@id="ID-m-propertyColumn"]/div[2]/div[3]/div[1]/a[1]/div', + administration_button:'//*[@id="bottomSectionAdmin"]/nav/div/div/ga-nav-link/div/a/ng-include/span', + google_analytics_id: '//*[@id="ID-m-content"]/div/div/div/div/div/div[2]/div/ui-view/form/section[1]/div[1]/div[2]', + google_analytics_url_input:'//*[@id="ID-m-content"]/div/div/div/div/div/div[2]/div/ui-view/form/section[1]/div[3]/div[2]/ga-url-selector/input', + save_button: '//*[@id="ID-m-content"]/div/div/div/div/div/div[2]/div/ui-view/form/ga-submit-buttons/div/button[1]', + google_analytics_link:'/html/body/div[2]/div[2]/section/div/article/section/div/ol/li[1]/ul/li[1]/a', + reset_button:'//*[@id="ID-m-content"]/div/div/div/div/div/div[2]/div/ui-view/form/ga-submit-buttons/div/button[2]' } } diff --git a/test/globals.webdriverio.js b/test/globals.webdriverio.js index 313c2ac..0d7bd4b 100644 --- a/test/globals.webdriverio.js +++ b/test/globals.webdriverio.js @@ -10,13 +10,13 @@ global.selenium_url = argv.SELENIUM; global._projectdir = path.join(__dirname, '..', '..'); global.product_id = new Date().getTime(); global.new_customer_email = 'pub' + date_time + '@prestashop.com'; - +global.module_tech_name_googleAnalytics = 'ps_googleanalytics'; global.module_tech_name_mailchimp = 'mailchimpintegration'; global.listNameInput = 'Test_list_MailChimp' + date_time; module.exports = { selector: { - BO:{ + BO: { Common: { menu: '#nav-sidebar', close_validation_button: '.growl-close', @@ -35,8 +35,8 @@ module.exports = { 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', + 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"]' }, @@ -183,6 +183,16 @@ module.exports = { phone_input: '//*[@id="conf_id_PS_SHOP_PHONE"]/div/input', fax_input: '//*[@id="conf_id_PS_SHOP_FAX"]/div/input', save_button: '//*[@id="store_fieldset_contact"]/div[3]/button', + }, + + GoogleAnalyticsPage: { + config_module_button: '//*[@id="modules-list-container-native"]/div/div/div/div[5]/div[2]/form/button', + googleanalytics_tracking_id: '//*[@id="GA_ACCOUNT_ID"]', + enable_user_id_tracking: '//*[@id="ga_userid_enabled"]', + googleanalytics_submit_btn: '//*[@id="configuration_form_submit_btn"]', + account_id_green_block: '//*[@id="content"]/div[6]/div[@class="module_confirmation conf confirm alert alert-success"]', + user_id_green_block: '//*[@id="content"]/div[7]/div[@class="module_confirmation conf confirm alert alert-success"]', + creat_account_link: '//*[@id="google_analytics_content"]/div/div[2]/p[2]/b/a' } }, //FO @@ -368,7 +378,7 @@ module.exports = { } }, - shouldExist: function(err, existing) { + shouldExist: function (err, existing) { should(err).be.not.defined; should(existing).be.true; } From e168fe482f50f6b3951c699b950e559f5cf1a966 Mon Sep 17 00:00:00 2001 From: sallemiines Date: Wed, 1 Nov 2017 08:38:38 +0100 Subject: [PATCH 2/4] Fixing code --- test/campaigns/googleAnalytics/GoogleAnalytics.js | 2 +- .../google-analytics/googleAnalytics-client.js | 5 +---- test/external_globals.webdriverio.js | 14 +++++++------- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/test/campaigns/googleAnalytics/GoogleAnalytics.js b/test/campaigns/googleAnalytics/GoogleAnalytics.js index 5b5e685..506d5a8 100644 --- a/test/campaigns/googleAnalytics/GoogleAnalytics.js +++ b/test/campaigns/googleAnalytics/GoogleAnalytics.js @@ -19,7 +19,7 @@ scenario('Test google analytics', client => { scenario('Configure the module in shop', client => { test('should back to shop', () => client.backToShop()); test('should enter Google Analytics Tracking ID', () => client.addGoogleTrackingId()); - test('should Enable User ID tracking', () => client.enableUserTrackingId()); + test('should enable the user ID tracking', () => client.enableUserTrackingId()); test('should click on button Save', () => client.clickOnSaveButton()); test('should check the account ID', () => client.checkAccountId()); test('should check the user ID', () => client.checkUserId()); diff --git a/test/clients/google-analytics/googleAnalytics-client.js b/test/clients/google-analytics/googleAnalytics-client.js index 02507d1..2413377 100644 --- a/test/clients/google-analytics/googleAnalytics-client.js +++ b/test/clients/google-analytics/googleAnalytics-client.js @@ -40,7 +40,6 @@ class GoogleAnalytics { return this.client .waitForExist(selector.BO.GoogleAnalyticsPage.config_module_button, 90000) .click(selector.BO.GoogleAnalyticsPage.config_module_button) - } fillGoogleSignInForm(login = "prestotests@gmail.com", password = "presto_tests") { @@ -83,7 +82,7 @@ class GoogleAnalytics { .waitForExist(external.FO.GoogleAnalytics.reset_button, 90000) .then(() => this.client.getTabIds()) .then((ids) => this.client.switchTab(ids[0])) - .pause(20000); + .pause(5000); } clickOnAdministration() { @@ -91,7 +90,6 @@ class GoogleAnalytics { return this.client .waitForExist(external.FO.GoogleAnalytics.administration_button, 90000) .click(external.FO.GoogleAnalytics.administration_button) - .pause(3000) } selectPropertySettings() { @@ -171,7 +169,6 @@ class GoogleAnalytics { should(text).be.equal('×\nSettings for User ID updated successfully'); }) } - } module.exports = GoogleAnalytics; diff --git a/test/external_globals.webdriverio.js b/test/external_globals.webdriverio.js index 8f8eaa5..152a12a 100644 --- a/test/external_globals.webdriverio.js +++ b/test/external_globals.webdriverio.js @@ -217,15 +217,15 @@ module.exports = { save_button: '//*[@id="app_save_btn"]' }, GoogleAnalytics: { - connect_button:'/html/body/header/nav/div/a', - google_analytics_choice:'/html/body/header/nav/div/div/ul/li[1]/a', - property_settings_button:'//*[@id="ID-m-propertyColumn"]/div[2]/div[3]/div[1]/a[1]/div', - administration_button:'//*[@id="bottomSectionAdmin"]/nav/div/div/ga-nav-link/div/a/ng-include/span', + connect_button: '/html/body/header/nav/div/a', + google_analytics_choice: '/html/body/header/nav/div/div/ul/li[1]/a', + property_settings_button: '//*[@id="ID-m-propertyColumn"]/div[2]/div[3]/div[1]/a[1]/div', + administration_button: '//*[@id="bottomSectionAdmin"]/nav/div/div/ga-nav-link/div/a/ng-include/span', google_analytics_id: '//*[@id="ID-m-content"]/div/div/div/div/div/div[2]/div/ui-view/form/section[1]/div[1]/div[2]', - google_analytics_url_input:'//*[@id="ID-m-content"]/div/div/div/div/div/div[2]/div/ui-view/form/section[1]/div[3]/div[2]/ga-url-selector/input', + google_analytics_url_input: '//*[@id="ID-m-content"]/div/div/div/div/div/div[2]/div/ui-view/form/section[1]/div[3]/div[2]/ga-url-selector/input', save_button: '//*[@id="ID-m-content"]/div/div/div/div/div/div[2]/div/ui-view/form/ga-submit-buttons/div/button[1]', - google_analytics_link:'/html/body/div[2]/div[2]/section/div/article/section/div/ol/li[1]/ul/li[1]/a', - reset_button:'//*[@id="ID-m-content"]/div/div/div/div/div/div[2]/div/ui-view/form/ga-submit-buttons/div/button[2]' + google_analytics_link: '/html/body/div[2]/div[2]/section/div/article/section/div/ol/li[1]/ul/li[1]/a', + reset_button: '//*[@id="ID-m-content"]/div/div/div/div/div/div[2]/div/ui-view/form/ga-submit-buttons/div/button[2]' } } From 4d6f81a5714c454cb988a33c822d3eff00392539 Mon Sep 17 00:00:00 2001 From: sallemiines Date: Wed, 1 Nov 2017 10:50:39 +0100 Subject: [PATCH 3/4] Updating selector --- .../googleAnalytics/GoogleAnalytics.js | 14 +++++-------- .../googleAnalytics-client.js | 21 +++++++++++-------- test/globals.webdriverio.js | 3 +-- 3 files changed, 18 insertions(+), 20 deletions(-) diff --git a/test/campaigns/googleAnalytics/GoogleAnalytics.js b/test/campaigns/googleAnalytics/GoogleAnalytics.js index 506d5a8..2f24aa9 100644 --- a/test/campaigns/googleAnalytics/GoogleAnalytics.js +++ b/test/campaigns/googleAnalytics/GoogleAnalytics.js @@ -1,16 +1,13 @@ scenario('Test google analytics', client => { - scenario('Test case 1 : Configure "Google analytics" module ', () => { - scenario('Log in in Back 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()); + }, "google-analytics/googleAnalytics-client"); + scenario('Configure google analytics account', () => { test('should go to the installed module page', () => client.goToModulePage()); - test('should search the "ps_googleanalytics" module page', () => client.searchModule()); + test('should search the "ps_googleanalytics" module page', () => client.searchModule('ps_googleanalytics')); test('should go to the module configuration page', () => client.goToModuleConfigurationPage()); - }, "google-analytics/googleAnalytics-client"); - }, "google-analytics/googleAnalytics-client"); - scenario('Test case 2 : Configure google analytics account', () => { - scenario('Go to google analytics account', client => { - test('should go to creat account link', () => client.goToCreateAccountLink()); + test('should click on create account link', () => client.clickOnCreateAccountLink()); test('should log in successfully in google account', () => client.fillGoogleSignInForm()); test('should go to administration setting', () => client.clickOnAdministration()); test('should select the Property Settings', () => client.selectPropertySettings()); @@ -27,5 +24,4 @@ scenario('Test google analytics', client => { scenario('Logout from Back Office', client => { test('should logout', () => client.signOutBO()); }, "google-analytics/googleAnalytics-client"); - }, "google-analytics/googleAnalytics-client"); }, "google-analytics/googleAnalytics-client", true); diff --git a/test/clients/google-analytics/googleAnalytics-client.js b/test/clients/google-analytics/googleAnalytics-client.js index 2413377..79f7718 100644 --- a/test/clients/google-analytics/googleAnalytics-client.js +++ b/test/clients/google-analytics/googleAnalytics-client.js @@ -61,11 +61,11 @@ class GoogleAnalytics { .pause(9000) } - goToCreateAccountLink() { + clickOnCreateAccountLink() { return this.client - .moveToObject(selector.BO.GoogleAnalyticsPage.creat_account_link, 9000) - .then(() => this.client.getAttribute(selector.BO.GoogleAnalyticsPage.creat_account_link, 'href')) + .moveToObject(selector.BO.GoogleAnalyticsPage.create_account_link, 9000) + .then(() => this.client.getAttribute(selector.BO.GoogleAnalyticsPage.create_account_link, 'href')) .then((href) => { this.client.newWindow(href) }) @@ -115,11 +115,11 @@ class GoogleAnalytics { .pause(9000) } - searchModule() { + searchModule(moduleName) { return this.client .waitForExist(selector.BO.ModulesPage.search_input, 90000) - .setValue(selector.BO.ModulesPage.search_input, module_tech_name_googleAnalytics) + .setValue(selector.BO.ModulesPage.search_input, moduleName) .waitForExist(selector.BO.ModulesPage.search_button, 3000) .click(selector.BO.ModulesPage.search_button) .pause(3000) @@ -156,8 +156,9 @@ class GoogleAnalytics { return this.client .waitForExist(selector.BO.GoogleAnalyticsPage.account_id_green_block, 90000) - .getText(selector.BO.GoogleAnalyticsPage.account_id_green_block).then(function (text) { - should(text).be.equal('×\nAccount ID updated successfully'); + .then(() => this.client.getText(selector.BO.GoogleAnalyticsPage.account_id_green_block)) + .then((value) => { + expect(value).to.eql('×\nAccount ID updated successfully') }) } @@ -165,10 +166,12 @@ class GoogleAnalytics { return this.client .waitForExist(selector.BO.GoogleAnalyticsPage.user_id_green_block, 90000) - .getText(selector.BO.GoogleAnalyticsPage.user_id_green_block).then(function (text) { - should(text).be.equal('×\nSettings for User ID updated successfully'); + .then(() => this.client.getText(selector.BO.GoogleAnalyticsPage.user_id_green_block)) + .then((value) => { + expect(value).to.eql('×\nSettings for User ID updated successfully') }) } + } module.exports = GoogleAnalytics; diff --git a/test/globals.webdriverio.js b/test/globals.webdriverio.js index 0d7bd4b..3b071f8 100644 --- a/test/globals.webdriverio.js +++ b/test/globals.webdriverio.js @@ -10,7 +10,6 @@ global.selenium_url = argv.SELENIUM; global._projectdir = path.join(__dirname, '..', '..'); global.product_id = new Date().getTime(); global.new_customer_email = 'pub' + date_time + '@prestashop.com'; -global.module_tech_name_googleAnalytics = 'ps_googleanalytics'; global.module_tech_name_mailchimp = 'mailchimpintegration'; global.listNameInput = 'Test_list_MailChimp' + date_time; module.exports = { @@ -192,7 +191,7 @@ module.exports = { googleanalytics_submit_btn: '//*[@id="configuration_form_submit_btn"]', account_id_green_block: '//*[@id="content"]/div[6]/div[@class="module_confirmation conf confirm alert alert-success"]', user_id_green_block: '//*[@id="content"]/div[7]/div[@class="module_confirmation conf confirm alert alert-success"]', - creat_account_link: '//*[@id="google_analytics_content"]/div/div[2]/p[2]/b/a' + create_account_link: '//*[@id="google_analytics_content"]/div/div[2]/p[2]/b/a' } }, //FO From 370579d6a79759e91f59d71e1835d94a6b5a1706 Mon Sep 17 00:00:00 2001 From: sallemiines Date: Thu, 2 Nov 2017 11:54:15 +0100 Subject: [PATCH 4/4] Change email --- test/common.webdriverio.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/common.webdriverio.js b/test/common.webdriverio.js index fc13753..4279f1d 100644 --- a/test/common.webdriverio.js +++ b/test/common.webdriverio.js @@ -40,7 +40,7 @@ function initCommands(client) { return client .url('https://' + URL + '/backoffice/') .waitForExist(this.selector.BO.LoginPage.login_input, 90000) - .setValue(this.selector.BO.LoginPage.login_input, 'testmodule@prestashop.com') + .setValue(this.selector.BO.LoginPage.login_input,'remi.gaillard@prestashop.com') .setValue(this.selector.BO.LoginPage.password_input, 'abcd1234') .click(this.selector.BO.LoginPage.login_button) .waitForExist(this.selector.BO.Common.menu, 90000)