首页 > 解决方案 > IOS 设备上的 Testcafe typeText 在第三方 iframe 上不起作用

问题描述

我在 IOS 设备和 testcafé 上使用 typeText 时遇到了一些问题。相同的脚本适用于桌面浏览器、android 浏览器,但不适用于 IOS。我曾尝试在 Browserstack Automate 上托管真实设备,并在我手中的设备上尝试过整洁的 testcafe 功能 --qr-code。相同的行为。
添加文本的代码中没有任何错误。当以下元素应该可见时,我收到错误消息。

我之前也尝试过使用 WebDriver(用 Java 编码),但是 sendKeys() 遇到了同样的问题

我很确定 IOS 和 Safari 需要一些特殊处理,但我不知道需要什么。

我的代码是这样的:

async payWithCreditCardSecure(cardNumber, expiryDate, cvc) {
    await t
        .click(this.creditCardRadioButton)
        .switchToIframe(this.creditCardNumberIFrame)
        .typeText(this.creditCardNumber, cardNumber, {paste: true, replace: true})
        .switchToMainWindow()
        .switchToIframe(this.creditCardExpiryDateIFrame)
        .typeText(this.creditCardExpiryDate, expiryDate, {paste: true, replace: true})
        .switchToMainWindow()
        .switchToIframe(this.creditCardCVCIFrame)
        .typeText(this.creditCardCVC, cvc, {paste: true, replace: true})
        .switchToMainWindow()
        .click(this.finishPurchaseCreditCard) **// BUTTON NEVER GETS ACTIVE SINCE NO TEXT IS ADDED**
        .typeText(this.creditCardSecureUsername, creditCardCredentials.user)  **//HERE IT FAILS**
        .typeText(this.creditCardSecurePassword, creditCardCredentials.password)
        .click(this.creditCardSecureSubmit)
}

该元素如下所示:在此处输入图像描述

UI 如下所示:在此处输入图像描述

提前致谢。

标签: iostestinge2e-testingtestcafebrowser-automation

解决方案


我已经在 Safari 中重现了所描述的行为。我在 TestCafe 存储库中创建了一个问题。请点击以下线程以获取进度通知:

typeText 操作在 Safari 的第三方 iframe 中不起作用

(更新:问题已修复)


推荐阅读