NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

const puppeteer = require('puppeteer');
const {writeHtml} = require('./fileWriter');
class Navigator {

constructor(required_details) {
this.url = required_details.url
this.uname = required_details.uname;
this.pwd = required_details.pwd;
this.baseUrl = required_details.baseUrl;
this.elements = ['#username', '#password', 'button[type="submit"]'];
}

checkArgs() {
if (!this.uname || !this.pwd) {
throw new Error('UNAME OR PWD NOT ENTERED');
}
}
async perform_login() {
await this.page.waitForSelector(this.elements[1]);
await this.page.type(this.elements[0], this.uname, {
delay: 50
});
await this.page.type(this.elements[1], this.pwd, {
delay: 50
});
await this.page.click(this.elements[2]);
await Promise.race([this.page.waitForNavigation({
waitUntil: 'networkidle0'
}), this.page.waitForTimeout(10000)]);
}

async naviagte_to_profile() {
const profileElements = [".infotextdiv", "#id____UID7", ".infotextdiv"];
const profileUrl = this.baseUrl + "/prodssb/bwskgstu.P_StuInfo";
await this.page.goto(profileUrl, {
timeout: 20000,
waitUntil: 'load'
});
await this.page.waitForSelector(profileElements[0]);
await this.page.click(profileElements[1]);
await this.page.waitForSelector(profileElements[2]);
console.log("Profile load successfully");
const websiteContent = await this.page.content();
return websiteContent;
}

async is_login_page() {
return await this.page.evaluate((unameSelector, pwdSelector) => {
if (document.querySelector(unameSelector) || document.querySelector(pwdSelector)) {
return true;
}
return false;
}, this.elements[0], this.elements[1]);
}

async navigate_transcript_report() {
const transUrl = this.baseUrl + '/prodssb/bwskotrn.P_ViewTermTran';
const transElements = ["#levl_id", "select#type_id", '#id____UID7', '.datadisplaytable']
await this.page.goto(transUrl, {
timeout: 20000,
waitUntil: 'load'
});
await this.page.waitForSelector(transElements[0]);
var dropdowns = await this.page.$$eval("select#type_id option", all => all.map(a => a.value));
await console.log(dropdowns);
var i = 0;
var contents=[]
for (i; i < dropdowns.length - 1; i++) {
await this.select_transcript(transElements,dropdowns,i);
await this.store_content(contents);
await this.page.goBack();
await this.page.waitForSelector(transElements[0]);
}
await this.select_transcript(transElements,dropdowns,i);
await this.store_content(contents);
return contents
}
async store_content(contents){
const websiteContent = await this.page.content();
contents.push(websiteContent);
}

async select_transcript(transElements,dropdowns,i){
await this.page.select(transElements[1], dropdowns[i]);
await this.page.waitForTimeout(2000);
await this.page.click(transElements[2]);
await this.page.waitForSelector(transElements[3]);
}

async create_browser() {
const browser = await puppeteer.launch({
headless: false,
args: ['--start-maximized'],
defaultViewport: null,
});
return browser;
}

async create_page(browser) {
this.page = await browser.newPage();
}

async navigate_to_login_page() {
await this.page.goto(this.url, {
timeout: 20000,
waitUntil: 'load'
});
if (!await this.is_login_page()) {
throw new Error('not a login page');
}
}

async store_content_profile(htmlText){
writeHtml(htmlText, 'profile2.html');
}
async store_content_transcript(contents){

for(var i=0;i<contents.length;i++){
writeHtml(contents[i], `trans${i}.html`);
}

}

async run() {
const browser=await this.create_browser()
await this.create_page(browser);
await this.navigate_to_login_page()
await this.perform_login()
if (await this.is_login_page()) {
throw new Error('Incorrect Credentials');
}
let content = await this.naviagte_to_profile();
if(!content){
throw new Error('There is some issues in profile navigation');
}
this.store_content_profile(content); //

let contents = await this.navigate_transcript_report();
if(!contents){
throw new Error('There is some issues in profile navigation');
}
this.store_content_transcript(contents); //
}


async init() {
try {
this.checkArgs();
} catch (e) {
console.log(e.message);
}
}
}

(async function () {

const get_required_details= () => ({
url:"https://banner.aws.valenciacollege.edu/ssomanager/c/SSB",
uname:process.argv[2],
pwd:process.argv[3],
baseUrl:"https://banner.aws.valenciacollege.edu"
})
const required_details=get_required_details();
try {
let navigator = new Navigator(required_details);
await navigator.init(); //validation
await navigator.run();
} catch (e) {
console.error(e);
}

})();
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.