Using Android UIAutomator: find_element_by_android_uiautomator('new UiSelector().textContains("test")')
If you want to use a regular expression, use textMatches instead.
Thank you so much Alexis. I tried it and successed! Thanks a lot!
Would you mind if ask more things?
First, Anything to use self.driver.find_element_by_xpath function?
For example, self.driver.find_element_by_xpath("//android.view.View[@content-desc=’****.text.****’]")
Second, If I use your solution, Is there a way to using both Android and IOS? Is it same to use in ios_uiautomator? Sorry, I cannot test it now in IOS.
I don’t think you can use regular expressions in xpath. It will probably search for exact content.
Unfortunately, UIAutomator methods only work on Android. I am not too familiar with UIAutomation myself, but there might be a similar function. You can use a switch on device name to execute correct code depending on device (I use java, so i can’t give you an accurate example).
There may also be a function in python client that does it on both.