appium-uiautomator2-server icon indicating copy to clipboard operation
appium-uiautomator2-server copied to clipboard

To be faster in Android!Here is some optimization suggestion

Open zengxiaoshi opened this issue 5 years ago • 9 comments

I want to abandon all "waitForIdle" in order to be faster ! I will set timeout in my test case in order for stable test case! From the above discussion:

  1. Can we set properties that can abandon all "waitForIdle" in appium-uiautomator2-server and in uiautomator;
  2. Appium-uiautomator2-server had abandon "find_element_by_name", can you tell me why?
  3. We must replace the "find_element_by_name" with "find_element_by_uiautomator", and uiautomator is very slowly because of "waitForIdle" in internal logic
  4. If we want to get text(or description) by element, we must use: element = find_element_by_android_uiautomator(uia_command) text = element.text What's the meaning of above? find_element_by_android_uiautomator --> use "waitForIdle" in uiautomator element.text --> getAccessibilityNodeInfo().getText(); --> use "waitForIdle" in getAccessibilityNodeInfo My God! It use more than 20s in dynamic activity; How amazing!!! Can we get text in one step? elem.get_attribute('checked'), elem.get_attribute('selected'), and so on

zengxiaoshi avatar Jun 06 '19 07:06 zengxiaoshi

Can we set properties that can abandon all "waitForIdle" in appium-uiautomator2-server and in uiautomator;

You can set idle timeout to zero after https://github.com/appium/appium-uiautomator2-server/pull/279 has been merged

Appium-uiautomator2-server had abandon "find_element_by_name", can you tell me wh

name was superseded by id

We must replace the "find_element_by_name" with "find_element_by_uiautomator", and uiautomator is very slowly because of "waitForIdle" in internal logic

See above

mykola-mokhnach avatar Jun 06 '19 07:06 mykola-mokhnach

I had read the code of #279,we can only set idle timeout for appium-uiautomator2-server except “androidx.test.uiautomator”

name was superseded by id

is AccessibilityId?find_element_by_accessibility_id? if (by instanceof By.ByAccessibilityId) return findObject(androidx.test.uiautomator.By.desc(by.getElementLocator()));

zengxiaoshi avatar Jun 06 '19 08:06 zengxiaoshi

@zengxiaoshi Please, if you have a working solution that implements this idea, please submit a PR. We would be happy to get this functionality in Appium and you seem the best to get it done.

imurchie avatar Jun 06 '19 12:06 imurchie

@zengxiaoshi Please, if you have a working solution that implements this idea, please submit a PR. We would be happy to get this functionality in Appium and you seem the best to get it done.

def find_element_by_accessibility_id(self, accessibility_id):
else if (by instanceof By.ByAccessibilityId) {
            return CustomUiDevice.getInstance().findObject(androidx.test.uiautomator.By.desc(by.getElementLocator()));
        } 

We can see "find_element_by_accessibility_id" is equal to "By.desc", from the source code. We often find the element by text more than by desc, and why don't we modify code to compatible both text and desc:

else if (by instanceof By.ByAccessibilityId) {
            Object textElement =  CustomUiDevice.getInstance().findObject(androidx.test.uiautomator.By.text(by.getElementLocator()));
            return textElement != null
                    ? textElement
                    : CustomUiDevice.getInstance().findObject(androidx.test.uiautomator.By.desc(by.getElementLocator()));
        } 

zengxiaoshi avatar Jun 10 '19 07:06 zengxiaoshi

@zengxiaoshi That would be a breaking change that would not be easily accommodated. It is possible that the reverse could be done (i.e., try by desc, then by text).

imurchie avatar Jun 11 '19 12:06 imurchie

This change would also increase the lookup time in case the element is not present in DOM

mykola-mokhnach avatar Jun 11 '19 14:06 mykola-mokhnach

This change would also increase the lookup time in case the element is not present in DOM

I know what you mean. Form the hierarchical automation concept, we should use UITest when the product becomes stable. I can't understand why appium abandon "find_element_by_text" in Android.

zengxiaoshi avatar Jun 12 '19 02:06 zengxiaoshi

@zengxiaoshi That would be a breaking change that would not be easily accommodated. It is possible that the reverse could be done (i.e., try by desc, then by text).

I agree your idea. And I hope we can use "find_element_by_text" and "find_element_by_desc" rather than "find_element_by_accessibility_id".

zengxiaoshi avatar Jun 12 '19 02:06 zengxiaoshi

@zengxiaoshi That would be a breaking change that would not be easily accommodated. It is possible that the reverse could be done (i.e., try by desc, then by text).

The appium is very complex and huge. I just used appium for few weeks, It's difficult to submit major code. I hope you can add "find_element_by_text" for appium.

zengxiaoshi avatar Jun 12 '19 02:06 zengxiaoshi