-
Notifications
You must be signed in to change notification settings - Fork 6
/
getCode.js
26 lines (21 loc) · 910 Bytes
/
getCode.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
const { Builder, By, Key, until } = require('selenium-webdriver');
const sleep = (waitTimeInMs) => new Promise(resolve => setTimeout(resolve, waitTimeInMs));
const getInstCode = async function (domain, mailName, browser) {
const INST_CODE = 'https://email-fake.com/' + domain + '/' + mailName;
let code = "";
try {
await browser.executeScript('window.open("newURL");');
let tab = await browser.getAllWindowHandles();
await browser.switchTo().window(tab[1]);
await browser.get(INST_CODE);
await sleep(10000);
code = await browser.findElement(By.xpath("//*[@id='email-table']/div[2]/div[1]/div/h1")).getText();
console.log(code)
code = code.replace("is your Instagram code", "");
await browser.switchTo().window(tab[0]);
} catch (error) {
} finally {
return code;
}
};
module.exports = { getInstCode };