对于这行测试代码: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
logelement树看起来像这样
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。任何人都可以帮我解决这个问题。感谢
答案 0 :(得分: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();
我希望这适合你。
答案 1 :(得分: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}});