Skip to content

Commit

Permalink
Merge pull request #52 from ronny17/main
Browse files Browse the repository at this point in the history
Added Uniparma login module
  • Loading branch information
kylon authored Oct 19, 2022
2 parents 3a86617 + a0f9f80 commit feb5f30
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 1 deletion.
58 changes: 58 additions & 0 deletions sharedown/loginModules/UniParma.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/**
* This file is part of the Sharedown (https://github.com/kylon/Sharedown).
* Copyright (c) 2021 Kylon.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
"use strict";

const basic = require('./Basic');

class UniParma extends basic.BasicLogin {
constructor() {
super();
this.registerField('Email', basic.InputType.Text, 'Email provied by your university');
this.registerField('Password', basic.InputType.Password);
}

async doLogin(puppeteerPage, loginData) {
await puppeteerPage.waitForNavigation({waitUntil: 'networkidle2'});
await puppeteerPage.waitForSelector('input[type="email"]');
await puppeteerPage.focus('input[type="email"]');
await puppeteerPage.evaluate(() => document.querySelector('input[type="email"]').value = '');
await puppeteerPage.keyboard.type(loginData.field0);
await puppeteerPage.click('input[type="submit"]')
await puppeteerPage.waitForNavigation({waitUntil: 'networkidle2'});

await puppeteerPage.waitForSelector('input[id="userNameInput"]');
await puppeteerPage.focus('input[id="userNameInput"]');
await puppeteerPage.evaluate(() => document.querySelector('input[id="userNameInput"]').value = '');
await puppeteerPage.keyboard.type(loginData.field0);

await puppeteerPage.waitForSelector('input[id="passwordInput"]');
await puppeteerPage.focus('input[id="passwordInput"]');
await puppeteerPage.evaluate(() => document.querySelector('input[id="passwordInput"]').value = '');
await puppeteerPage.keyboard.type(loginData.field1);

await puppeteerPage.click('span[id="submitButton"]');
await puppeteerPage.waitForNavigation({waitUntil: 'networkidle2'});

if ((await puppeteerPage.$('input[id="idBtn_Back"]')) !== null) {
await puppeteerPage.waitForSelector('input[id="idBtn_Back"]', {timeout: 6000});
await puppeteerPage.focus('input[id="idBtn_Back"]');
await puppeteerPage.click('input[id="idBtn_Back"]');
}
}
}

module.exports = UniParma;
7 changes: 6 additions & 1 deletion sharedown/loginModules/loginModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,16 @@ const basic = require('./Basic');
const simpleUniversity = require('./SimpleUniversity');
const simpleUniversity365 = require('./SimpleUniversity365');
const unina = require('./Unina');
const uniparma = require('./UniParma')

class LoginModule {
// Sharedown UI module label
#modules = [
'Basic - Manual login',
'University [Simple]',
'University [MS 365]',
'Unina'
'Unina',
'UniParma'
];
#active;

Expand All @@ -48,6 +50,9 @@ class LoginModule {
case 3:
this.#active = new unina();
break;
case 4:
this.#active = new uniparma();
break;
default:
this.#active = new basic.BasicLogin();
break;
Expand Down

0 comments on commit feb5f30

Please sign in to comment.