【发布时间】:2018-07-11 22:50:56
【问题描述】:
我正在尝试运行一个用打字稿编写的量角器测试脚本。但是当我这样做时,我会得到 'ManagedPromise' 作为回报。它没有显示任何错误,只是返回“ManagedPromise”
我的 Typescript 测试:
//import {describe, it} from "selenium-webdriver/testing";
import {browser, by, element} from "protractor";
describe("For testing purpose", () => {
it('should pass', () => {
browser.get("https://angularjs.org");
element(by.model('todoList.todoText')).sendKeys('write first
protractor test');
element(by.css('[value="add"]')).click();
let title = browser.getTitle();
console.log(title);
});
});
我的 conf.js 文件:
import {browser} from "protractor";
exports.config = {
directConnect: true,
capabilities: {
'browserName': 'chrome'
},
framework: 'jasmine2',
specs: ['./JSfiles/appExample.js'],
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 9000
/* getPageTimeout: 3000,
allScriptsTimeout: 2000*/
},
onPreapre: () => {
browser.driver.manage().window().maximize();
}
};
我的 package.json 文件:
{
"name": "typescript-dev-project",
"version": "1.0.0",
"description": "",
"main": "index.js",
"dependencies": {
"@types/jasminewd2": "^2.0.3",
"jasmine": "^3.1.0",
"jasminewd2": "^2.2.0",
"protractor": "^5.3.2"
},
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC"
}
我的 tsconfig.json 文件:
"compilerOptions": {
/* Basic Options */
"target": "es5",
"module": "commonjs",
"esModuleInterop": true,
"strict": true,
"outDir": "./JSfiles",
我尝试运行测试时得到的响应:
Started
ManagedPromise {
flow_:
ControlFlow {
propagateUnhandledRejections_: true,
activeQueue_:
TaskQueue {
name_: 'TaskQueue::101',
flow_: [Circular],
tasks_: [Array],
interrupts_: null,
pending_: null,
subQ_: null,
state_: 'new',
unhandledRejections_: Set {} },
taskQueues_: Set { [TaskQueue] },
shutdownTask_: null,
hold_:
Timeout {
_called: false,
_idleTimeout: 2147483647,
_idlePrev: [TimersList],
_idleNext: [TimersList],
_idleStart: 1694,
_onTimeout: [Function],
_timerArgs: undefined,
_repeat: 2147483647,
_destroyed: false,
[Symbol(unrefed)]: false,
[Symbol(asyncId)]: 109,
[Symbol(triggerId)]: 104 } },
stack_: null,
parent_:
ManagedPromise {
flow_:
ControlFlow {
propagateUnhandledRejections_: true,
activeQueue_: [TaskQueue],
taskQueues_: [Set],
shutdownTask_: null,
hold_: [Timeout] },
stack_: null,
parent_:
ManagedPromise {
flow_: [ControlFlow],
stack_: null,
parent_: [ManagedPromise],
callbacks_: [Array],
state_: 'pending',
handled_: true,
value_: undefined,
queue_: null },
callbacks_: [ [Task] ],
state_: 'pending',
handled_: true,
value_: undefined,
queue_: null },
callbacks_: null,
state_: 'pending',
handled_: false,
value_: undefined,
queue_: null }
【问题讨论】:
-
你是控制台。记录一个承诺。你需要解决它。
-
@Gunderson :是的,和这个类似。我试着搜索这个问题。但我没有得到这个问题。所以这就是我自己发帖的原因。
标签: typescript promise webdriver protractor