如何在Protractor中写入Excel文件

问题描述 投票:0回答:1

我正在使用量角器5.2.2。我有一个需求 - 将数据写入excel文件(我需要将动态变量传递给同一个excel文件。也就是说,当我每次运行时,应该将不同的数据集输入到excel中,所以我使用过编辑XLSX)。我使用下面的代码。

var EditXlsx = require('edit-xlsx');
var xlsx = new EditXlsx('../files/exl.xlsx');
var sheet = xlsx.sheet(0);
var data = {
title: 'AKIRA'}
sheet.update('A1', 'Title');

但是当我运行量角器脚本时,它会显示“错误:无法找到模块'edit-xlsx'”。当我通过命令'npm install edit-xlsx'安装edit-xlsx时,它会给出错误及其下面的给出(I还成功安装了python 2.7)。

F:\frx-automation>npm install edit-xlsx

> [email protected] install F:\frx-automation\node_modules\libxmljs
> node-gyp rebuild


F:\frx-automation\node_modules\libxmljs>if not defined npm_config_node_gyp (node
"C:\Program Files\nodejs\node_modules\npm\bin\node-gyp- 
bin\\..\..\node_modules\
node-gyp\bin\node-gyp.js" rebuild )  else (node "" rebuild )
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "C:\Program Files 
(x86)\Python37-32\python.EXE", you can set the PYTHON env variable.
gyp ERR! stack     at PythonFinder.failNoPython (C:\Program 
Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:483:19)
gyp ERR! stack     at PythonFinder.<anonymous> (C:\Program 
Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:508:16)
gyp ERR! stack     at C:\Program 
Files\nodejs\node_modules\npm\node_modules\graceful-fs\polyfills.js:284:29
gyp ERR! stack     at FSReqWrap.oncomplete (fs.js:152:21)
gyp ERR! System Windows_NT 6.3.9600
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program 
Files\\nodej
s\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd F:\frx-automation\node_modules\libxmljs
gyp ERR! node -v v8.9.3
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
npm WARN [email protected] requires a 
peer of protractor@>= 4.0.0 but none is installed. You must install peer 
dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] 
(node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for 
fsevents@
1.2.4: wanted {"os":"darwin","arch":"any"} 
(current{"os":"win32","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional 
logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\CS1027C\AppData\Roaming\npm-cache\_logs\2018- 
020T03_43_13_721Z-debug.log

我错了吗?先谢谢

protractor
1个回答
0
投票

edit-xlsx需要2.5到3.0之间的python版本

如果没有安装,请使用以下命令将npm设置为指向版本2.7,然后从here安装正确的版本

npm install --python=python2.7

然后使用安装edit-xlsx

npm install edit-xlsx
© www.soinside.com 2019 - 2024. All rights reserved.