简体   繁体   English

Protracto-TypeScript错误:参数类型boolean未分配给参数类型boolean

[英]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.

相关问题 'boolean | 类型的参数 undefined' 不可分配给 'boolean' 类型的参数 - Argument of type 'boolean | undefined' is not assignable to parameter of type 'boolean' 参数类型 'string | null' 不可分配给参数类型 'string | 编号 | 布尔值' - Argument type 'string | null' not assignable to parameter type 'string | number | boolean' 错误 TS2345:“NgForm”类型的参数不可分配给“{值:用户”类型的参数; 有效:boolean; }' - error TS2345: Argument of type 'NgForm' is not assignable to parameter of type '{ value: User; valid: boolean; }' { static: boolean; 类型的参数 } 不能分配给类型为 { read?: any } 的参数 - Argument of type { static: boolean; } is not assignable to parameter of type { read?: any } '(fg: FormGroup) => { notmatched: boolean; 类型的参数 }' 不可分配给类型的参数 - Argument of type '(fg: FormGroup) => { notmatched: boolean; }' is not assignable to parameter of type 如何解决 setAttribute() 函数中“boolean”类型的参数不能分配给“string”类型的参数错误 - How to solve Argument of type 'boolean' is not assignable to parameter of type 'string' error in setAttribute() function 错误 TS2345:'{ 类型的参数读取:typeof ElementRef; }' 不可分配给类型为 '{ read?: any; 的参数 static:boolean; }' - error TS2345: Argument of type '{ read: typeof ElementRef; }' is not assignable to parameter of type '{ read?: any; static: boolean; }' 错误:类型“boolean”不可分配给类型“Observable”<boolean> '</boolean> - Error: Type 'boolean' is not assignable to type 'Observable<boolean>' Angular TypeScript错误:无法将类型“ void”分配给类型“ boolean” - Angular TypeScript error: Type 'void' is not assignable to type 'boolean' 在 Angular 中出现错误:输入“布尔值”| 可观察的<boolean> ' 不可分配给类型 'boolean'</boolean> - Getting error in Angular: Type 'boolean | Observable<boolean>' is not assignable to type 'boolean'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM