簡體   English   中英

執行 TestCafe 斷言的正確方法是什么

[英]What is the correct way to perform TestCafe assertions

我基本上被困在岩石和堅硬的地方之間。 我正在使用 TestCafe 編寫一些自動化腳本,我需要一些最佳實踐方面的幫助。 基本上我想知道創建一個斷言的最佳方法,該斷言在執行之前等待一小段時間直到元素出現。

我目前的實現:

const setTimeout = 5000;

await t
    .expect(this.papernote.exists, { timeout: setTimeout })
    .ok('The trail is not visible');

當測試執行時,似乎超時沒有得到遵守。 這意味着 TestCafe 將等待默認時間(我相信 3 秒)然后斷言將失敗

我希望你想增加選擇器超時。 嘗試使用此標志

--selector-timeout 500000

你也可以試試

--assertion-timeout 10000

或者你可以嘗試等待元素,

await element.with({ visibilityCheck: true }).with({timeout: 10000});

https://devexpress.github.io/testcafe/documentation/using-testcafe/command-line-interface.html

如果需要為特定斷言定義超時,請將選項對象傳遞給ok方法:

await t
    .expect(this.papernote.exists)
    .ok('The trail is not visible', { timeout: setTimeout });

詳見文檔文章: https : //devexpress.github.io/testcafe/documentation/test-api/assertions/assertion-api.html#ok

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM