Xamarin UITest Listview Not Updated On Runtime

I have a uitest where I search client-side in listview. For example, if my listview has 2 items, when I open the page
Automation id of the 1st element: auto_test1,
Automation id of the 2nd element: auto_test2
all 2 items are visible. After entering text in an entry and searching, only the following item appears on the screen:
Automation id of the 2nd element: auto_test2,
Automation ids are not updated after the search. When I look with the repl, there is one item. But automation id of it is automation id of first item.
For example:
My UITest Code:
And I have 2 item on my screen
When I look 1. Repl, I see this:
After the search, I look 1 item on screen:
But when I look the second repl, I look it doesn't update:
So I don't control with UITest. I have to test if the search is working correctly. How do I update listview at runtime in uitest?
NOTE: i tried to use image instead of cached image for set automation id. But it doesn't worked.
Hi JarvanZhang, I already do it. My first cmd screen is first repl and I run tree command. After I closed cmd screen and repl worked again (after search) and I again call tree command. The item already has been changed (First time Listview had two item on cmd but when I call tree command second time, Listview had 1 item). But automation id didn't update.
Do you mean changing the AutomationId? We cannot do that, the id can still only be set once.
Check the link:
https://forums.xamarin.com/discussion/144718/why-cant-repl-find-my-visible-elements-by-automationid
Actually I mean when I open the page firstly, I see 2 listview item like this:
After the search, I see 1 item on Listview. But automation ID is mixed with first item's automation id:
In my opinion the reason of this is my xaml page. My xaml page is like this:
I set automation id with StringFormat:
AutomationId="{Binding DisplayName, StringFormat='DownloadPage_Listview_DetailIcon_{0}'}"
Maybe this causes the problem. How can I fix it? Can't I set dynamic automation id with string format?
The AutomationId cannot be changed. Setting binding for the property will not work. If you want to detect the view, try using the Text property instead.
Sign in to comment