Reputation: 718
I am using Xamarin.UITest to execute automation on iOS app.
The problem is that: while accessing gallery to upload a photo, there is a permission dialog and i need to tap "OK" button to dismiss it.
The following ways that i tried, but they didn't work:
Using tree command does not show hierarchy of that dialog, so that i can not locate UI element to automate
Using
iOSApp.InvokeUia("UIATarget.localTarget().frontMostApp().alert().buttons()[\"OK\"].tap()");
This shown error:
UIATarget.localTarget().frontMostApp().alert().buttons()["OK"] could
not be tapped because the element is not visible tap@[native code]
app.TapCoordinate
, it seems that it is able to work, but have to know the correct coordinate depends on different screens and when dialog appears.Are there any solution to work on this problem? Thanks.
Upvotes: 8
Views: 2335
Reputation: 315
If you use Repl(); in your code you can try to get the marking for the OK button with the tree command.
If you are using the Visual Studio Entrerprise Edition you can make your tests a lot easier using the Xamarin Test Recorder, it works fantastically!
Another thing that should be noted is that UI Tests are usually made for screenshots and screen layout validations, the functionality of your should be tested with another kind of test with another framework or toolkit.
Upvotes: 0
Reputation: 2398
System dialogs for permissions are outside the scope of the app and won't show up in tree
or any other query that you can do through UITest. Instead, these are typically handled automatically by calabash. The "automatic" behavior is to accept any permission dialog that appears.
Is your dialog in a different language where "OK" might be displayed in a non-english language? If so, we may need to file an issue for that specific locale so it can be implemented.
Also, make sure you have the latest UITest version. Take a look at the changes for iOS 10 and InvokeUia here.
Upvotes: 5
Reputation: 1288
try this: target.frontMostApp().mainWindow().elements()[0].elements()[2].elements()[1].tap()
Upvotes: 2