UNPKG

@sap_oss/wdio-qmate-service

Version:

[![REUSE status](https://api.reuse.software/badge/github.com/SAP/wdio-qmate-service)](https://api.reuse.software/info/github.com/SAP/wdio-qmate-service)[![Node.js CI](https://github.com/SAP/wdio-qmate-service/actions/workflows/node.js.yml/badge.svg)](http

130 lines (129 loc) 6.75 kB
/** * @class file * @memberof util */ export declare class File { private vlf; private ErrorHandler; /** * @function upload * @memberOf util.file * @description Uploads all the file/s by the paths given in the Array. * @param {String[]} files - Array with path/s of file/s to be uploaded. * @param {String} [selector="input[type='file']"] - Custom selector of uploader control (in case there are more then one present). * @example await util.file.upload(["path/to/text1.txt", "path/to/text2.txt"]); // uses the default uploader control * @example await util.file.upload(["path/to/text1.txt", "path/to/text2.txt"], "input[id='myUpload']"); // upload to file uploader with matching selector */ upload(files: Array<string>, selector?: string): Promise<void>; /** * @function uploadWebGui * @memberOf util.file * @description Uploads all the file/s by the paths given in the Array for SAP WebGUI apps. * @param {String[]} files - Array with path/s of file/s to be uploaded. * @param {String} selector - Custom selector of the input element * @example await util.file.uploadWebGui(["path/to/text1.txt"], "INPUT[title='External file name']"); */ uploadWebGui(files: Array<string>, selector: string): Promise<void>; /** * @function parsePdf * @memberOf util.file * @description Parses the text from PDF stream. Returned text can be asserted to verify the PDF document content. * @param {Buffer} pdfStream - PDF stream to be downloaded. * @param {Function} renderingMethod - Function to customize the parsing process. * @returns {String} The parsed PDF text. * @see <a href="TODO">Parse PDF</a> * @example await util.file.parsePdf(pdfStream, customRenderingMethod); */ parsePdf(pdfStream: Buffer, renderingMethod?: Function): Promise<String>; /** * @function expectPdfContainsText * @memberOf util.file * @description Parses the PDF and checks for given text to be contained in PDF. * @param {Buffer} pdfStream - PDF stream to be downloaded. * @param {String} text - The expected text. * @param {Function} renderingMethod - Function to customize the parsing process. * @see <a href="TODO">Parse pdf</a> * @example await util.file.expectPdfContainsText(pdfStream, "abc"); */ expectPdfContainsText(pdfStream: Buffer, text: string, renderingMethod?: Function): Promise<any>; /** * @function expectPdfNotContainsText * @memberOf util.file * @description Parses the PDF and checks for given text not to be contained in PDF. * @param {Buffer} pdfStream - PDF stream to be downloaded * @param {String} text - The text expected to be not contained in the PDF. * @param {Function} renderingMethod - Function to customize the parsing process. * @see <a href="TODO">Parse pdf</a> * @example await util.file.expectPdfNotContainsText(pdfStream, "abc"); */ expectPdfNotContainsText(pdfStream: Buffer, text: string, renderingMethod?: Function): Promise<boolean>; /** * @function getExcelData * @memberof util.file * @description - It returns the excel data based on the conversion type which is passed * @param {string} filePath - File path is required * @param {string} fileName - File Name is required * @param {number} [sheetIndex] - sheetIndex is required * @param {string} [conversionType] - Value for this are [json, csv, txt] * @example const myTableContent = await util.file.getExcelData("/Users/path/myWork", "myTable.xlx"); */ getExcelData(filePath: string, fileName: string, sheetIndex?: number, conversionType?: string): Promise<any>; /** * @function getTextData * @memberof util.file * @description - Returns the content of a .txt file. * @param {string} filePath - Path to the file. * @example const txtData = await util.file.getTextData(path.resolve(__dirname, "./testFiles/test3.txt")); * const isDateIncluded = txtData.includes("26.6.2023"); * common.assertion.expectEqual(isDateIncluded, true); */ getTextData(filePath: string): Promise<any>; /** * @function expectTextDataToContain * @memberof util.file * @description - Reads the specified .txt file and asserts if it includes a specific string. * @param {string} filePath - Path to the file. * @example await util.file.expectTextDataToContain("/Users/path/myWork", "supplierList.txt"); */ expectTextDataToContain(filePath: string, searchString: string): Promise<any>; /** * @function getXmlData * @memberof util.file * @description - Returns the converted JSON object based on the passed XML file. * @param {string} filePath - Path to the file. * @example const xmlData = await util.file.getXmlData(path.resolve(__dirname, "./testFiles/test2.xml")); */ getXmlData(filePath: string): Promise<any>; /** * @function getAttributeValuesFromJson * @memberof util.file * @description - Traverses the passed JSON object and returns the value/s of the passed attribute if found. Else returns empty Array. * @param {object} object - The JSON Object to search through. * @example const attribute = util.file.getAttributeValuesFromJson(xmlData, "CtrlSum"); */ getAttributeValuesFromJson(object: any, attributeName: string): any[]; /** * @function findFilePathRecursively * @memberof util.file * @description - Returns the absolute path of the file with the given filename. Searches Recursively for the file within the given directory. * @param {string} directory - The name of the directory. * @param {string} fileName - The name of the file. * @example await util.file.findFilePathRecursively("/Users","test.xls"); */ findFilePathRecursively(directory: string, fileName: string): Promise<any>; /** * @function getFileNamesByExtensions * @memberof util.file * @description - Returns the filename/s of the given directory filtered by the given extensions. * @param {string} dirPath - The path to the directory. * @param {string | string[]} fileExtensions - The file extension as string or multiple as string array. * @example const fileName = await util.file.getFileNamesByExtensions("regression/downloads", "xml"); * const fileNames = await util.file.getFileNamesByExtensions("regression/downloads", "["xml", "txt"]"); */ getFileNamesByExtensions(dirPath: string, fileExtensions: string | string[]): string[]; private _renderPage; private _convertSheet; private _checkFileEnding; } declare const _default: File; export default _default;