我正在尝试创建一个基类来在click和select方法中添加显式权重。这是我到目前为止尝试的代码,但我收到了Click.on()的错误:
import { Enter, Click } from "serenity-js/lib/screenplay-protractor";
import { by } from "protractor";
import { protractor, browser } from 'protractor';
var EC = protractor.ExpectedConditions;
export class wait{
constructor() {
}
ElementVisibility(selector){
browser.driver.wait(function() {
return browser.driver.isElementPresent(by.xpath(selector));
});
}
Click(selector) {
this.ElementVisibility(selector).Click.on()
}
}
另外,当我导入到另一个页面时,这是正确的方法吗?对不起,我是打字稿的新手,它给出了错误而没有识别Click方法
import { Task, step, PerformsTasks } from "serenity-js/lib/screenplay";
import { Enter, Click } from "serenity-js/lib/screenplay-protractor";
import { CheckoutPageMap } from "../interactions/element-mappings/CheckoutPageMap";
import { wait } from "../interactions/element-mappings/wait";
export class FillPaymentMethod implements Task {
static called(): FillPaymentMethod {
return new FillPaymentMethod();
}
@step('{0} Select Shipping Method - Bruno selects for an item in men section')
performAs(actor: PerformsTasks): PromiseLike<void> {
return actor.attemptsTo(
Click.on(CheckoutPageMap.radioCreditCard),
Enter.theValue('Bruno Sacco').into(CheckoutPageMap.textCreditCardHolderName),
Enter.theValue('4032039926075500').into(CheckoutPageMap.textCreditCardNumber),
Enter.theValue('123').into(CheckoutPageMap.textCreditCardCvv),
wait.Click('//*[@id="card_month"]/option[.=" 09"]'),
//Click.on(CheckoutPageMap.dropDownCreditCardMonth), // TO-DO: optimize choosing option from dropdown from properties file
Click.on(CheckoutPageMap.dropDownCreditCardYear) // TO-DO: optimize choosing option from dropdown from properties file
);
}
};
收到此错误 - [ts]“typeof wait”类型中不存在属性“Click”。