[英]What is an easier for Testcafe to check if a class selector exists on the page or not
[英]Check selector is exist or not in testcafe
現在我有一些角色用戶,每個角色在創建帳戶時都會有一些不同所以我有條件來檢查下拉列表是否存在
'''
if(await t.expect(this.dynamicButtonDropdownByAttribute('originator-org-select-button').exists).ok()){
await this.selectValueInDropdownByAttribute('originator-org-select-button' , 'ORG')
await this.clickButtonByAttribute('originator-org-next-button')
}
'''
當下拉列表存在時沒關系,但當不存在時,它仍然在 if 條件下運行代碼,所以我不確定為什么會這樣?
expect
不返回斷言的結果; 它返回testController
。 多虧了它,您可以在鏈中運行操作。 因此,您需要像這樣從條件中刪除expect
:
if(await this.dynamicButtonDropdownByAttribute('originator-org-select-button').exists){
await this.selectValueInDropdownByAttribute('originator-org-select-button' , 'ORG')
await this.clickButtonByAttribute('originator-org-next-button')
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.