我目前使用的是最新的包 1.18.4,并且在測驗執行期間切換到 iframe 時遇到問題。
每次呼叫 t.switchToIframe() 都會顯示如下錯誤:
Content of the iframe in which the test is currently operating did not load.
即使我可以清楚地看到 iframe 已加載,即使在登陸頁面時等待 60 秒以進行測驗,也會發生這種情況。
下面的粗略代碼應該可以運行并重現問題:
import { Selector, t } from "testcafe";
fixture(`Quick Test`);
test
.page(`https://www.terrific.ie/dealer/bradys-of-castleknock/finance/45784/13295`)(
`Quick Test`,
async () => {
await t
.click(`.submit-outer`)
.expect(Selector(`.car-summary-box`).visible)
.ok()
.expect(Selector(`.cw-finance-plugin.plugin-loaded`).visible)
.ok()
.switchToIframe(`.cw-finance-plugin.plugin-loaded`)
.click(`.cw-checkmark`)
.debug();
});
uj5u.com熱心網友回復:
一般來說,切換到iframe有兩個步驟。第一步是獲取帶有 iframe 的選擇器,但如果選擇器不存在,您將收到另一個錯誤。下一步是contentWindow使用本地 getter。該錯誤可能發生在此步驟中,但我無法使用您的 iframe 示例重現這種情況。您能否分享一個完整的測驗示例來說明此錯誤?
此外,您將 iframe 的內容放在標簽之間,但它不是這樣作業的。您需要在srciframe 的屬性中設定檔案的路徑。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/447569.html
