From a52bf99bbf2d394685f92aa13b5bff438ff8ef0a Mon Sep 17 00:00:00 2001 From: eug-vs Date: Wed, 11 Nov 2020 00:47:40 +0300 Subject: refactor: move attendConference() to separate file --- src/attendConference.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/attendConference.js (limited to 'src/attendConference.js') diff --git a/src/attendConference.js b/src/attendConference.js new file mode 100644 index 0000000..b7f744f --- /dev/null +++ b/src/attendConference.js @@ -0,0 +1,21 @@ +const clickElementByXPath = (page, xPath) => page + .waitForXPath(xPath) + .then(item => item.click()); + +const attendConference = async page => { + // Join as "Listen only" + await clickElementByXPath(page, '//span[contains(text(),"Listen only")]'); + console.log('Joined the conference'); + + // Wait 5 seconds + await page.waitForTimeout(5000); + console.log('Time to leave!') + + // Leave audio and close the tab + await clickElementByXPath(page, '//button[contains(@aria-label,"Leave audio")]'); + await page.waitForTimeout(1500); + await page.close(); + console.log('Left the conference'); +}; + +module.exports = attendConference; -- cgit v1.2.3