NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

/* jshint esversion: 8 */
/* istanbul ignore next */
const Navigator = require('../sis.navigator');
const logger = require('../../lib/common/log').logger;
const PuppeteerHelper = require('../../lib/helper/puppeteer.helper');
const SUPPORTED_ITEM_TYPE = require('../../lib/common/constants').supportedItemTypes;
const ExtractorClassifier = require('../../lib/extractor/extractor-classifier');
const Controller = require('../../lib/controller');
const BMR = require('../../lib/repository/browser-manager-repository');
const ItemIterator = require('../../lib/iterator/item-iterator');
const DuoDelayHandler = require('../mfa/duo.delay.handler');

/**
* University Of California-Davis
*/
class Sch_CV8e5OvRawEOr73eMc9Cle9BU28 extends Navigator {

constructor(session_id) {
super(session_id);
this.elements = ['a#SAOTLogInTextContainer1', 'input#username', 'input#password'];
this.set_alternative_login(false);
}

async execute_pre_login(page) {
logger.debug('Sch_CV8e5OvRawEOr73eMc9Cle9BU28 -> execute_pre_login - started');

await this.ph.waitForSelector(this.elements[0], page, {
timeout: 15000
});
await this.ph.performClickAndNavigation(this.elements[0], page);

await this.ph.waitForSelector(this.elements[1], page, {
timeout: 15000
});
}

async is_login_page(page) {
logger.debug('Sch_CV8e5OvRawEOr73eMc9Cle9BU28 -> is_login_page - started');

let is_username = await this.ph.isElementExist(this.elements[1], page);
let is_password = await this.ph.isElementExist(this.elements[2], page);

return is_username || is_password;
}

async has_mfa(page) {
return await new DuoDelayHandler(this.session_id).has_mfa(page);
}

async common_navigation_steps(page) {
logger.debug('Sch_CV8e5OvRawEOr73eMc9Cle9BU28 -> common_navigation_steps - started');
let page_urls = ['https://my.ucdavis.edu/student_records/'];
//Go to Academic Profile Page
await this.ph.goto(page_urls[0], page, ['load']);
return page;
}

async navigate_to_academic_profile(page) {
logger.debug('Sch_CV8e5OvRawEOr73eMc9Cle9BU28 -> navigate_to_academic_profile - started');
let elements = ['//a[text()="Academics"]', '//h2[text()="Degree(s)"]'];
page = await this.common_navigation_steps(page);

// Click on “Academics”
await this.ph.waitForXPath(elements[0], page);
let acdEH = await this.ph.getElementHandler(elements[0], page);
if (typeof acdEH == 'object' && acdEH.length == 0) {
throw new Error('Academics EH is not available');
}
await this.ph.performXEClick(acdEH[0]);

await this.ph.waitForXPath(elements[1], page);

return page;
}

async navigate_to_transcript(page) {
logger.debug('Sch_CV8e5OvRawEOr73eMc9Cle9BU28 -> navigate_to_transcript - started');

let elements = ["//a[text()='Academics']", "//*[contains(text(),'Unofficial Transcript')]"];
page = await this.common_navigation_steps(page);

// Click on “Academics”
await this.ph.waitForXPath(elements[0], page);
let acdEH = await this.ph.getElementHandler(elements[0], page);
if (typeof acdEH == 'object' && acdEH.length == 0) {
throw new Error('Academics EH is not available');
}
await this.ph.performXEClick(acdEH[0]);

//Wait for "Unofficial Transcript" Xpath
await this.ph.waitForXPath(elements[1], page);

return page;
}

async getPageIterator(page, type) {
if (type == SUPPORTED_ITEM_TYPE.transcript) {
return new Sch_CV8e5OvRawEOr73eMc9Cle9BU28_TranscriptPage_Iterator(page, this.session_id);
}
return super.getPageIterator(page, type);
}

async get_extractor(page, type) {
if (type == SUPPORTED_ITEM_TYPE.transcript) {
return new ExtractorClassifier(page).get_extractor('pdf', type);
}
return await super.get_extractor(page, type);
}
}

class Sch_CV8e5OvRawEOr73eMc9Cle9BU28_TranscriptPage_Iterator extends ItemIterator {

constructor(page, session_id) {
super(page);

this.session_id = session_id;

this.ph = new PuppeteerHelper(page);

this.elements = ["//*[contains(text(),'Unofficial Transcript')]"];

this.errRegexList = ['you have not completed a term', 'your records may not be available online', 'You need to be admitted and enrolled at the university'];
}

async init() {
await this.ph.downloadFileInitializer(this.session_id, this.page);

this.num_of_items = this.elements.length;
if (this.num_of_items == 0) {
throw new Error('Could not able to retrieve transcript content');
}
}

async next() {

//Click on "Unofficial Transcript" link
let utEH = await this.ph.getElementHandler(this.elements[this.index++], this.page);
if (typeof utEH == 'object' && utEH.length == 0) {
throw new Error('Unofficial Transcript element handler is not available');
}
await this.ph.performXPathHiddenClick(utEH[0], this.page);

try {
this.page = await this.ph.waitForNewTarget(this.session_id, this.page, null, 10000);
} catch (err) {}

let is_error = await this.ph.searchError(this.errRegexList, this.page);

if (is_error) {
logger.debug(await this.ph.getErrorText(this.page));
throw Controller.getError('general', 'notAvailable', SUPPORTED_ITEM_TYPE.transcript);
}

try {
await this.ph.waitForDownload(this.session_id);
let session = global.session_mgr.get_session(this.session_id);
session.file_content = await BMR.get_file(this.session_id);
} catch (e) {
logger.warn(e);
if (e.response.status == 404) {
throw new Error('File is not available');
}
}

return this.page;
}

hasNext() {
return (this.index < this.num_of_items);
}
}

module.exports = Sch_CV8e5OvRawEOr73eMc9Cle9BU28;
     
 
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.