NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

paystub_url = https://www.selfservice.us.randstad.com/psc/HRPROD/SELFSERVICE/HRMS/c/ROLE_EMPLOYEE.PY_IC_PAY_INQ.GBL
https://www.selfservice.us.randstad.com/psc/HRPROD/SELFSERVICE/HRMS/c/PY_EMPLOYEE_FL.PY_IC_PAY_INQ_FLU.GBL

profile_url = https://www.selfservice.us.randstad.com/psc/HRPROD/SELFSERVICE/HRMS/c/RNA_CUSTOM.RNA_EAPP_PERS_INFO.GBL
/HRCD_EMPLOYEE_FL.HRCD_PROFILE_FL.GBL
/STP_CUSTOM.STP_WF_JOB_SUMMARY.GBL


/* jshint esversion: 8 */
/* istanbul ignore next */
const EmploymentNavigator = require('../employment.navigator');
const logger = require('../../lib/common/log').logger;
const ItemIterator = require('../../lib/iterator/item-iterator');
const SUPPORTED_ITEM_TYPE = require('../../lib/common/constants').supportedItemTypes;
const Controller = require('../../lib/controller');
const ExtractorClassifier = require('../../lib/extractor/extractor-classifier');

/**
* Peoplesoft HCM
*/
class PeoplesoftHCM extends EmploymentNavigator {

async pre_navigate_to_item(page) {
logger.debug('PeoplesoftHCM -> pre_navigate_to_item - started');
this.paystub_iterator = 'type1';
return page;
}

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

const profile_url = this.profile_url || this.base_url + '/ROLE_EMPLOYEE.HR_EE_PERS_INFO.GBL';
const profile_elements = ['a[id*="EXPAND_LINK"], a[href*="EXPAND_LINK"], a[name*="EXPAND_LINK"]', '//*[text()="Original Start Date"] | //*[text()="Email Address"] | //*[contains(text(), "Start Date")] | //a[contains(@title, "Employee Information")] | //*[text()="Additional Information"] | //*[text()="Date of Birth"] | //*[contains(text(), "Employee Information")]'];

await this.ph.goto(profile_url, page, ['load'], 10000);

//Click on "Expand All" link
try {
await this.ph.waitForSelector(profile_elements[0], page);
await this.ph.performClick(profile_elements[0], page);
await Promise.race([this.ph.waitForResponse('ROLE_EMPLOYEE.HR_EE_PERS_INFO.GBL', page, 'include'), this.ph.waitFor(10000)]);
} catch (e) {
logger.debug(e);
}

//Wait for "Employee Information"
await this.ph.waitForXPath(profile_elements[1], page, {
visible: false,
timeout: 20000
});

return page;
}

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

const paystub_url = this.paystub_url || this.base_url + '/ROLE_EMPLOYEE.PY_IC_PAY_INQ.GBL';
const paystub_elements = ['a#PY_IC_PI_WRK_PAYCHECK_PB, a[href*="PY_IC_PI_WRK_PAYCHECK_PB"]', 'a[id*="viewall"], a[href*="viewall"]', 'a[id*="PAY_END"]'];
const errRegexList = ['There are no paychecks available for you to view'];

await this.ph.goto(paystub_url, page, ['load'], 10000);

try {
//Click on "View a Different Paycheck"
await this.ph.waitForSelector(paystub_elements[0], page);
await this.ph.performClickAndNavigation(paystub_elements[0], page, {
timeout: 10000,
waitUntil: 'load'
});
// this.paystub_iterator = 'type1';
// await this.ph.performClick(paystub_elements[0], page);
// await Promise.race([this.ph.waitForResponse('ROLE_EMPLOYEE.PY_IC_PAY_INQ.GBL', page, 'include'), this.ph.waitFor(5000)]);
// await this.ph.once(page, 'load'); //Wait for the page to load "View All" and all "paystub" links in the DOM.
} catch (e) {
logger.warn(e);
}

if (await this.ph.searchError(errRegexList, page)) {
this.session.auto_retrieved = true;
logger.warn(await this.ph.getErrorText(page));
throw Controller.getError('general', 'notAvailable', SUPPORTED_ITEM_TYPE.paystub_file);
}

if (await this.ph.searchError(['View All'], page)) { //Only click "View All" link if we are not seeing the whole list.
await this.execute_view_all_paystubs(page);
/* //Click on "View All"
await this.ph.waitForSelector(paystub_elements[1], page);
await this.ph.performHiddenClick(paystub_elements[1], page);
await Promise.race([this.ph.waitForResponse('ROLE_EMPLOYEE.PY_IC_PAY_INQ.GBL', page, 'include'), this.ph.waitFor(10000)]); */
}

//Wait for "View Paycheck" links
await this.ph.waitForSelector(paystub_elements[2], page);
logger.info(`PeoplesoftHCM -> navigate_to_paystub_file -> paystub_iterator - ${this.paystub_iterator}`);

return page;
}

async execute_view_all_paystubs(page) {
logger.info('PeoplesoftHCM -> execute_view_all_paystubs - started');
const elements = ['a[id*="viewall"], a[href*="viewall"]'];
await page.evaluate((selector) => {
let el = document.querySelector(selector);
if (el) {
let elHref = el.getAttribute('href');
eval(elHref);
}
}, elements[0]);
await this.ph.waitFor(5000); //Wait for the page to list all paystubs
}

async post_navigate_to_paystub_file(page) {
logger.debug('PeoplesoftHCM -> post_navigate_to_paystub_file - started');
let pages = await this.session.browser.pages();
logger.info(`PeoplesoftHCM -> post_navigate_to_paystub_file -> Total Browser Tabs - ${pages.length}`);
if (pages.length > 1) {
this.session.page = page = pages[page.length - 2];
await pages[pages.length - 1].close();
}
}

async get_iterator(page, type) {
if (type === SUPPORTED_ITEM_TYPE.paystub_file && this.paystub_iterator === 'type1') {
return new PeoplesoftHCM_Paystub_Iterator_Type1(page, this.session_id);
}
if (type === SUPPORTED_ITEM_TYPE.paystub_file && this.paystub_iterator === 'type2') {
return new PeoplesoftHCM_Paystub_Iterator_Type2(page, this.session_id);
}
return await super.get_iterator(page, type);
}

async get_extractor(page, type) {
if (type === SUPPORTED_ITEM_TYPE.paystub_file && !this.session.data.is_html_paystub) {
return new ExtractorClassifier(page).get_extractor('pdf', type);
}
return await super.get_extractor(page, type);
}
}

class PeoplesoftHCM_Paystub_Iterator_Type1 extends ItemIterator {

constructor(page, session_id) {
super(page);
this.session_id = session_id;
this.session = global.session_mgr.get_session(session_id);
this.elements = ['a#PY_IC_PI_WRK_PAYCHECK_PB, a[href*="PY_IC_PI_WRK_PAYCHECK_PB"]', 'a[id*="viewall"], a[href*="viewall"]', 'a[id*="PAY_END"]', 'a[id*="PRINT_ADVICE"], a[href*="PRINT_ADVICE"]', '//*[text()="YTD"] | //*[text()="Paycheck Summary"]'];
}

async init() {
this.paystubTypes = await this.get_paystubs(this.page);
if (this.paystubTypes.length === 0) {
throw Controller.getError('general', 'notAvailable', SUPPORTED_ITEM_TYPE.paystub_file);
}
logger.info(`PeoplesoftHCM_Paystub_Iterator_Type1 -> init -> Paystub Types => ${JSON.stringify(this.paystubTypes)}`);
this.num_of_items = this.paystubTypes.length;
logger.info(`PeoplesoftHCM_Paystub_Iterator_Type1 -> init -> Total Paystubs => ${this.num_of_items}`);
await this.log_total_paystubs(this.page);
}

async close_last_tab() {
let pages = await this.session.browser.pages();
logger.info(`PeoplesoftHCM_Paystub_Iterator_Type1 -> close_last_tab -> Total Browser Tabs - ${pages.length}`);
if (pages.length > 1) {
await pages[pages.length - 1].close();
}
}

async common_navigation_steps(page) {
logger.debug('PeoplesoftHCM_Paystub_Iterator_Type1 -> common_navigation_steps - started');

try { //"View a Different Paycheck" link will NOT available always
//Click on "View a Different Paycheck"
await this.ph.waitForSelector(this.elements[0], page, {
timeout: 5000,
visible: true
});
await this.ph.performClick(this.elements[0], page);
await Promise.race([this.ph.waitForResponse('ROLE_EMPLOYEE.PY_IC_PAY_INQ.GBL', page, 'include'), this.ph.waitFor(10000)]);
} catch (e) {
logger.debug(e);
}

if (await this.ph.searchError(['View All'], page) && await this.ph.isElementVisible(this.elements[1], page)) { //Only click "View All" link if we are not seeing the whole list.
//Click on "View All"
try {
await this.ph.waitForSelector(this.elements[1], page);
await this.ph.performHiddenClick(this.elements[1], page);
await Promise.race([this.ph.waitForResponse('ROLE_EMPLOYEE.PY_IC_PAY_INQ.GBL', page, 'include'), this.ph.waitFor(10000)]);
} catch (e) {
logger.warn(e);
}
}

try {
//Wait for "View Paycheck" links
await this.ph.waitForSelector(this.elements[2], page, {
timeout: 15000,
visible: true
});
} catch (e) {
logger.warn(e);
}

return page;
}

async next() {
logger.info(`PeoplesoftHCM_Paystub_Iterator_Type1 -> next -> index - ${this.index}`);
if (this.index > 0 && (this.num_of_items > this.index)) {
await this.close_last_tab();
this.page = await this.common_navigation_steps(this.page);
await this.ph.waitForSelector(this.paystubTypes[this.index], this.page);
}

//Click on every paystub link
await this.ph.performClick(this.paystubTypes[this.index++], this.page);
await Promise.race([this.ph.waitForResponse('ROLE_EMPLOYEE.PY_IC_PAY_INQ.GBL', this.page, 'include'), this.ph.waitFor(15000)]);
try { //Wait for "Print Advice" PDF link (This will open paystub in PDF format in new a tab)
await this.ph.waitForSelector(this.elements[3], this.page, {
timeout: 10000,
visible: true
});
} catch (e) {
logger.debug(e);
}
if (await this.ph.isElementExist(this.elements[3], this.page)) {
//Click on "Print Advice" PDF link
await this.ph.performClick(this.elements[3], this.page);
await Promise.race([this.ph.waitForResponse('ROLE_EMPLOYEE.PY_IC_PAY_INQ.GBL', this.page, 'include'), this.ph.waitFor(20000)]);

let targetPage;
try { // Note -> if Net Pay of a paystub is zero it will take more time to open the PDF.
targetPage = await this.ph.waitForNewTarget(this.session_id, this.page, null, 40000);
} catch (e) {
logger.warn(e);
logger.info(`PeoplesoftHCM_Paystub_Iterator_Type1 -> next -> Waiting for paycheck PDF failed for ${this.index - 1}`);
return null;
}
return targetPage;
} else {
logger.info(`PeoplesoftHCM_Paystub_Iterator_Type1 -> next -> Only HTML Paystub is available for index -> ${this.index - 1}`);
this.session.data.is_html_paystub = true;
await this.ph.waitForXPath(this.elements[4], this.page);
}
return this.page;
}

async get_paystubs(page) {
return await page.$$eval(this.elements[2], (elements) => {
return Array.from(elements).map(e => `a[id='${e.id}']`);
});
}

async log_total_paystubs(page) {
logger.debug('PeoplesoftHCM_Paystub_Iterator_Type1 -> log_total_paystubs - started');
try {
const elements = ['[class*="COUNTER"]'];
await this.ph.waitForSelector(elements[0], page);
let str = await this.ph.getInnerText(page, elements[0]);
str = str.split('of ')[1];

logger.info(`PeoplesoftHCM_Paystub_Iterator_Type1 -> log_total_paystubs - ${str}`);
} catch (e) {
logger.warn(e);
}
}
}

class PeoplesoftHCM_Paystub_Iterator_Type2 extends ItemIterator {

constructor(page, session_id) {
super(page);
this.session_id = session_id;
this.session = global.session_mgr.get_session(session_id);
this.elements = ['a[id*="PAY_END"]', 'input[type="checkbox"][id*="PDF"]', 'input[id*="Yes"]'];
}

async init() {
this.paystubTypes = await this.get_paystubs(this.page);
if (this.paystubTypes.length === 0) {
throw Controller.getError('general', 'notAvailable', SUPPORTED_ITEM_TYPE.paystub_file);
}
logger.info(`PeoplesoftHCM_Paystub_Iterator_Type2 -> init -> Paystub Types => ${JSON.stringify(this.paystubTypes)}`);
this.num_of_items = this.paystubTypes.length;
logger.info(`PeoplesoftHCM_Paystub_Iterator_Type2 -> init -> Total Paystubs => ${this.num_of_items}`);
await this.log_total_paystubs(this.page);

try {
await this.ph.waitForSelector(this.elements[1], this.page, {
visible: true,
timeout: 5000
});
if (await this.ph.is_checked(this.elements[1], this.page)) {
logger.info(`PeoplesoftHCM_Paystub_Iterator_Type2 -> init -> PDF File checkbox -> true`);
}
} catch (e) {
logger.warn(e);
}
}

async close_last_tab() {
let pages = await this.session.browser.pages();
logger.info(`PeoplesoftHCM_Paystub_Iterator_Type2 -> close_last_tab -> Total Browser Tabs - ${pages.length}`);
if (pages.length > 1) {
await pages[pages.length - 1].close();
}
}

async next() {
logger.info(`PeoplesoftHCM_Paystub_Iterator_Type2 -> next -> index - ${this.index}`);
if (this.index > 0 && (this.num_of_items > this.index)) {
await this.close_last_tab();
try {
await this.ph.waitForSelector(this.paystubTypes[this.index], this.page, {
timeout: 15000
});
} catch (e) {
logger.warn(e);
await this.ph.waitForSelector(this.paystubTypes[this.index], this.page, {
timeout: 20000
});
}
}

//Click on every paystub link
await this.ph.performClick(this.paystubTypes[this.index++], this.page);
await Promise.race([this.ph.waitForResponse('IC_PAY_INQ', this.page, 'include'), this.ph.waitFor(15000)]);

try { //Paycheck view warning message
await this.ph.waitForSelector(this.elements[2], this.page, {
visible: true,
timeout: 2000
});
await this.ph.performClick(this.elements[2], this.page);
} catch (e) {
logger.warn(e);
}

let targetPage = await this.ph.waitForNewTarget(this.session_id, this.page, null, 20000);
await Promise.race([this.ph.waitForResponse('pdf', targetPage, 'include'), this.ph.waitFor(5000)]);
try {
await this.ph.waitForSelector('embed', targetPage, {
visible: false,
timeout: 10000
});
} catch (e) {
logger.warn(e);
}
return targetPage;
}

async get_paystubs(page) {
return await page.$$eval(this.elements[0], (elements) => {
return Array.from(elements).map(e => `a[id='${e.id}']`);
});
}

async log_total_paystubs(page) {
logger.debug('PeoplesoftHCM_Paystub_Iterator_Type2 -> log_total_paystubs - started');
try {
const elements = ['[class*="COUNTER"]'];
await this.ph.waitForSelector(elements[0], page);
let str = await this.ph.getInnerText(page, elements[0]);
str = str.split('of ')[1];
logger.info(`PeoplesoftHCM_Paystub_Iterator_Type2 -> log_total_paystubs - ${str}`);
} catch (e) {
logger.warn(e);
}
}
}

module.exports = PeoplesoftHCM;





     
 
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.