My Appium version is 1.6.3 in Mac, and my Android device’s version is Android 7.1.1.
I am facing a problem that get child element from parent element is incorrect.
please check the screenshot below,
in my test case, I would like to verify the row “Call only” without “IM” button, and have “Call” button.
so my code similar as below:
// find all rows
List<MobileElement> rows = driver.findElementsByClassName("android.widget.RelativeLayout");
// get the target row "Call only"
MobileElement call_only_row;
for (MobileElement row : rows) {
if (row.findElementById("....:id/lc_title").getText().equals("Call only")) {
call_only_row = row;
break;
}
}
now I try to list all IM buttons from the parent element call_only_row
;
List<MobileElement> ims = row.findElementById("...:id/mw_linearLayout2").findElemendByIds("...:id/lc_btn_chat");
and then print out the size of the IM buttons of element “call_only_row”, it should be ZERO, but actually the value is ONE.
System.out.println("Call only's IM button size: " + ims.size()); // output 1;
it is incorrect.
finally, I traced what “IM” button was found in ims
list, I try to click this “IM” button which stored in ims
list, and finally found up this “IM” button, is the next row’s “IM” button, the “IM” button of row IM only
.
please check screenshot below.
Could you advise how I can get the correct child element from parent?