orString name = "some_text";
((AndroidDriver)driver).findElementByAndroidUIAutomator("new UiSelector().text(\"" + name + "\")")
- for Android (it is should be faster then xPath)
try - https://github.com/appium/java-client/wiki32 to see commands
Hi Cepin
I was really glad that Xpath was useful, so i easy converted Byname to ByXpath
but again i have strucked up
i need to pass a set of string values to array
one by one text i need to validate whether that element is available in my device or not
Initially my code was working with Byname now as i have to use double quotes for Xpath my Array value getting converted into normal texts
so what syntax i can use
code snippet:
int count = 0;
//To verify the following elements are present in the login page
String[] myArr = {"test IDs", "Usage without logging in", "com.test.mobile.android.mytest:id/body_icon", "com.test.mobile.android.mytelstra:id/auth_info_button"};
for(int i =0; i<myArr.length; i++){
try{
if(myArr[i].contains("com.test")){
MobileElement e = driver.findElement(By.id(myArr[i]));
System.out.println(e);
count++;
}
else{
// MobileElement e = driver.findElement(By.name(myArr[i])); //old syntax how to give the xpath
MobileElement e = driver.findElementByXPath("//android.widget.TextView[@text='(myArr[i])']"); //not working wont work resolution needed for this line of code
System.out.println(e);
count++;
}
}
catch (NoSuchElementException e){
System.out.println(myArr[i] + " not found");
Reporter.log("Screen Element" + " " + myArr[i] + " " + "not found");
getScreenshot("Failed Screenshot/_Skip_Login_MobEle_myLogin Not Found");
}
the ouput i am getting is "test IDs not found"
Hi @Test_Market,
Could you try:
MobileElement e = driver.findElementByXPath("//android.widget.TextView[@text='"+myArr[i]+"']");
Magali
@ackck maybe you have UI version of Appium ? You can download any UI version from here - https://github.com/appium/appium-desktop/releases37
Dont see any error or click in the screenshot of logs. Paste complete logs on https://gist.github.com/3 and place the link in here.
Like i told you, best way is to run test in debug mode, place a break point before clicking and run some commands directly from IDE to find out what element you are receiving.