After reading the code I found that we will search for UI object firstly by BySelector and later by UiSelector if search by BySelector failed when conducting click or something similar:
The source of UiAutomator shows that both two ways will finally invoke UiAutomation.getRootInActiveWindow(). So UiSelector can't do more than BySelector. BySelector even supports multi-window search while UiSelector doesn't. The only reason to use UiSelector is that it will delay the search operation. Maybe it's useful for a Java instrumental test, but it seems meaningless to hold a reference of a remote object in a python script. Even worse, searching by UiSelector is asynchronous and will waste time to wait for timeout.
So I suggest to use BySelector only when doing search. Would you accept my pull request if I made one to fix it?
After reading the code I found that we will search for UI object firstly by BySelector and later by UiSelector if search by BySelector failed when conducting click or something similar:
The source of UiAutomator shows that both two ways will finally invoke UiAutomation.getRootInActiveWindow(). So UiSelector can't do more than BySelector. BySelector even supports multi-window search while UiSelector doesn't. The only reason to use UiSelector is that it will delay the search operation. Maybe it's useful for a Java instrumental test, but it seems meaningless to hold a reference of a remote object in a python script. Even worse, searching by UiSelector is asynchronous and will waste time to wait for timeout. So I suggest to use BySelector only when doing search. Would you accept my pull request if I made one to fix it?