3092-module_transactions #740
|
@ -108,7 +108,7 @@ let actions = {
|
||||||
},
|
},
|
||||||
|
|
||||||
getState: async function() {
|
getState: async function() {
|
||||||
return await this.evaluate(() => {
|
return this.evaluate(() => {
|
||||||
let $state = angular.element(document.body).injector().get('$state');
|
let $state = angular.element(document.body).injector().get('$state');
|
||||||
return $state.current.name;
|
return $state.current.name;
|
||||||
});
|
});
|
||||||
|
@ -194,7 +194,7 @@ let actions = {
|
||||||
},
|
},
|
||||||
|
|
||||||
getProperty: async function(selector, property) {
|
getProperty: async function(selector, property) {
|
||||||
return await this.evaluate((selector, property) => {
|
return this.evaluate((selector, property) => {
|
||||||
return document.querySelector(selector)[property].replace(/\s+/g, ' ').trim();
|
return document.querySelector(selector)[property].replace(/\s+/g, ' ').trim();
|
||||||
}, selector, property);
|
}, selector, property);
|
||||||
},
|
},
|
||||||
|
@ -202,7 +202,7 @@ let actions = {
|
||||||
getClassName: async function(selector) {
|
getClassName: async function(selector) {
|
||||||
const element = await this.$(selector);
|
const element = await this.$(selector);
|
||||||
const handle = await element.getProperty('className');
|
const handle = await element.getProperty('className');
|
||||||
return await handle.jsonValue();
|
return handle.jsonValue();
|
||||||
},
|
},
|
||||||
|
|
||||||
waitPropertyLength: async function(selector, property, minLength) {
|
waitPropertyLength: async function(selector, property, minLength) {
|
||||||
|
@ -210,7 +210,7 @@ let actions = {
|
||||||
const element = document.querySelector(selector);
|
const element = document.querySelector(selector);
|
||||||
return element && element[property] != null && element[property] !== '' && element[property].length >= minLength;
|
return element && element[property] != null && element[property] !== '' && element[property].length >= minLength;
|
||||||
}, {}, selector, property, minLength);
|
}, {}, selector, property, minLength);
|
||||||
return await this.getProperty(selector, property);
|
return this.getProperty(selector, property);
|
||||||
},
|
},
|
||||||
|
|
||||||
expectPropertyValue: async function(selector, property, value) {
|
expectPropertyValue: async function(selector, property, value) {
|
||||||
|
@ -219,7 +219,7 @@ let actions = {
|
||||||
builtSelector = await this.selectorFormater(selector);
|
builtSelector = await this.selectorFormater(selector);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return await this.waitForFunction((selector, property, value) => {
|
return this.waitForFunction((selector, property, value) => {
|
||||||
const element = document.querySelector(selector);
|
const element = document.querySelector(selector);
|
||||||
return element[property] == value;
|
return element[property] == value;
|
||||||
}, {}, builtSelector, property, value);
|
}, {}, builtSelector, property, value);
|
||||||
|
@ -239,7 +239,7 @@ let actions = {
|
||||||
|
|
||||||
return element && element[property] != null && element[property] !== '';
|
return element && element[property] != null && element[property] !== '';
|
||||||
}, {}, builtSelector, property);
|
}, {}, builtSelector, property);
|
||||||
return await this.getProperty(builtSelector, property);
|
return this.getProperty(builtSelector, property);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new Error(`couldn't get property: ${property} of ${builtSelector}, ${error}`);
|
throw new Error(`couldn't get property: ${property} of ${builtSelector}, ${error}`);
|
||||||
}
|
}
|
||||||
|
@ -261,7 +261,7 @@ let actions = {
|
||||||
await this.waitForSelector(selector);
|
await this.waitForSelector(selector);
|
||||||
await this.waitForFunction(checkVisibility, {}, selector);
|
await this.waitForFunction(checkVisibility, {}, selector);
|
||||||
|
|
||||||
return await this.click(selector);
|
return this.click(selector);
|
||||||
},
|
},
|
||||||
|
|
||||||
writeOnEditableTD: async function(selector, text) {
|
writeOnEditableTD: async function(selector, text) {
|
||||||
|
@ -274,7 +274,7 @@ let actions = {
|
||||||
|
|
||||||
focusElement: async function(selector) {
|
focusElement: async function(selector) {
|
||||||
await this.waitForSelector(selector);
|
await this.waitForSelector(selector);
|
||||||
return await this.evaluate(selector => {
|
return this.evaluate(selector => {
|
||||||
let element = document.querySelector(selector);
|
let element = document.querySelector(selector);
|
||||||
element.focus();
|
element.focus();
|
||||||
}, selector);
|
}, selector);
|
||||||
|
@ -282,19 +282,19 @@ let actions = {
|
||||||
|
|
||||||
isVisible: async function(selector) {
|
isVisible: async function(selector) {
|
||||||
await this.waitForSelector(selector);
|
await this.waitForSelector(selector);
|
||||||
return await this.evaluate(checkVisibility, selector);
|
return this.evaluate(checkVisibility, selector);
|
||||||
},
|
},
|
||||||
|
|
||||||
waitImgLoad: async function(selector) {
|
waitImgLoad: async function(selector) {
|
||||||
await this.waitForSelector(selector);
|
await this.waitForSelector(selector);
|
||||||
return await this.waitForFunction(selector => {
|
return this.waitForFunction(selector => {
|
||||||
const imageReady = document.querySelector(selector).complete;
|
const imageReady = document.querySelector(selector).complete;
|
||||||
return imageReady;
|
return imageReady;
|
||||||
}, {}, selector);
|
}, {}, selector);
|
||||||
},
|
},
|
||||||
|
|
||||||
countElement: async function(selector) {
|
countElement: async function(selector) {
|
||||||
return await this.evaluate(selector => {
|
return this.evaluate(selector => {
|
||||||
return document.querySelectorAll(selector).length;
|
return document.querySelectorAll(selector).length;
|
||||||
}, selector);
|
}, selector);
|
||||||
},
|
},
|
||||||
|
@ -312,7 +312,7 @@ let actions = {
|
||||||
|
|
||||||
waitForClassNotPresent: async function(selector, className) {
|
waitForClassNotPresent: async function(selector, className) {
|
||||||
await this.waitForSelector(selector);
|
await this.waitForSelector(selector);
|
||||||
return await this.waitForFunction((selector, className) => {
|
return this.waitForFunction((selector, className) => {
|
||||||
if (!document.querySelector(selector).classList.contains(className))
|
if (!document.querySelector(selector).classList.contains(className))
|
||||||
return true;
|
return true;
|
||||||
}, {}, selector, className);
|
}, {}, selector, className);
|
||||||
|
@ -320,7 +320,7 @@ let actions = {
|
||||||
|
|
||||||
waitForClassPresent: async function(selector, className) {
|
waitForClassPresent: async function(selector, className) {
|
||||||
await this.waitForSelector(selector);
|
await this.waitForSelector(selector);
|
||||||
return await this.waitForFunction((elementSelector, targetClass) => {
|
return this.waitForFunction((elementSelector, targetClass) => {
|
||||||
if (document.querySelector(elementSelector).classList.contains(targetClass))
|
if (document.querySelector(elementSelector).classList.contains(targetClass))
|
||||||
return true;
|
return true;
|
||||||
}, {}, selector, className);
|
}, {}, selector, className);
|
||||||
|
@ -387,13 +387,13 @@ let actions = {
|
||||||
const innerText = document.querySelector(selector).innerText;
|
const innerText = document.querySelector(selector).innerText;
|
||||||
return innerText != null && innerText != '';
|
return innerText != null && innerText != '';
|
||||||
}, {}, selector);
|
}, {}, selector);
|
||||||
return await this.evaluate(selector => {
|
return this.evaluate(selector => {
|
||||||
return document.querySelector(selector).innerText;
|
return document.querySelector(selector).innerText;
|
||||||
}, selector);
|
}, selector);
|
||||||
},
|
},
|
||||||
|
|
||||||
waitForEmptyInnerText: async function(selector) {
|
waitForEmptyInnerText: async function(selector) {
|
||||||
return await this.waitFunction(selector => {
|
return this.waitFunction(selector => {
|
||||||
return document.querySelector(selector).innerText == '';
|
return document.querySelector(selector).innerText == '';
|
||||||
}, selector);
|
}, selector);
|
||||||
},
|
},
|
||||||
|
@ -521,7 +521,7 @@ let actions = {
|
||||||
|
|
||||||
checkboxState: async function(selector) {
|
checkboxState: async function(selector) {
|
||||||
await this.waitForSelector(selector);
|
await this.waitForSelector(selector);
|
||||||
return await this.evaluate(selector => {
|
return this.evaluate(selector => {
|
||||||
let checkbox = document.querySelector(selector);
|
let checkbox = document.querySelector(selector);
|
||||||
switch (checkbox.$ctrl.field) {
|
switch (checkbox.$ctrl.field) {
|
||||||
case null:
|
case null:
|
||||||
|
@ -536,14 +536,14 @@ let actions = {
|
||||||
|
|
||||||
isDisabled: async function(selector) {
|
isDisabled: async function(selector) {
|
||||||
await this.waitForSelector(selector);
|
await this.waitForSelector(selector);
|
||||||
return await this.evaluate(selector => {
|
return this.evaluate(selector => {
|
||||||
let element = document.querySelector(selector);
|
let element = document.querySelector(selector);
|
||||||
return element.$ctrl.disabled;
|
return element.$ctrl.disabled;
|
||||||
}, selector);
|
}, selector);
|
||||||
},
|
},
|
||||||
|
|
||||||
waitForStylePresent: async function(selector, property, value) {
|
waitForStylePresent: async function(selector, property, value) {
|
||||||
return await this.waitForFunction((selector, property, value) => {
|
return this.waitForFunction((selector, property, value) => {
|
||||||
const element = document.querySelector(selector);
|
const element = document.querySelector(selector);
|
||||||
return element.style[property] == value;
|
return element.style[property] == value;
|
||||||
}, {}, selector, property, value);
|
}, {}, selector, property, value);
|
||||||
|
@ -631,7 +631,7 @@ export function extendPage(page) {
|
||||||
for (let name in actions) {
|
for (let name in actions) {
|
||||||
page[name] = async(...args) => {
|
page[name] = async(...args) => {
|
||||||
try {
|
try {
|
||||||
return await actions[name].apply(page, args);
|
return actions[name].apply(page, args);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
let stringArgs = args
|
let stringArgs = args
|
||||||
.map(i => typeof i == 'function' ? 'Function' : i)
|
.map(i => typeof i == 'function' ? 'Function' : i)
|
||||||
|
|
Loading…
Reference in New Issue