【发布时间】:2019-05-13 22:25:02
【问题描述】:
我的项目文件夹结构如下:
tests
- features
- payloads
- request
-JSONRequest (create-req.json file is present inside this folder)
-XMLRequest (sample-req.xml file is present inside this folder)
我必须根据找到的 create-req.json 文件打印完整的 PATH
我创建了一个名为 requestDataPath 的变量,它存储到“请求”结构的路径。我正在根据作为参数传递的值来选择我的 json 请求。我正在尝试根据文件所在的文件夹打印完整路径。
let path = require('path');
let requestDataPath = path.resolve('tests/payloads/request/../');
let requestBodyPath = requestDataPath + '/' + 'create' + '-req.json';
console.log('Path is-->' + requestBody);
实际结果:/Users/pranaytgupta/Documents/pranay/api-automation-framework/tests/payloads/request/create-req.json
预期结果:/Users/pranaytgupta/Documents/pranay/api-automation-framework/tests/payloads/request/JSONRequest/create-req.json
【问题讨论】:
-
你的脚本存放在哪个文件夹?
-
功能文件夹内--> step_definition(脚本在此)
标签: javascript filepath