3

对于这行测试代码:view.scrollViews()[0].tapWithOptions({tapOffset:{x:0.32, y:0.25}})

我收到此错误

2012-11-02 18:09:23 +0000 None: Script threw an uncaught JavaScript error: target.frontMostApp().mainWindow().scrollViews()[0] could not be tapped on line 244 of feature.js
2012-11-02 18:09:23 +0000 Debug: target.frontMostApp().mainWindow().scrollViews()[0].tapWithOptions({tapOffset:{x:"0.32", y:"0.25"}})
2012-11-02 18:09:23 +0000 Debug: target.frontMostApp().mainWindow().scrollViews()[0].scrollToVisible()
2012-11-02 18:09:23 +0000 Debug: target.frontMostApp().mainWindow().scrollViews()[0] - scrollToVisible cannot be used on the element because it does not have a scrollable ancestor.
2012-11-02 18:09:23 +0000 Debug: target.frontMostApp().mainWindow().scrollViews()[0] - scrollToVisible cannot be used on the element because it does not have a scrollable ancestor.
2012-11-02 18:09:23 +0000 Debug: target.frontMostApp().mainWindow().scrollViews()[0] could not be tapped

对数元素树看起来像这样

UIATarget "MyiPadname" {{0, 0}, {1024, 768}}
elements: {
UIAApplication "myAppName" {{0, 0}, {1024, 768}}
elements: {
    UIAWindow "(null)" {{0, 0}, {1024, 768}}
    elements: {
        UIAScrollView "(null)" {{0, 0}, {1024, 768}}
        elements: {
            UIAImage "(null)" {{1017, 761}, {7, 7}}
            UIAImage "(null)" {{1017, 761}, {7, 7}}
        }
        UIAImage "nav_bar.png" {{0, 724}, {1024, 44}}
        UIAButton "button featured" {{0, 730}, {134, 39}}
        UIAButton "See the world" {{134, 730}, {223, 39}}
        UIAButton "button my favorites" {{357, 730}, {180, 39}}
        UIAButton "button settings" {{967, 736}, {33, 27}}
    }
 }
}

我正在使用 XCode 4.5.1 。谁能帮我解决这个问题。谢谢

4

2 回答 2

1

您是否有机会使用 iOS 5.x 模拟器或 iOS 5.x 设备?如果是,那么我看到了同样的问题。我相信 Xcode 4.5.1 不喜欢 ScrollViews。

但是,我找到了解决方法。

我的元素看起来像:

target.frontMostApp().mainWindow().scrollViews()[0].buttons()["Wikipedia"]

因此,我没有直接访问按钮,而是尝试访问按钮的 staticText。

target.frontMostApp().mainWindow().scrollViews()[0].buttons()["Wikipedia"].staticTexts()["Wikipedia"].tap();

我希望这对你有用。

于 2012-11-09T09:54:39.437 回答
1

flickInsideWithOptions在滚动视图上执行时,我遇到了同样的错误。我相信自动化框架正在尝试滚动到您要首先点击的元素,但是如果由于某种原因禁用了滚动,它会因您提到的错误而失败。

只有一种方法可以解决它 - 自动化框架无法知道我们正在点击滚动视图 - 我们必须避免其特殊版本的点击/滑动/轻弹功能。我们将mainWindow改为点击,例如

var buttonRect = button.rect();
var windowRect = mainWindow.rect();

var xPos = (20 + buttonRect.origin.x) / windowRect.size.width;
var yPos  = (50 + buttonRect.origin.y) / windowRect.size.height;

mainWindow.tapWithOptions({tapOffset:{x:xPos, y:yPos}});
于 2013-01-10T10:12:39.633 回答