NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

/* jshint esversion: 8 */
/* istanbul ignore next */
const EmploymentNavigator = require('../employment.navigator');
const logger = require('../../lib/common/log').logger;
const CustomMFAHandler = require('../mfa/emp_21dhqlDb96sgb3kjdDLqI4GAQBY.custom.handler');
const CommonUtils = require('../../lib/utils/common-utils');
const Controller = require('../../lib/controller');
const PuppeteerHelper = require('../../lib/helper/puppeteer.helper');
const DownloadUtils = require('../../lib/utils/download-utils');
const ItemIterator = require('../../lib/iterator/item-iterator');
const ExtractorClassifier = require('../../lib/extractor/extractor-classifier');
const PuppeteerUtils = require('../../lib/utils/puppeteer-utils');
const SUPPORTED_ITEM_TYPE = require('../../lib/common/constants').supportedItemTypes;

/**
* UKG (UltiPro) - Boeing
*/
class Emp_21dhqlDb96sgb3kjdDLqI4GAQBY extends EmploymentNavigator {

constructor(session_id) {
super(session_id);
this.elements = ['input[name="username"]', 'input[type="password"]', 'input[name="sms"], input[id="sms_click"]'];
}

async execute_pre_login(page) {
logger.debug('Emp_21dhqlDb96sgb3kjdDLqI4GAQBY -> execute_pre_login -> started');
await this.ph.waitForSelector(this.elements[1], page, {
timeout: 30000,
visible: false
});
}

async is_login_page(page) {
logger.debug('Emp_21dhqlDb96sgb3kjdDLqI4GAQBY -> is_login_page - started');
let is_username = await this.ph.isElementExist(this.elements[0], page);
let is_password = await this.ph.isElementExist(this.elements[1], page);
let is_mfa = await this.ph.isElementExist(this.elements[2], page);

logger.info(`Emp_21dhqlDb96sgb3kjdDLqI4GAQBY -> is_login_page -> is_username - ${is_username}, is_password - ${is_password}, is_mfa - ${is_mfa}`);
if (is_mfa) {
return false;
}
return (is_username || is_password);
}

async do_login(page, username, password) {
logger.debug('Emp_21dhqlDb96sgb3kjdDLqI4GAQBY -> do_login - started');
if (!CommonUtils.isNumber(username))
return;
await this.ph.fillElementValue(this.elements[0], username, page);
await this.ph.fillElementValue(this.elements[1], password, page);
await this.ph.pressEnter(this.elements[1], page);
await this.ph.once(page, 'load');
}

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

async navigate_to_employment_profile(page) {
logger.debug('Emp_21dhqlDb96sgb3kjdDLqI4GAQBY -> navigate_to_employment_profile - started');

const elements = ['div[data-automation-id*="profile_link"]', 'span[title="Summary"]'];
const page_url = 'https://www.myworkday.com/boeing';

//Navigate to home page
await this.ph.goto(page_url, page, ['load'], 15000);

//Click on Profile
await this.ph.waitForSelector(elements[0], page, {
visible: false,
timeout: 15000
});
await this.ph.performHiddenClick(elements[0], page);

//Wait for "Summary" tab
await this.ph.waitForSelector(elements[1], page);

return page;
}

async navigate_to_paystub_file(page) {
logger.debug('Emp_21dhqlDb96sgb3kjdDLqI4GAQBY -> navigate_to_paystub_file - started');

const elements = ['select[id="cboHistoryDates"]'];
const page_url = 'https://my-ext.boeing.com/mbx/server.pt#PaycheckInformationDeductionsTaxes';

await this.ph.goto(page_url, page, ['load'], 15000);
await this.ph.waitForSelector(elements[0],page);

return page;
}

async get_iterator(page, type) {
if (type === SUPPORTED_ITEM_TYPE.paystub_file) {
return new Emp_21dhqlDb96sgb3kjdDLqI4GAQBY_Paystub_Iterator(page, this.session_id);
}
return await super.get_iterator(page, type);
}

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

class Emp_21dhqlDb96sgb3kjdDLqI4GAQBY_Paystub_Iterator extends ItemIterator {

constructor(page, session_id) {
super(page);
this.elements = ['select[id="cboHistoryDates"]','a[href*="pdf"]'];
this.session_id = session_id;
this.session = global.session_mgr.get_session(session_id);
}

async init() {
this.pu = new PuppeteerUtils();
this.ph = new PuppeteerHelper(this.page);
this.paystubs_urls = await this.getPaystubLinks(this.page, this.elements[0]);

this.num_of_items = this.paystubs_urls.length;

logger.info(`Paystubs links => ${this.paystubs_urls}`);

if (this.num_of_items === 0) {
throw Controller.getError('general', 'notAvailable', SUPPORTED_ITEM_TYPE.paystub_file);
}

logger.info(`Total Paystubs types => ${this.num_of_items}`);

await this.ph.set_pdf_download(this.session, true);

this.du = new DownloadUtils();
this.downloadPath = this.du.getDownloadPath(this.session_id);
await this.du.createDownloadDir(this.session_id);
await this.ph.downloadFileInitializer(this.downloadPath, this.page);
}

async removeDownloadedFiles() {
if (this.index > 0 && (this.num_of_items > this.index)) {
let files = await this.du.getDownloadFilesPath(this.session_id);
if (files.length > 0) {
await this.du.emptyDownloadDir(this.session_id);
}
}
}

async next() {
logger.info(`Emp_21dhqlDb96sgb3kjdDLqI4GAQBY_Paystub_Iterator -> next -- index -> ${this.index}`);
await this.removeDownloadedFiles();

await this.ph.goto(this.paystubs_urls[this.index], this.page, ['load']);

const errRegexList = ['We are unable to retrieve required identifying information for you at this time'];
const frame = await this.ph.getFrameByIdOrName('videoMirror', this.page);

// skip error page
if(frame && await this.ph.searchError(errRegexList, frame)) {
await this.pu.debugger(this.page, this.session_id);
return null;
}

// Click on pdf download
try {
await this.ph.waitForSelector(this.elements[1],this.page, {timeout: 15000});
await this.ph.performClick(this.elements[1],this.page);
} catch(e) {
logger.warn(e);
await this.ph.waitForSelector(this.elements[1],this.page, {timeout: 15000,visible:false});
await this.ph.performHiddenClick(this.elements[1],this.page);
}

let files = await this.du.getDownloadFilesPath(this.session_id);
if (files.length === 0) {
throw new Error(`File is not available in the download path for -> index -> ${this.index}`);
}
this.session.extract_file_path = files[0];
logger.debug(`session.extract_path => ${this.session.extract_file_path}`);

this.index++;
return this.page;
}

async getPaystubLinks(page, selector) {
logger.info('Emp_21dhqlDb96sgb3kjdDLqI4GAQBY_Paystub_Iterator -> getPaystubLinks - started');

const options = await this.ph.getSelectOptions(selector,page);

return options.map(({value}) => `https://my-ext.boeing.com/mbx/TotalAccessPrint.pdf?appid=23&cboHistoryDatesSELECTED=${value.trim()}`);
}
}

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