[英]Protracto-TypeScript Error: Argument type boolean not assigned to parameter type boolean
I am new to typescript and don't know how to debug this error which am getting in my page object code. 我是打字稿的新手,不知道如何调试我的页面对象代码中的错误。 Here is the error which typescript is throwing:
这是打字稿投掷的错误:
Error:(101, 50) TS2345:Argument of type '(isEnabled: boolean) => Promise<CloudletPolicyBean> | undefined' is not assignable to parameter of type '((value: boolean) => CloudletPolicyBean | IThenable<CloudletPolicyBean>) | undefined'.
My Code: 我的代码:
import {ClType} from "./ClType";
export class ClPolicyBean {
private type: ClType;
private name: string;
private description: string;
public setType(type: ClType): void {
this.type = type;
}
public getType(): ClType {
return this.type;
}
public setName(name: string): void {
this.name = name;
}
public getName(): string {
return this.name;
}
public setDescription(description: string): void {
this.description = description;
}
public getDescription(): string {
return this.description;
}
}
Page Object: 页面对象:
import {browser, element, by, ElementFinder,ElementArrayFinder} from "protractor”;
import {ClPolicyBean} from "../dsl/ClPolicyBean";
export class CreateClPolicyDialog{
public constructor() {
super(true);
}
private createPolicyButton: ElementFinder = element(by.css("button[class *= 'submit-button']"));
public isSubmitButtonEnabled(): wd.promise.Promise<boolean> {
return this.createPolicyButton.isEnabled();
}
public submit(): wd.promise.Promise<CloudletPolicyBean> {
return this.isSubmitButtonEnabled().then(isEnabled => {
if(isEnabled) {
let cl:ClPolicyBean = new ClPolicyBean();
this.getSelectedClType().then(type => {
cl.setType(type);
});
return this.createPolicyButton.click().then(() => {
ExtendedExpectedConditions.waitForElementNotVisible(this.dialogContainer, 30000);
return cl;
});
}
});
}
}
Now, in my Page object code TypeScript is complaining when I am trying to use isSubmitButtonEnabled. 现在,在我的Page对象代码中,当我尝试使用isSubmitButtonEnabled时,TypeScript抱怨。 I am new to typescript any help would be appreciated.
我是打字稿的新手任何帮助将不胜感激。
isSubmitButtonEnabled
returns a promise. isSubmitButtonEnabled
返回一个promise。 In submit
in if
statement you are trying to check is result of isSubmitButtonEnabled
true. 在
if
语句中submit
你试图检查的是isSubmitButtonEnabled
结果为true。 It is not. 它不是。
Use something like that: 使用类似的东西:
public isSubmitButtonEnabled() {
return this.createPolicyButton.isEnabled().then((enabledBool) => {
return enabledBool;
})
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.