This site is in read only mode. Please continue to browse, but replying, likes, and other actions are disabled for now.
26 / 30
Oct 2017

Looks you have to use for locating " xpath, id, class name, accessibility id, -android uiautomator"

for example via xpath in ruby:
find_element(:xpath,"//android.widget.TextView[@text='Test']")

the old way locating elements was removed I believe....try to use XPATH for locating.

Yeah, I believe By.Name was deprecated in later versions of Appium. You'll need to pick a different identifier, like ID or if nothing else, xpath.

instated of By.name u can use By.id , latest version of appium they removed Name.

8 days later

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

6 months later
2 months later

Hi cepin one probelm is there in my side andriod 7.0 update the my device some elements is clicking and some element not cliking then appium server is stoped

Use debug mode to see why they are not “clicking”. In Android 7 some dialog buttons are all in uppercase, check if it might be that.

These way i am trying no element not found is comeing then it will be working on 5.0 device is perfectly working

Like I told, for me some dialog are appearing all in uppercase in Android 7 and not in Android 6 or below, that might be one reason.

If you want to place the example of one of those elements it doesn’t found, post that piece of code and a screenshot from uiautomatorviewer with that element details

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.

plz send me u r skype id i am share the screen then if u not possible my team viewer id