import ActionButton from '../../../pages/actionButton/actionButton.page'; import DpOtherDocument from '../../../pages/dp/dpOtherDocument.page'; import SubSideMenu from '../../../pages/sideMenu/subSideMenu.page'; import moment = require('moment'); import path = require('path'); import process = require('process'); export async function fillInOtherDocument(otherDocumentName: string, dataTable: any) { const data = dataTable.rowsHash(); const subSideMenu = new SubSideMenu(); const dpOtherDocument = new DpOtherDocument(); const actionButton = new ActionButton(); await subSideMenu.getSubMenuSubOption(otherDocumentName).clickElement(); if (data['Document'] == 'Electronic record') { await dpOtherDocument.getRadioElectronicRecordAvailable().clickElement(); } else if (data['Document'] == 'Paper document') { await dpOtherDocument.getRadioDocumentsWillBeMailed().clickElement(); } else { await dpOtherDocument.getRadioDocumentNotAvailable().clickElement(); } if (data['Transport document']) { await dpOtherDocument.getInputTransportDocument().setInputField(data['Transport document']); } if (data['Date of shipment']) { await dpOtherDocument.getInputDateOfShipment().selectDate(moment(data['Date of shipment'], 'dd-mm-yyyy')); } if (data['Port of loading']) { await dpOtherDocument.getInputPortOfLoading().setInputField(data['Port of loading']); } if (data['Port of discharge']) { await dpOtherDocument.getInputPortOfDischarge().setInputField(data['Port of discharge']); } if (data['Upload file']) { const filePaths = data['Upload file'].split(','); for (const element of filePaths) { const fullPath = path.join(process.cwd(), element); const remoteFilePath = browser.uploadFile(fullPath); await dpOtherDocument.getUploadFiles().uploadFile(await remoteFilePath); } } await actionButton.getSaveAndNextButton().clickElement(); }