Skip to content

Instantly share code, notes, and snippets.

@chippers
Created August 17, 2021 03:54
Show Gist options
  • Save chippers/db4305dac38e53399ee6775d6380b31a to your computer and use it in GitHub Desktop.
Save chippers/db4305dac38e53399ee6775d6380b31a to your computer and use it in GitHub Desktop.
simple https://github.com/tauri-apps/wry webdriver testing scripts
;(async () => {
const browser = await require('webdriverio').remote({
capabilities: {
"webkitgtk:browserOptions": {
binary: process.argv.slice(2)[0]
}
}
});
await browser.url("https://github.com");
const header = await browser.$("body > h1");
const headerText = await header.getText();
console.log(`original header text: ${headerText}`);
const checks = await browser.$$("tr > td:nth-child(2)");
const compat = {
good: 0,
bad: 0,
};
for (const check of checks) {
const text = await check.getText();
if (text.trim() === "✔") {
compat.good++
} else {
compat.bad++
}
}
await browser.closeWindow();
console.log(`compatibility: good ${compat.good} | bad ${compat.bad}`);
})()
;(async () => {
const browser = await require('webdriverio').remote({
capabilities: {
"tauri:options": {
application: process.argv.slice(2)[0]
}
}
});
const mainWindow = await browser.getWindowHandle();
const checkRodaRoraDa = async () => {
let windows = await browser.getWindowHandles();
if (windows.length < 2) {
setTimeout(checkRodaRoraDa, 100)
} else {
const newWindow = windows.filter(w => w !== mainWindow).pop();
await browser.switchToWindow(newWindow);
const img = await browser.$("body > img");
console.log(await img.getAttribute("src"))
await browser.deleteSession();
}
};
await checkRodaRoraDa();
})()//"RODA RORA DA"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment