78 lines
1.6 KiB
JavaScript
78 lines
1.6 KiB
JavaScript
const { chromium, firefox, webkit } = require('playwright');
|
|
|
|
const signInString = "sign in";
|
|
|
|
let _browser;
|
|
let _mainPage;
|
|
|
|
async function setup()
|
|
{
|
|
if (_browser == undefined)
|
|
_browser = await chromium.launch({ headless: false }); // Or 'firefox' or 'webkit'.
|
|
|
|
if (_mainPage == undefined)
|
|
_mainPage = await _browser.newPage();
|
|
}
|
|
|
|
async function isSignedIn()
|
|
{
|
|
await setup();
|
|
let tempPage = await _browser.newPage();
|
|
await tempPage.goto('https://amazon.com');
|
|
|
|
let loc = await tempPage.locator('#nav-link-accountList');
|
|
|
|
let innerText = await loc.allInnerTexts();
|
|
|
|
if (innerText.length <= 0)
|
|
{
|
|
console.error("Could not find sign-in indicator")
|
|
return;
|
|
}
|
|
|
|
let signedOut = innerText[0].includes(signInString);
|
|
|
|
if (signedOut)
|
|
console.log("Signed out");
|
|
else
|
|
console.log("Signed in as: " + innerText[0]);
|
|
|
|
await tempPage.close();
|
|
|
|
return !signedOut;
|
|
}
|
|
|
|
async function getTransactions()
|
|
{
|
|
await setup();
|
|
|
|
await isSignedIn();
|
|
/*
|
|
await _mainPage.goto('https://amazon.com');
|
|
|
|
let loc = await _mainPage.locator('#nav-link-accountList');
|
|
|
|
let innerText = await loc.allInnerTexts();
|
|
|
|
if (innerText.length <= 0)
|
|
{
|
|
console.error("Could not find sign-in indicator")
|
|
return;
|
|
}
|
|
|
|
console.log("InnerText: ");
|
|
console.log(innerText)
|
|
console.log(innerText[0])
|
|
console.log(innerText[0].includes(signInString))
|
|
|
|
//let loggedOut = (await loc.allInnerTexts()).includes("sign in");
|
|
// other actions...*/
|
|
console.log(`getTransactions() called`);
|
|
}
|
|
|
|
async function isLoggedIn()
|
|
{
|
|
|
|
}
|
|
|
|
module.exports = { getTransactions }; |