Skip to content

Instantly share code, notes, and snippets.

@pjcalvo
Last active June 21, 2020 05:17
Show Gist options
  • Save pjcalvo/6875f07ec66c30ece5066330a8324840 to your computer and use it in GitHub Desktop.
Save pjcalvo/6875f07ec66c30ece5066330a8324840 to your computer and use it in GitHub Desktop.
const { remote } = require('webdriverio');
(async () => {
const browser = await remote({
logLevel: 'trace', capabilities: { browserName: 'chrome'}
})
await browser.url('http://zzzscore.com/1to50/en/?ts=1592666149743') // navigate
result = await browser.execute(function(){
for(i=1;i<26;i++){
var el = document.evaluate('//div[text()="@id"]'.replace('@id',i), document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null ).singleNodeValue;
el.dispatchEvent(new Event('tap', { 'bubbles': true }));
}
return "done";
})
// had to add here and loop twice for numbers on 25. Yes it is that fast that the event hasn't executed.
await browser.pause(100);
result = await browser.execute(function(){
for(i=26;i<51;i++){
var el = document.evaluate('//div[text()="@id"]'.replace('@id',i), document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null ).singleNodeValue;
el.dispatchEvent(new Event('tap', { 'bubbles': true }));
}
return "done";
})
var result = await browser.$('.level');
console.log(`The result is ${await result.getText()}`);
// leave the browser open to check the result
// await browser.deleteSession()
})().catch((e) => console.error(e))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment