let fs = require('fs'); export class ReadLocators { /** * To get locators json object * @return {Object} */ static readJson(): object { try { if (fs.existsSync('locators.json')) { console.log("The file exists in product repository."); var xpathsFromJSON = JSON.parse((fs.readFileSync("locators.json"))); if(Object.entries(xpathsFromJSON).length === 0) { console.log("Json file seems to be empty. Hence fetching xpaths from dd-cc-zycus-automation"); xpathsFromJSON = JSON.parse((fs.readFileSync("node_modules/dd-cc-zycus-automation/locators.json"))); } } else { console.log('The file does not exist in root of repository, using from COE repository.'); var xpathsFromJSON = JSON.parse((fs.readFileSync("node_modules/dd-cc-zycus-automation/locators.json"))); } return xpathsFromJSON; } catch (err) { console.error(err + 'in reading element file'); return null; } } }