检查元素是否存在的语法是什么?我需要检查该元素是否存在以便在我的测试中走得更远。如果该元素不存在,我想执行一些其他操作。
这就是我正在尝试的,但语法在平静中不起作用:
import {Click, PerformsTasks, Task, step, Wait, Is} from "serenity-js/lib/screenplay-protractor";
import {ProductDetailPageMap} from "../interactions/element-mappings/ProductDetailPageMap";
import { Interaction, UsesAbilities, AnswersQuestions } from "serenity-js/lib/screenplay-protractor";
import { Target, Attribute, BrowseTheWeb } from "serenity-js/lib/screenplay-protractor";
import { ElementArrayFinder, ElementFinder, $$, browser } from "protractor";
export class AddItemToWishlist implements Task {
static called(): AddItemToWishlist {
return new AddItemToWishlist();
}
private parseSizeList(elements: ElementArrayFinder): any {
if (elements.isPresent()) {
Click.on(ProductDetailPageMap.addToWishlist)
} else {
Click.on(ProductDetailPageMap.removeFromWishlist)
browser.sleep(2000);
Click.on(ProductDetailPageMap.addToWishlist)
}
}
@step('{0} Add Item to the Wishlist')
performAs(actor: PerformsTasks): PromiseLike<void> {
return actor.attemptsTo(
//return
);
}
}
我不确定要在退货中添加什么??