Created
August 30, 2024 18:21
-
-
Save hoelzro/a95af8e206ce192e83471aaaf2f1ace5 to your computer and use it in GitHub Desktop.
Playwright test script for https://github.com/TiddlyWiki/TiddlyWiki5/issues/8551
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { chromium, firefox } = require('playwright'); | |
const child_process = require('child_process'); | |
const process = require('process'); | |
function sleep(ms) { | |
return new Promise(function(resolve) { | |
setTimeout(resolve, ms); | |
}); | |
} | |
async function main(url) { | |
if(!url.startsWith('http://') && !url.startsWith('https://')) { | |
url = `file:///${url}`; | |
} | |
url += '#ProblemTiddler'; | |
const browser = await firefox.launch({ | |
headless: false, | |
}); | |
const page = await browser.newPage(); | |
await page.goto(url); | |
await page.waitForSelector('.repro-search'); | |
await page.locator('.repro-search').focus(); | |
await sleep(1_000); | |
let keys = [ | |
'b', 'l', 'a', 'h', 'space', | |
'b', 'l', 'a', 'h', 'space', | |
'b', 'l', 'a', 'h' | |
]; | |
child_process.spawnSync('xdotool', ['key', '--delay', '75'].concat(keys)); | |
await sleep(1_000); | |
let searchValue = await page.locator('.repro-search').inputValue(); | |
await browser.close(); | |
return searchValue == 'blah blah blah'; | |
} | |
main(process.argv[2]).then(function(res) { | |
process.exit(res ? 0 : 1); | |
}, function(err) { | |
console.error(err); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment