我有一些回归测试可以正常工作,直到拥有Node 6.9.5版本为止 这是代码摘录
let input = element(by.id('input1'));
let absolutePath = path.resolve("../config", 'data.txt');
input.sendKeys(absolutePath);
将节点升级到10.15.3后,我开始出现以下错误:
- Failed: The value of "value" is out of range. It must be >= -2147483648 and <= 2147483647. Received 2728251391
at checkInt (internal/buffer.js:58:11)
at writeU_Int32LE (internal/buffer.js:678:3)
at Buffer.writeInt32LE (internal/buffer.js:847:10)
at Object.entryHeaderToBinary (Z:\node_modules\adm-zip\headers\entryHeader.js:216:18)
at Object.packHeader (Z:\node_modules\adm-zip\zipEntry.js:260:39)
at Z:\node_modules\adm-zip\zipFile.js:198:41
at Array.forEach (<anonymous>)
at Object.compressToBuffer (Z:\node_modules\adm-zip\zipFile.js:182:23)
at Object.toBuffer (Z:\node_modules\adm-zip\adm-zip.js:472:25)
at Z:\node_modules\selenium-webdriver\remote\index.js:579:37
From: Task: WebElement.sendKeys()
at WebElement.sendKeys (Z:\node_modules\selenium-webdriver\lib\webdriver.js:2094:43)
at actionFn (Z:\node_modules\protractor\lib\element.ts:94:34)
at Array.map (<anonymous>)
at Z:\node_modules\protractor\lib\element.ts:484:67
at ManagedPromise.invokeCallback_ (Z:\node_modules\selenium-webdriver\lib\promise.js:1366:14)
at TaskQueue.execute_ (Z:\node_modules\selenium-webdriver\lib\promise.js:2970:14)
at TaskQueue.executeNext_ (Z:\node_modules\selenium-webdriver\lib\promise.js:2953:27)
at Z:\node_modules\selenium-webdriver\lib\promise.js:2813:27
at Z:\node_modules\selenium-webdriver\lib\promise.js:676:7
at processTicksAndRejections (internal/process/task_queues.js:85:5)Error
at ElementArrayFinder.applyAction_ (Z:\node_modules\protractor\lib\element.ts:482:23)
at ElementArrayFinder.<computed> [as sendKeys] (Z:\node_modules\protractor\lib\element.ts:96:21)
at ElementFinder.<computed> [as sendKeys] (Z:\node_modules\protractor\lib\element.ts:873:14)
at Object.<anonymous> (Z:\test\e2e\sample.spec.ts:233:35)
at new ManagedPromise (Z:\node_modules\selenium-webdriver\lib\promise.js:1067:7)
at ControlFlow.promise (Z:\node_modules\selenium-webdriver\lib\promise.js:2396:12)
at TaskQueue.execute_ (Z:\node_modules\selenium-webdriver\lib\promise.js:2970:14)
at TaskQueue.executeNext_ (Z:\node_modules\selenium-webdriver\lib\promise.js:2953:27)
From: Task: Run fit("Sample test case to demo out of range error") in control flow
at ControlFlow.emit (Z:\node_modules\selenium-webdriver\lib\events.js:62:21)
at ControlFlow.shutdown_ (Z:\node_modules\selenium-webdriver\lib\promise.js:2565:10)
at Z:\node_modules\selenium-webdriver\lib\promise.js:2490:53
at Z:\node_modules\selenium-webdriver\lib\promise.js:2619:9
我检查了节点上报告的类似问题,但这是针对writeUInt16BE()的 https://github.com/nodejs/node/issues/24205
我尝试将节点升级到版本12.8.0,但上述错误仍然存在。
我已设法为该问题创建一个最小的复制器:
D:\gTools\node\node-v12.8.0-win-x86>node
Welcome to Node.js v12.8.0.
Type ".help" for more information.
> var data = new Buffer(70);
undefined
> (node:13384) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
data.writeUInt32LE(33639248);
4
> data.writeUInt16LE(10, 4);
6
> data.writeUInt16LE(10, 6);
8
> data.writeUInt16LE(0, 8);
10
> data.writeUInt16LE(0, 10);
12
> data.writeUInt32LE(1325687893, 12);
16
> data.writeInt32LE(2728251391, 16, true);
Thrown:
RangeError [ERR_OUT_OF_RANGE]: The value of "value" is out of range. It must be >= -2147483648 and <= 2147483647. Received 2728251391
at checkInt (internal/buffer.js:58:11)
at writeU_Int32LE (internal/buffer.js:678:3)
at Buffer.writeInt32LE (internal/buffer.js:847:10)
at repl:1:6
at Script.runInThisContext (vm.js:126:20)
at REPLServer.defaultEval (repl.js:384:29)
at bound (domain.js:420:14)
at REPLServer.runBound [as eval] (domain.js:433:12)
at REPLServer.onLine (repl.js:700:10)
at REPLServer.emit (events.js:208:15)
相同的代码在节点v6.9.2上可以正常工作:
C:\Users\pvaddepa>node -v
v6.9.5
C:\Users\pvaddepa>D:
D:\tools\node>node
> let b = new Buffer(70);
undefined
> b.writeInt32LE(0xA29DCFFF);
TypeError: "value" argument is out of bounds
at checkInt (buffer.js:1027:11)
at Buffer.writeInt32LE (buffer.js:1217:5)
at repl:1:3
at sigintHandlersWrap (vm.js:22:35)
at sigintHandlersWrap (vm.js:96:12)
at ContextifyScript.Script.runInThisContext (vm.js:21:12)
at REPLServer.defaultEval (repl.js:346:29)
at bound (domain.js:280:14)
at REPLServer.runBound [as eval] (domain.js:293:12)
at REPLServer.<anonymous> (repl.js:545:10)
> var data = new Buffer(70);
undefined
> data.writeUInt32LE(33639248);
4
> data.writeUInt16LE(10, 4);
6
> data.writeUInt16LE(10, 6);
8
> data.writeUInt16LE(0, 8);
10
> data.writeUInt16LE(0, 10);
12
> data.writeUInt32LE(1325687893, 12);
16
> data.writeInt32LE(2728251391, 16, true);
20
是否存在针对此问题的解决方法或解决方案?