Webdriveragent: UI Testing Failure - Failure fetching attributes for element <XCAccessibilityElement>. Error copying attributes -25202

Created on 5 Oct 2016  路  10Comments  路  Source: facebookarchive/WebDriverAgent

Hello,

I'm having issues while trying to get view hierarchy on specific iOS app screen.

First of all - inspector works properly in all screens except one, so it's probably related to app code, not WebDriverAgent itself?

Logs:

2016-10-05 15:18:20.358 XCTRunner[7819:247635] Built at Oct  5 2016 15:18:01
2016-10-05 15:18:20.374 XCTRunner[7819:247635] ServerURLHere->http://10.53.2.167:8100<-ServerURLHere
    t =    35.42s     Find the Application "local.pid.7842" 0x6100000ac3c0
    t =    35.43s         Snapshot accessibility hierarchy for local.pid.7842
//author-note: it worked properly here and showed hierarchy for first app screen
    t =    44.21s     Find the Application "local.pid.7842" 0x6100000ac3c0
    t =    44.21s         Snapshot accessibility hierarchy for local.pid.7842
//author-note: it crashes here because it's another screen (that one it doesn't work with), I'm not able to see anything in inspector - everything is empty, no screen, no hierarchy, etc.
2016-10-05 15:19:05.068 XCTRunner[7819:253165] Enqueue Failure: UI Testing Failure - Failure fetching attributes for element <XCAccessibilityElement: 0x610000247290> Device element: Error Domain=XCTestManagerErrorDomain Code=13 "Error copying attributes -25202" UserInfo={NSLocalizedDescription=Error copying attributes -25202} <unknown> 0 1
2016-10-05 15:19:20.932 XCTRunner[7819:253165] Enqueue Failure: UI Testing Failure - Failure fetching attributes for element <XCAccessibilityElement: 0x6100002467b0> Device element: Error Domain=XCTestManagerErrorDomain Code=13 "Error copying attributes -25202" UserInfo={NSLocalizedDescription=Error copying attributes -25202} <unknown> 0 1

It looks like it has issues with some elements. I've tried different simulators (iPhone 5 and 6) with different OS versions (iOS 9.3, 10), nothing helped. Any ideas how to debug that or how to determine which elements are causing these issues, so I can know what should I look for? I've tried to get view hierarchy using Xcode, but sadly I can't match XCAccessibilityElement UUID (not sure how it's called) from WebDriverAgent logs with of UUIDs present in xCode hierarchy viewer.

I'm able to get view hierarchy using .debugDescription method while running UI tests and also using hierarchy viewer from Xcode. It looks like only WebDriverAgent has some issues.

I'm also having some weird issues with tests on that specific screen (for example - I'm getting text from element using index, print it (to confirm that it's proper element), but when I use .tap() on exactly the same selector, it clicks on completely different element which has nothing to do with that previously printed text..), so it all must be connected somehow.

Yes, WebDriverAgent was working on that screen before without issues, together with tests mentioned above which are acting really weird now. Sadly I'm not able to exactly track down what's the direct cause of this issue, it's like 500 commits waiting for review.. That's why I'm asking for some advices.

Thanks in advance!

Most helpful comment

Anyone have a solution for this yet?

All 10 comments

Okay so I know the cause now..

This specific app screen has "load more" functionality while scrolling to the bottom of the screen.

It looks like WebDriverAgent while getting view hierarchy, causes "load more" to execute, making app populated with more elements, then probably executes "load more" again, app is populated again, etc, etc.. but why does "load more" gets executed? Tracking it down now.

@drptbl hello, have you figured out this problem? It seems that I have exactly the same problem. Any advice?

Thanks!

@apankov1
Yes I did.

For me the problem was that I was trying to use it on screen where there was a loadMore() function at the bottom which would trigger and add more cells if there're 5 cells left to the bottom of the screen.

Now while you're on this screen - try to get hierarchy view using XCTest - you will see that it triggers loadMore() function even if your screen is at the top (this is because it iterates(?) through all elements and it triggers loadMore() while iterating through some elements at the bottom of screen).

So the cause of this error was that it was loading more and more stuff infinite number of times throwing weird and unrelated errors.

How did I fix that?
I've edited my loadMore() app code function because I couldn't find any better solution.

So.. this "bug" occurs in this loadMore() function:

if indexPath.row == model.rowsCount - 5 {
   loadMore()
}

while it doesn't in this one:

        func isTableViewScrolledToBottom() -> Bool {
            let tableHeight = tableView.bounds.size.height
            let contentHeight = tableView.contentSize.height
            let insetHeight = tableView.contentInset.bottom

            let yOffset = tableView.contentOffset.y
            let yOffsetAtBottom = yOffset + tableHeight - insetHeight

            return yOffsetAtBottom > contentHeight-500
        }

        if isTableViewScrolledToBottom() {
            loadMore()
        }

and I've switched to it. It just works.

@drptbl thank you for such a quick response. We don't have explicit "load more" feature, but we do load more items as user scroll down.

Since now I have a direction to dig I will see what can be done. Thank you for a tip.

@apankov1 I bet you're having exactly the same issue as me. Try to dig around yours loadMore, I bet that it's related to yours problem.

Cheers!

I'm using Appium 1.6.1 against an iOS 10 iPhone 6S simulator and this issue hits me when I try to use driver.getPageSource() on a view containing a pickerWheel (in this case, loaded with dozens of countries). I'm firing getPageSource() so I can capture all the XCUITest elements on the page and use them for mapping MobilElements in my PageObjects. What can I do to get around this showstopper for me?

I am not super familiar with Appium, you probably should poke them instead

Anyone have a solution for this yet?

I have the same issue with appium, I don't know what's inside the code, but indeed it's possible to load more data when scrolling to the top.
I'be interested to a solution to avoid to change the code.

@drptbl Thank you! This is an old issue and I don't even use WebDriver, but I was running into this exact issue when using native XCTest; as you said, I implemented a function that loads the next page (willDisplayCell) based on the table cell position (count - 5). Changing this to use content offset fixed the issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Azuer picture Azuer  路  3Comments

prudhvialahari picture prudhvialahari  路  16Comments

bearxc picture bearxc  路  6Comments

saikrishna321 picture saikrishna321  路  8Comments

monleylu picture monleylu  路  16Comments