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"