When we have a XAML layout with a -90藲 rotated ListView and 90藲 rotated list items the Xamarin.UITest packaged is unable to locate the elements as expected. e.g. app.WaitForElement(...)
ListView rotated -90藲app.WaitForElement for the markersTo the WaitForElement method find the marked rotated element within the timeout.
No element is ever found even if they are cleary visible in the running application.
When running the REPL tree command in this scenario is obvious that the element tree is not complete, somehow empty.
With the linked project:
ListView and the second one should fail for the rotated ListView.https://www.dropbox.com/s/279qlu5ki3p5j82/Xamarin_UITest_Rotated_Bug.zip?dl=0
Is there any fix expected soon?
waiting for a fix. My ui tests are failing because of this bug
Any updates?
The App Center Test team has determined the underlying cause of this issue as well as a workaround.
The cause of the issue is that when the image is rotated, Xamarin.UITest incorrectly determines it as being offscreen, so it can be found by appending .All() to an otherwise valid query for the element:
app.Tap(x=>x.All().Marked(STRING));
Because .All() returns "all" matching elements, not just those currently visible in the UI, it's recommended that you check that the element you're searching for is either the 1st returned with this query at index zero (app.Tap() activates the 1st element found), and/or you add additional methods to make sure you're actually targeting the right element.
The rotation may also offset the elements coordinates. If the logging reports that the element is tapped but the element is not actually activated, it may be because the miscalculation is enough to move the detected center of the element off of the element itself.
If you are blocked by that aspect, you should be able to use the REPL tool and app.Query(x=>x.All().Marked(STRING)); to gather more data on where the element actually is showing up & use that two write a correction; for example app.TapCoordinates(updated coordinates).
The tricky thing is that the precise coordinates of an element can vary by screen resolution, so you might have to write a helper method that dynamically checks the location, applies a correction and then finally taps that location. I have some examples of general helper method implementations with Xamarin.UITest, but not currently an example of this exact scenario: https://github.com/King-of-Spades/AppCenter-Test-Samples/blob/master/Xamarin.UITest/FormsGallery/FormsGallery.UITest/HelperMethods.cs
Unfortunately a fix is _not_ expected to be available soon, which is why I've prioritized giving this workaround information. I haven't fully QA'd the workaround but the details here cover what's known and been observed on the issue, please let me know if the workaround is ineffective.
@arctouch-fabriciomiranda If you continue to experience this issue, please report it via App Center. Thanks!