【问题标题】:Can't click on web element with flutter appium driver that is covered by other element无法单击其他元素覆盖的带有颤振appium驱动程序的Web元素
【发布时间】:2020-06-02 11:56:22
【问题描述】:

我尝试使用flutter appium驱动程序在flutter app中测试webview,但遇到了一个问题: 在 webview 中,我有一个文本,它被放置在两行中。因为那个放置文本被另一个元素覆盖。 我尝试了 3 种方法:

1.appium 驱动:mouse.moveTo 然后 mouse.click。 使用 mouse.moveTo 然后 mouse.click 的解决方案不起作用,因为 appium 需要其他称为持续时间的参数,这不包含在我们的 appium_driver 中的参数中。

2。使用颤振检查器来定位 webview 上的元素 - 解决方案没有成功,因为这个 webviews 是外部的并且没有被任何颤振覆盖覆盖。

3。按边界点击 使用 TESTWorld().appiumDriver.pageSource 从 webview 获取所有对象。发现我们的 xml 包含 webview 上的所有对象,其属性为边界、文本。用“MyString”字符串的 3 个对象制作一个列表,并使用 appium_driver 中的 click() 方法一个一个地单击它们。第二个元素“MyString”是可点击的,appium可以点击,但是这个字符串的第一个实例是两行的,所以这个元素是其他大元素的一部分,这就是appium_driver不能点击的原因。

也许有人知道另一种方法?

【问题讨论】:

    标签: flutter appium flutter-web flutter-test


    【解决方案1】:

    因为放置文本被另一个元素覆盖

    在特定情况下,这听起来像是 AUT 问题。 Appium 使用 WebDriver API 测试 WebView,预计无法与重叠的元素交互。

    如果在app中没有办法解决和修复,可以尝试JS发送点击动作(和我们在Webdriver中做的一样):

    WebElement textElement = driver.findElement(...);
    JavascriptExecutor jsEx = (JavascriptExecutor)driver;
    jsEx.executeScript("arguments[0].click();", textElement);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-04-13
      • 1970-01-01
      • 2015-09-19
      • 2020-12-29
      • 2019-05-04
      • 1970-01-01
      • 2019-09-20
      相关资源
      最近更新 更多