scrollToVisible error while testing on a device, UIAutomation
Asked Answered
N

2

3

For this line of test code : view.scrollViews()[0].tapWithOptions({tapOffset:{x:0.32, y:0.25}})

I am getting this error

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

The logelement tree looks like this

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}}
    }
 }
}

I am using XCode 4.5.1 . Can anyone help me to fix this . Thanks

Nightcap answered 2/11, 2012 at 18:16 Comment(2)
There is a f*** bug in instruments, this is turning me crazyBitty
Sorry I didn't see you're trying to tap a Scrollview, which is strangeBitty
O
1

Are you, by any chance, using iOS 5.x simulator or iOS 5.x device? If yes then I am seeing the same issue. I believe Xcode 4.5.1 does not like ScrollViews.

But, I found a workaround.

My element is looks like :

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

So, instead of accessing the button directly, I am trying to access a staticText for the button.

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

I hope this works for you.

Oakie answered 9/11, 2012 at 9:54 Comment(1)
This works only because you've a UIStaticText inside the button. I upvoted because the general idea of the workaround is right: the issue seems to be occurring on Buttons onlyBitty
W
1

I am getting the same error when doing flickInsideWithOptions on a scroll view. I believe that the automation framework is trying to scroll to the element you want to tap first but if the scrolling is disabled for some reason, it fails with the error you mentioned.

There is only one way how to fix it - the automation framework can't know that we are tapping into a scroll view - we have to avoid its special versions of the tap/swipe/flick functions. We will tap on mainWindow instead, e.g.

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}});
Wirra answered 10/1, 2013 at 10:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.