Object inspector used - uiautomatorviewer
How to use ‘index’ node detail to find element in android native app using appium java client?
Object inspector used - uiautomatorviewer
How to use ‘index’ node detail to find element in android native app using appium java client?
Is that you need to find element using index. If so you can use xPath
Thanks Antony…
I used xpath and inserted the index in it and I was able to use it
eg WebElement e1=seleniumFunctions.getElement(driver, By.xpath("//android.widget.RelativeLayout[@index=‘8’]"));
@neharm27,
Can you please help me to identify what is wrong with the following xpath:
driver.findElement(By.xpath("//android.widget.RelativeLayout[2]/android.widget.RelativeLayout[1]/android.widget.TextView[@index=‘2’]")).getText();
i dont get any error but, it does not work as well
try -
driver.findElementByXPath("//android.widget.RelativeLayout[2]/android.widget.RelativeLayout[1]/android.widget.TextView[2]")
OR
driver.findElementByXPath("//android.widget.TextView[@index=‘2’])
Does anyone know if i can use more than one Webelement property to find an element?
eg I want to use index and resource id of a webelement instead of just resource id.
@neharm27
thanks i’l try it …
and i have not used index and resource id together but i have attempted something like this:
“driver.findElement(By.id()).findElements(By.tagName(“TextView”));” and it worked for me. (if this helps)
i had already tried “driver.findElementByXPath(”//android.widget.RelativeLayout[2]/android.widget.RelativeLayout[1]/android.widget.TextView[2]")" but it did not work, and in my case i couldn’t have used “driver.findElementByXPath(”//android.widget.TextView[@index=‘2’])" due the way it is designed.
But, i did it some other way!
@neharm24
instead of this you can use
driver.findElement(By.xpath("//android.widget.RelativeLayout[@index=‘2’]/android.widget.RelativeLayout[@index=‘1’]/android.widget.TextView[@index=‘2’]")).getText();
It will surly locate element
@pavant @Antony_Barnabas @rashiatry @neharm27 @willosser Iam using the below code to select the first three check box …but when first it check the first checkbox,then while selecting the second checkbox ,it automatically uncheck the first check box,pls solve this issue…how to select the multiple check box at a time
driver.findElement(By.xpath("//android.widget.LinearLayout[@index=‘0’]/android.widget.LinearLayout[@index=‘0’]/android.widget.CheckBox[@index=‘0’]")).click();
driver.findElement(By.xpath("//android.widget.LinearLayout[@index=‘1’]/android.widget.LinearLayout[@index=‘0’]/android.widget.CheckBox[@index=‘0’]")).click();
@suryasurendar, you state that the first check box becomes unchecked when selecting the second box. Is the second box getting checked? If not, then something is incorrect in your xpath. Please forgive me for asking this next questions – are the box selections mutually exclusive?
Yes, it is selecting the second box,no its not mutually exclusive
I’m at a loss to guess. I think I would break out the code so that the click action is separate from the call to findElement(). Verify the call to click() is causing both clicks to occur. Also, in order to assist, what version of Appium are you using? And what version of AppiumLib?