google / GTXiLib

Google Toolbox for Accessibility for iOS
Apache License 2.0
228 stars 42 forks source link

How to find reported element when there is no accessibility Id in GTXiLib report? #15

Open selin194 opened 5 years ago

selin194 commented 5 years ago

Hi all, I have a question. I have successfully called GTXiLib on my UI tests and get a report of accessibility checks. However, I receive error report like:

Screen Shot 2019-09-15 at 12 52 24

I can not understand which UI buttons does this report try to point on. How can I learn which button is failing by reading this report? I mean should not this report include accessibility Id on the report to know the button that fails? Thank you @niksawtschuk @j-sid !

aloksinha18 commented 5 years ago

@selin194 you have frame of element which might help you.

selin194 commented 5 years ago

I see, maybe I can use address information too. (By stopping my test at a specific point and see the address of the each element and check failure). Is there a way to add accessibility Id to the elements to the report? @sishuiOS , thank you.

niksawtschuk commented 5 years ago

I realize this isn't a perfect solution, but the failing element is set in the NSError's userInfo which is logged by the check: https://github.com/google/GTXiLib/blob/61eb9829353656f40c46da50af2988339092af9b/Classes/NSError%2BGTXAdditions.m#L62

If you put a breakpoint in this file, you can log whatever you'd like about the element in question.

I do agree that the element's description should include some additional info:

@j-sid I don't think it should be too difficult to add some extra logging to the element's description in NSError+GTXAdditions

selin194 commented 5 years ago

We can add additional key-value pairs to the userinfo, right?

niksawtschuk commented 5 years ago

We can add additional key-value pairs to the userinfo, right?

@selin194 we certainly could, but the element's description is logged regardless, and since by default most UIView classes don't seem to add much useful information to their description, you don't get a good idea which element it's logging. I'm suggesting that we either add to that description, or add some category or extension which appends additional detail to description.

In the meantime, though, you could try adding a breakpoint to that file to do the check yourself.

aloksinha18 commented 5 years ago

@selin194 Hi ..I have integrated GtxiLib in UnitTests but I also need to integrate GtxiLib for my UITests as you have already integrated for UITests ..could you please explain how to use it for UITests target. Thanks.

selin194 commented 5 years ago

Hey @sishuiOS, for UITests we need to use EarlGrey library and create a new target by selecting IOS Unit Testing Bundle. After that we need to create a scheme whose target is newly created one. After that we can start to use GTXiLib features! Let me now if you have any question!