From 06af5b3f224cf068ce9e12eb3edb6e5e943a4d6b Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Tue, 17 Sep 2019 11:40:24 +0200 Subject: [PATCH] look for a change (HS) link in the registration but don't fail if its not there --- src/session.js | 3 +-- src/usecases/signup.js | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/session.js b/src/session.js index f91bce5a46..d3c26c07e4 100644 --- a/src/session.js +++ b/src/session.js @@ -117,8 +117,7 @@ module.exports = class RiotSession { await input.type(text); } - query(selector) { - const timeout = DEFAULT_TIMEOUT; + query(selector, timeout = DEFAULT_TIMEOUT) { return this.page.waitForSelector(selector, {visible: true, timeout}); } diff --git a/src/usecases/signup.js b/src/usecases/signup.js index 64cf52668c..b6fad58260 100644 --- a/src/usecases/signup.js +++ b/src/usecases/signup.js @@ -19,10 +19,23 @@ const assert = require('assert'); module.exports = async function signup(session, username, password, homeserver) { session.log.step("signs up"); await session.goto(session.url('/#/register')); - // change the homeserver by clicking the "Change" link. + // change the homeserver by clicking the advanced section if (homeserver) { const advancedButton = await session.query('.mx_ServerTypeSelector_type_Advanced'); await advancedButton.click(); + + // depending on what HS is configured as the default, the advanced registration + // goes the HS/IS entry directly (for matrix.org) or takes you to the user/pass entry (not matrix.org). + // To work with both, we look for the "Change" link in the user/pass entry but don't fail when we can't find it + // As this link should be visible immediately, and to not slow down the case where it isn't present, + // pick a lower timeout of 5000ms + try { + const changeHsField = await session.query('.mx_AuthBody_editServerDetails', 5000); + if (changeHsField) { + await changeHsField.click(); + } + } catch (err) {} + const hsInputField = await session.query('#mx_ServerConfig_hsUrl'); await session.replaceInputText(hsInputField, homeserver); const nextButton = await session.query('.mx_Login_submit');