为什么toBe()在测试中不起作用-量角器e2e

Why toBe () does not work in the test - protractor e2e

我正在 运行 我的测试中,但我收到以下消息。谁能帮我解决这个问题?我该如何写文本,例如密码不正确?警报和 console.log 对我不起作用。

我的代码:app.e2e-spec.ts

import { FobosFrontendBackofficePage } from './app.po';
import { browser, by, element, promise, ElementFinder, Key, protractor } from 'protractor';
import {ActionSequence, By, Capabilities, Command as WdCommand, FileDetector, ICommandName, Options, Session, TargetLocator, TouchSequence, until, WebDriver, WebElement, WebElementPromise} from 'selenium-webdriver';
import {extend as extendWD, ExtendedWebDriver} from 'webdriver-js-extender';
import {promise as wdpromise} from 'selenium-webdriver';
import {error as wderror} from 'selenium-webdriver';
import {Response} from '@angular/http';

describe('Frontend backoffice App', () => {

let page: FobosFrontendBackofficePage;

beforeEach(() => {
page = new FobosFrontendBackofficePage();

});

it('should navigate to browser', () => {
page.navigateTo();

});

it('Login panel', () => {
var login = element(by.name('username')).sendKeys('Test');
var passwordField = element(by.css('input[ng-reflect-name="password"]')).sendKeys('assadsa');
var buttonSubmit = element(by.buttonText('Dalej')).click();

});

it('Result test', () => {

var result = element(by.className('msg'));

if(result != null){
    expect(result.isDisplayed().toBe(true));

}   
else{
    expect(result.isDisplayed().toBe(false));
}
});  
});

我的日志 运行 测试:

[15:49:14] I/update - chromedriver: unzipping chromedriver_2.32.zip
[15:49:14] I/update - chromedriver: chromedriver_2.32.exe up to date
[15:49:14] I/launcher - Running 1 instances of WebDriver
[15:49:14] I/direct - Using ChromeDriver directly...
[15:49:18] E/launcher - Error: TSError: ⨯ Unable to compile TypeScript
e2e\app.e2e-spec.ts (41,31): Property 'toBe' does not exist on type 'Promise<boolean>'. (2339)
e2e\app.e2e-spec.ts (47,31): Property 'toBe' does not exist on type 'Promise<boolean>'. (2339)

你做错了。它应该是这样的:

expect(result.isDisplayed()).toBe(true)