My question is related to UI Automation template from XCode's Instruments tool. How does UI Automation support UIActionSheet testing? I know that there is a UIAActionSheet element and I was able to obtain it in my application. But I do not know how to get and manipulate with buttons from the action sheet. UI Automation does not provide any elements for these buttons. The UI Automation documentation does not have any info on the matter either. See the link below. It looks like this control does not use UIButton class for the buttons and renders them in some specific way. Could you give me some clue how to reach the buttons from UIAActionSheet? Thank you.
相关问题
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- State preservation and restoration strategies with
- “Zero out” sensitive String data in Swift
- Get the NSRange for the visible text after scroll
相关文章
- 现在使用swift开发ios应用好还是swift?
- UITableView dragging distance with UIRefreshContro
- TCC __TCCAccessRequest_block_invoke
- Where does a host app handle NSExtensionContext#co
- Swift - hide pickerView after value selected
- How do you detect key up / key down events from a
- didBeginContact:(SKPhysicsContact *)contact not in
- Attempt to present UIAlertController on View Contr
Since my action sheet was in a popover this returns a nil element:
This does return the action sheet:
But it has nil elements() and buttons().
So I used MikhailV's function to tap the buttons.
If you like to keep it organized like me:
I have found a solution for the problem using direct tapping simulation. It is not an excellent solution but at least it works. I have asked the same question in the Apple Developer Forum but did not get any response.
So, the function below is my solution. I have tested it and it performs well. I will still continue to search for better approach.
As you can see there is method to return default button for each action sheet, which is Cancel button. As there is no other 'default' buttons for action sheet you need to implement those on your own.
One thing to notice woorth apple reference is that it skips methods for given class which are inherited from parent. UIAActionSheet (like most UIA elements) inherits all methods from UIAElement class. Check this reference. You should be able to get array of all buttons from actionsheet by calling
Then you can check by name property which one you need (again method from UIAElement
name()
).Alliteratively, if you check which element in array you are interested in you could call that button directly (assuming, that you won't change ActionSheet) by using UIAElement method
elements()
.For example if you want to tap second button in ActionSheet tree, you just call
Maybe you can skip localTarget(), not sure, but code above should work.