Conduit is a simple, fast and reliable chat server powered by Matrix https://conduit.rs
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
65 lines
2.6 KiB
65 lines
2.6 KiB
|
5 years ago
|
const puppeteer = require('puppeteer');
|
||
|
|
|
||
|
|
run().then(() => console.log('Done')).catch(_error => process.exit(111));
|
||
|
|
|
||
|
|
async function run() {
|
||
|
|
|
||
|
|
const username = "testuser" + String(Math.floor(Math.random()*100000));
|
||
|
|
const password = "testpassword" + String(Math.floor(Math.random()*100000));
|
||
|
|
console.debug("Testuser for this run:\n User: "+username+"\n Password: "+password);
|
||
|
|
|
||
|
|
const browser = await puppeteer.launch({headless: true});
|
||
|
|
|
||
|
|
const page = await browser.newPage();
|
||
|
|
await page.goto('https://app.element.io/');
|
||
|
|
|
||
|
|
console.debug("Click [Create Account] button");
|
||
|
|
await page.waitForSelector('a.mx_ButtonCreateAccount');
|
||
|
|
await page.click('a.mx_ButtonCreateAccount');
|
||
|
|
|
||
|
|
// The webapp should have loaded right now, if anything takes more than 5 seconds, something probably broke
|
||
|
|
page.setDefaultTimeout(5000);
|
||
|
|
|
||
|
|
console.debug("Click [Edit] to switch homeserver");
|
||
|
|
await page.waitForSelector('div.mx_ServerPicker_change');
|
||
|
|
await page.click('div.mx_ServerPicker_change');
|
||
|
|
|
||
|
|
console.debug("Type in local homeserver url");
|
||
|
|
await page.waitForSelector('input#mx_homeserverInput');
|
||
|
|
await page.click('input#mx_homeserverInput');
|
||
|
|
await page.click('input#mx_homeserverInput');
|
||
|
|
await page.keyboard.type('http://localhost:6167');
|
||
|
|
|
||
|
|
console.debug("[Continue] with changed homeserver");
|
||
|
|
await page.waitForSelector("div.mx_ServerPickerDialog_continue");
|
||
|
|
await page.click('div.mx_ServerPickerDialog_continue');
|
||
|
|
|
||
|
|
console.debug("Type in username");
|
||
|
|
await page.waitForSelector("input#mx_RegistrationForm_username");
|
||
|
|
await page.click('input#mx_RegistrationForm_username');
|
||
|
|
await page.keyboard.type(username);
|
||
|
|
|
||
|
|
console.debug("Type in password");
|
||
|
|
await page.waitForSelector("input#mx_RegistrationForm_password");
|
||
|
|
await page.click('input#mx_RegistrationForm_password');
|
||
|
|
await page.keyboard.type(password);
|
||
|
|
|
||
|
|
console.debug("Type in password again");
|
||
|
|
await page.waitForSelector("input#mx_RegistrationForm_passwordConfirm");
|
||
|
|
await page.click('input#mx_RegistrationForm_passwordConfirm');
|
||
|
|
await page.keyboard.type(password);
|
||
|
|
|
||
|
|
console.debug("Click on [Register] to finish the account creation");
|
||
|
|
await page.waitForSelector("input.mx_Login_submit");
|
||
|
|
await page.click('input.mx_Login_submit');
|
||
|
|
|
||
|
|
console.debug("Wait for chat window to show up");
|
||
|
|
await page.waitForSelector("div.mx_HomePage_default_buttons");
|
||
|
|
console.debug("Apparently the registration worked.");
|
||
|
|
|
||
|
|
// Wait 5 seconds
|
||
|
|
await new Promise(resolve => setTimeout(resolve, 5000));
|
||
|
|
|
||
|
|
// Close the browser and exit the script
|
||
|
|
await browser.close();
|
||
|
|
}
|