【问题标题】:How to screenshot a tapped button using iOS UIAutomation?如何使用 iOS UIAutomation 截取点击的按钮?
【发布时间】:2012-09-21 10:46:34
【问题描述】:

我尝试了 UIAElement 中的tapAndHold() 函数

var target = UIATarget.localTarget();
target.frontMostApp().mainWindow().buttons()["Button"].tapAndHold()
target.captureScreenWithName("shot")

但这会因为 JavaScript 错误而失败:'undefined' is not a function (evaluating target.frontMostApp().mainWindow().buttons()["Button"].tapAndHold()

更新

我也试过

target.frontMostApp().mainWindow().buttons()["Button"].touchAndHold(1.5)
target.captureScreenWithName("shot")

至少确实突出显示了按钮,但是当屏幕截图被制作时,它已经再次被停用。 :(

【问题讨论】:

    标签: iphone ios instruments ui-automation ios-ui-automation


    【解决方案1】:

    插入延迟(1)。

    target.frontMostApp().mainWindow().buttons()["Button"].touchAndHold(1.5)
    target.delay(1);
    target.captureScreenWithName("shot")
    

    你是在 iPod 上运行它吗?您正在测试的设备也很重要。我建议使用 iPhone 3GS、4S 来检查更多品种。

    【讨论】:

    • 那行不通。它按顺序执行所有这些操作,因此延迟会在保持 1.5 秒后出现。我在模拟器上运行它。
    • 只是为了好奇,在 touchAndHold 之前尝试 target.captureScreenWithName("shot")
    猜你喜欢
    • 2012-06-15
    • 2011-07-21
    • 1970-01-01
    • 2019-12-06
    • 1970-01-01
    • 2017-12-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多