Skip to content
Permalink
Browse files

- ActionWaitForElement - Renamed to make it consistent, added tests

:goose:
  • Loading branch information...
maZahaca committed Nov 17, 2018
1 parent 90a1302 commit f91a852cca6885d795918ab5baaad935839cd640
@@ -5,7 +5,7 @@

const ActionWait = require('./ActionWait');

class ActionWaitElement extends ActionWait {
class ActionWaitForElement extends ActionWait {
async perform() {
this.log('._waitElement() ' + this._selector);
return this.wait(/* istanbul ignore next */ function (selector) {
@@ -16,5 +16,5 @@ class ActionWaitElement extends ActionWait {
}
}

module.exports = ActionWaitElement;
module.exports = ActionWaitForElement;

@@ -8,7 +8,8 @@ const actionsMap = {
mouseup: require('./ActionMouseUp'),
mouseUp: require('./ActionMouseUp'),
changeElement: require('./ActionChangeElement'),
wait: require('./ActionWaitElement'),
wait: require('./ActionWaitForElement'),
waitForElement: require('./ActionWaitForElement'),
waitForVisible: require('./ActionWaitForVisible'),
waitForPattern: require('./ActionWaitForPattern'),
waitForPage: require('./ActionWaitForPage'),
@@ -362,6 +362,39 @@ describe('Actions', () => {
});
});

describe('ActionWaitForElement', () => {
test('perform', async () => {
setServerResponse({
html: `<a href="#">test</a>`,
fn: () => {
document.querySelector('a').addEventListener('click', ({ target }) => {
setTimeout(function () {
document.body.insertAdjacentHTML('beforeend', '<div>12345</div>');
}, 500);
});
}
});
const result = await parser.parse({
url,
actions: [
{
type: 'click',
scope: 'a',
waitFor: {
type: 'element',
scope: 'div',
},
},
],
rules: {
scope: 'div',
},
});

expect(result).toEqual('12345');
});
});

describe('ActionClickWithWaitForQuery', () => {
test('perform', async () => {
setServerResponse({

0 comments on commit f91a852

Please sign in to comment.
You can’t perform that action at this time.