Question about locating element in custom component

Platform: Android
Appium version:1.22.3
Emulator/Simulator
Client langauage:Python
OS: Windows

Hi there,
We have a custom component in our app as follow:
It’s a component to choose district, and there’re 3 levels(1st is province, then city and then district)
The default selection is “上海市” (Shanghai city as it’s of the province level) which is highlighted below. When I use python-appium to choose a 2nd level district under Shanghai, all works fine.

But when I use python appium to choose another province in my testcase, it will keep finding the city in the 2nd column

I took some time to check in appium inspect and here’s what I found:

  1. If I open this page and do a refresh source in appium inspector before choosing another province, e.g. “河北省”, then when I use search element to search a city under this province, it cannot be found.

  2. If I open this page and don’t’ do a refresh source in appium inspector before choosing another province, the city element can be found

  3. And then when I went on to search for the district element under the chosen city, it failed again.


  4. Only by this method can I find the district element: open this page and choose province, city and then refresh the source(without doing a refresh source action before choosing the city)

Then I tried some trick in my code: after opening this page and before choosing another province, click on some other button like ‘1KM’ here, to force page source change from default province selecton “上海市”, and it succeeded in choosing the city under the other province now. But still the district cannot be found and I cannot click on the above button again, as it will go back to the state that no province is selected.

As the element can be found in appium inspector(although with some restriction), I think I should be able to find it using python-appium. Any suggestion I can do in my code, or ask the developer to adjust in their code? Thanks in advance.