accept terms when joining

This commit is contained in:
Bruno Windels 2018-07-10 19:26:47 +02:00
parent 9c5e43a693
commit 9a2d32e642
3 changed files with 36 additions and 2 deletions

View file

@ -87,6 +87,23 @@ async function waitAndQuerySelector(page, selector, timeout = 500) {
return await page.$(selector);
}
function waitForNewPage(timeout = 500) {
return new Promise((resolve, reject) => {
const timeoutHandle = setTimeout(() => {
browser.removeEventListener('targetcreated', callback);
reject(new Error(`timeout of ${timeout}ms for waitForNewPage elapsed`));
}, timeout);
const callback = async (target) => {
clearTimeout(timeoutHandle);
const page = await target.page();
resolve(page);
};
browser.once('targetcreated', callback);
});
}
// other helpers
function randomInt(max) {
@ -110,6 +127,7 @@ module.exports = {
printElements,
replaceInputText,
waitAndQuerySelector,
waitForNewPage,
randomInt,
riotUrl,
delay,