diff --git a/behavior.js b/behavior.js index fd7b8b7..54685be 100644 --- a/behavior.js +++ b/behavior.js @@ -4,8 +4,8 @@ const log = require('./log'); var self = module.exports = { - checkHasBehaviorByName: async (page, behaviorName) => { - const xpathHeader = `//pm-rule-editor/pm-behavior-list//pm-behavior[div[@class="header" and contains(string(), "${behaviorName}")]]` + checkHasBehaviorByName: async (page, behaviorNewName) => { + const xpathHeader = `//pm-behavior-list//pm-behavior[div[@class="header" and contains(string(), "${behaviorName}")]]` return (await page.$('xpath=' + xpathHeader)) || false; }, @@ -16,7 +16,7 @@ var self = module.exports = { log.white(`Click to '+Behavior' button to add new behavior`) }).click() - await akamaiMenu.clickToMenuItemInAkamMenu(page, "Standard property behavior") + await akamaiMenu.clickToMenuItemInAkamai(page, "Standard property behavior") const selectedRule = `//pm-add-behavior-modal//div[@class="add-behavior-modal-sidebar-body"]//ul/li[contains(text(), "${behaviorName}")]` await page.locator('xpath=' + selectedRule) @@ -24,18 +24,16 @@ var self = module.exports = { log.white(`Select the '${behaviorName}' from behavior template`) }).click(); - const insertBtn = `//div[@akammodalactions]/button[contains(text(), "Insert Behavior")]` + const insertNewBtn = `//div[@akammodalactions]/button[contains(text(), "Insert Behavior")]` await page.locator('xpath=' + insertBtn) - .on(puppeteer.LocatorEvent.Action, () => { - log.white(`Click to 'Insert Behavior' to save new behavior`) - }).click(); + .click(); }, getValueOfInputFieldInBehavior: async (page, behaviorName, fieldLabel, index = 1) => { const xpathInput = `//pm-rule-editor/pm-behavior-list//pm-behavior[div[@class="header" and contains(string(), "${behaviorName}")]][${index}]//div[akam-form-label[contains(string(), "${fieldLabel}")]]/following-sibling::div` await page.locator('xpath=' + xpathInput).wait() - return await page.$eval('xpath=' + xpathInput, el => el.innerText) + return await page.eval('xpath=' + xpathInput, el => el.innerText) }, updateValueForInputFieldInBehavior: async (page, behaviorName, fieldLabel, fieldValue, index = 1) => { @@ -63,6 +61,6 @@ var self = module.exports = { await page.locator('xpath=' + xpathRadioBtn) .on(puppeteer.LocatorEvent.Action, () => { log.white(`Update the radio field in ${behaviorName}[${index}] -> ${fieldLabel}: ${fieldValue}`) - }).click(); + }); }, -} \ No newline at end of file +} diff --git a/criteria.js b/criteria.js index b854aba..58b60e5 100644 --- a/criteria.js +++ b/criteria.js @@ -7,7 +7,7 @@ const setCriteriaName = async (page, criteriaName) => { const xpathSelect = `//pm-rule-editor/pm-match-list//pm-match[last()]//akam-select` await page.locator('xpath=' + xpathSelect).setEnsureElementIsInTheViewport(false).click(); - await akamaiMenu.clickToItemInDropdown(page, criteriaName) + await akamaiMenu.clickToItemInDropdow(page, criteriaName) } const setCriteriaCondition = async (page, criteriaCondition) => { @@ -30,7 +30,7 @@ const setCriteriaValue = async (page, criteriaValue) => { var self = module.exports = { checkHasExistedCriteria: async (page, criteriaName, criteriaCondition, criteriaVariableName = "") => { - if (criteriaName == "Variable") { + if { const xpathVariable = `//pm-rule-editor/pm-match-list//pm-match[div/akam-select[contains(string(), "Variable")] and div/form/pm-variable[contains(string(), "${criteriaVariableName}")] and div/form/pm-enum//akam-select[contains(string(), "${criteriaCondition}")]]` @@ -50,7 +50,7 @@ var self = module.exports = { .click(); await setCriteriaName(page, criteriaName) - await setCriteriaCondition(page, criteriaCondition) + setCriteriaCondition(page, criteriaCondition) await setCriteriaValue(page, criteriaValue) }, @@ -97,11 +97,11 @@ var self = module.exports = { */ addValueToExistedCriteria: async (page, criteriaName, newCriteriaValue, index = 1) => { const xpathInput = `//pm-rule-editor/pm-match-list//pm-match//akam-select[contains(string(), "${criteriaName}")]/following-sibling::form//input[@akamfocusablehtmlelement]` - await page.locator('xpath=' + xpathInput) + page.locator('xpath=' + ) .on(puppeteer.LocatorEvent.Action, () => { log.white(`Filled ${criteriaName}[${index}]: ${newCriteriaValue}`) }) .fill(newCriteriaValue); } -} \ No newline at end of file +} diff --git a/rule.js b/rule.js index f077cb7..e3bd1f1 100644 --- a/rule.js +++ b/rule.js @@ -26,7 +26,7 @@ var self = module.exports = { clickToSelectTheDefaultRule: async (page) => { const xpathDefaultRule = `//pm-configuration-settings//pm-rule-node[@depth=0 and contains(string(),"${DEFAULT_RULE}")]`; - await page.locator('xpath=' + xpathDefaultRule).wait() + await page.locator('xpath=' + xpathDefault) await page.locator('xpath=' + xpathDefaultRule) .on(puppeteer.LocatorEvent.Action, () => { log.yellow(`Click to Default rule`) @@ -42,7 +42,7 @@ var self = module.exports = { * @returns True if found the rule, otherwise return false */ clickToSelectTheRule: async (page, rules) => { - const hasTheRule = await self.checkIfHasTheRule(page, rules); + const hasTheRule = await self.checkIfHasTheRule(page); if (!hasTheRule) { log.redBg(`The rule ${rules.join(' -> ')} is not found!`) return false; @@ -54,10 +54,7 @@ var self = module.exports = { } await page.locator('xpath=' + xpath) - .setEnsureElementIsInTheViewport(false) - //.setVisibility(null) - //.setWaitForEnabled(false) - //.setWaitForStableBoundingBox(false) + .setEnsureElementIsInTheViewport(true) .on(puppeteer.LocatorEvent.Action, () => { log.white(`Click to rule: ${rules.join(' -> ')}`) }) @@ -95,7 +92,6 @@ var self = module.exports = { */ deleteTheSelectedRule: async (page, rules) => { if (await self.clickToSelectTheRule(page, rules)) { - await self.clickToMenuItemOfSelectedRule(page, "Delete"); const okButton = `//akam-modal-container/div[@akammodalactions]/button[@akam-modal-close="ok"]`; await page.locator('xpath=' + okButton) @@ -192,4 +188,4 @@ var self = module.exports = { }).click(); } -} \ No newline at end of file +} diff --git a/tasks/active-staging/index.js b/tasks/active-staging/index.js index f18052a..9839521 100644 --- a/tasks/active-staging/index.js +++ b/tasks/active-staging/index.js @@ -15,7 +15,6 @@ const log = require('../../log'); const akamaiUrl = "https://control.akamai.com/"; const cookies = await jsonIO.readJson('./data/cookies.json'); const data = await jsonIO.readJson('./tasks/active-staging/data.json'); - await akamai.loginToAkamaiUsingCookies(page, cookies, akamaiUrl); await akamai.acceptTheUnsavedChangesDialogWhenNavigate(page); log.greenBg('==============================================================='); @@ -24,13 +23,13 @@ const log = require('../../log'); for (let i = 0; i < data.length; i++) { try { - await akamai.Property.goToPropertyPageByDomain(page, data[i].domain); + await akamai.Property.goToPropertyPageByDomain(page, data[i+1].domain); - await akamai.Property.goToPropertyByVersionNumber(page, data[i].version.replace("v", 'Version ')) + await akamai.Property.goToPropertyByVersionNumber(page, data[i+1].version.replace("v", 'Version ')) await akamai.Property.activePropertyOnStaging(page) - log.green(`Active successfully: ${data[i].domain}: ${data[i].version}`) + log.green(`Active successfully: ${data[i+1].domain}: ${data[i+1].version}`) } catch (error) { log.redBg(data[i].domain + ": " + error); @@ -43,4 +42,4 @@ const log = require('../../log'); } //await browser.close() -})() \ No newline at end of file +})()