protractor - 获取错误 protractor_1.browser.action 不是函数
问题描述
我在执行操作时遇到错误。规格文件代码
it("testcase action", async()=> {
browser.waitForAngularEnabled(false);
await browser.get("https://google.com");
await browser.actions().mouseMove(element(by.css("input[name='q']"))).sendKeys("protrac").perform();
await browser.sleep(8000);
await browser.actions().sendKeys(protractor.Key.ARROW_DOWN);
await browser.action().sendKeys(protractor.Key.ENTER);
})
配置文件中的代码
import {Config, browser} from "protractor";
// An example configuration file
export let config: Config = {
// The address of a running selenium server.
//seleniumAddress: 'http://localhost:4444/wd/hub',
directConnect:true,
// Capabilities to be passed to the webdriver instance.
capabilities: {
browserName: 'chrome',
'goog: chromeOptions':{
w3c: false
},
},
// Spec patterns are relative to the configuration file location passed
// to protractor (in this example conf.js).
// They may include glob patterns.
specs: ['testspec.js'],
// Options to be passed to Jasmine-node.
jasmineNodeOpts: {
showColors: true, // Use colors in the command line report.
}
};
我面临的错误
> protractortypescriptcucumberframework@1.0.0 pretest C:\Users\Admin\Eclipse Protractor
JavaScript\ProtractorTypeScriptCucumberFramework
> tsc
> protractortypescriptcucumberframework@1.0.0 test C:\Users\Admin\Eclipse Protractor
JavaScript\ProtractorTypeScriptCucumberFramework
> protractor JSFiles/configuration.js
[12:35:49] I/launcher - Running 1 instances of WebDriver
[12:35:50] I/direct - Using ChromeDriver directly...
DevTools listening on ws://127.0.0.1:50594/devtools/browser/c5170ccf-5c5d-408d-8d10-c6eb3022c11f
Started
(node:7448) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues.
Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
F
Failures:
1) Action class testcase action
Message:
Failed: protractor_1.browser.action is not a function
Stack:
TypeError: protractor_1.browser.action is not a function
at C:\Users\Admin\Eclipse Protractor
JavaScript\ProtractorTypeScriptCucumberFramework\testspec.ts:110:15
at Generator.next (<anonymous>)
at fulfilled (C:\Users\Admin\Eclipse Protractor
JavaScript\ProtractorTypeScriptCucumberFramework\JSFiles\testspec.js:5:58)
From: Task: Run it("testcase action") in control flow
at UserContext.<anonymous> (C:\Users\Admin\Eclipse Protractor
JavaScript\ProtractorTypeScriptCucumberFramework\node_modules\jasminewd2\index.js:94:19)
From asynchronous test:
Error
at C:\Users\Admin\Eclipse Protractor
JavaScript\ProtractorTypeScriptCucumberFramework\testspec.ts:102:1
at Generator.next (<anonymous>)
at C:\Users\Admin\Eclipse Protractor
JavaScript\ProtractorTypeScriptCucumberFramework\JSFiles\testspec.js:8:71
at new Promise (<anonymous>)
at __awaiter (C:\Users\Admin\Eclipse Protractor
JavaScript\ProtractorTypeScriptCucumberFramework\JSFiles\testspec.js:4:12)
at Suite.fdescribe (C:\Users\Admin\Eclipse Protractor
JavaScript\ProtractorTypeScriptCucumberFramework\testspec.ts:99:36)
Ran 1 of 5 specs
1 spec, 1 failure
Finished in 13.633 seconds
[12:36:37] I/launcher - 0 instance(s) of WebDriver still running
[12:36:37] I/launcher - chrome #01 failed 1 test(s)
[12:36:37] I/launcher - overall: 1 failed spec(s)
[12:36:37] E/launcher - Process exited with error code 1
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! protractortypescriptcucumberframework@1.0.0 test: `protractor JSFiles/configuration.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the protractortypescriptcucumberframework@1.0.0 test 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\Admin\AppData\Roaming\npm-cache\_logs\2020-07-21T07_06_38_712Z-debug.log
PS C:\Users\Admin\Eclipse Protractor JavaScript\ProtractorTypeScriptCucumberFramework>
解决方案
推荐阅读
- node.js - 更改节点快速超时尝试连接
- visual-studio-2019 - 通过 Visual Studio 2019 连接 Firebird
- powerbi - 尝试在 Alm-Toolkit 中连接 Power-Bi 模型时,对象引用未设置为对象错误的实例
- video - 如何将 Twilio PSTN 语音会议桥接到 Twilio 视频室?
- jodit - 在 jodit-react 中禁用粘贴图像截图
- amazon-web-services - DynamoDB 使用查询对项目进行排序/排序
- python - 在 cs50 财务解决方案中不显示历史记录表
- html - html中的水平菜单显示错误,同时删除css中的float属性
- html - 在桌面上并排显示 2 个 div 和 2nd div 下的 3rd div 并在移动屏幕上显示 1st 和 2nd div 下的 3rd div
- jenkins - 在 Jenkins 脚本外壳中屏蔽凭据