我正在运行测试,但收到以下消息。任何人都可以帮我解决这个问题吗?我怎么写文本,例如密码不正确? Alert和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)
答案 0 :(得分:1)
你做错了。它应该是这样的:
expect(result.isDisplayed()).toBe(true)
&#13;