macaca icon indicating copy to clipboard operation
macaca copied to clipboard

macaca-ios控件是否存在判断不精准

Open bluesky12345 opened this issue 9 years ago • 1 comments

  • Macaca Version: 2.0.4

  • Macaca Doctor Logs: macaca-doctor version: 2.0.1

    Node.js checklist:

    node env: /usr/local/bin/node node version: v7.4.0

    iOS checklist:

    Xcode Command Line Tools require version: 2347 and above xcodebuild version: 8.3.2 iproxy[usbmuxd] is installed at: /usr/local/bin/iproxy ios_webkit_debug_proxy is installed at: /usr/local/bin/ios_webkit_debug_proxy carthage is installed, version: 0.23.0

    Android checklist:

    JAVA version is 1.8.0_111 JAVA_HOME is set to /Library/Java/JavaVirtualMachines/jdk1.8.0_111.jdk/Contents/Home ANDROID_HOME is not set Command Line Tools: gradle is uninstalled

    Installed driver list:

    ios: 2.0.22

  • Operate System: 10.12

  • Programming Language: java

XCTest中代码XCTestWDAccessibility.swift对控件可见判断不正确 代码片段: func isWDVisible() -> Bool { if self.frame.isEmpty || self.visibleFrame.isEmpty { return false }

    let app: XCElementSnapshot? = _rootElement() as! XCElementSnapshot?
    let screenSize: CGSize? = MathUtils.adjustDimensionsForApplication((app?.frame.size)!, (XCUIDevice.shared().orientation))
    let screenFrame = CGRect(x: CGFloat(0), y: CGFloat(0), width: CGFloat((screenSize?.width)!), height: CGFloat((screenSize?.height)!))
    let rectIntersects: Bool = visibleFrame.intersects(screenFrame)
    let isActionable: Bool? = app?.frame.contains(hitPoint)
    
    return rectIntersects && isActionable!
}

分析: 判断控件是否存在为什么要判断app的frame是否包含hitPoint,hitPoint不是用于点击吗?

bluesky12345 avatar Jul 11 '17 13:07 bluesky12345

hitpoint 代表 UIElement 实际的可以接受到的坐标, 如果hitpoint 属于app.frame 中代表 uielement 在可见范围中, 请参考 同类型的其他测试框架实现

SamuelZhaoY avatar Nov 13 '17 05:11 SamuelZhaoY