still facing the same problem
used the command
driver.findElement(MobileBy.name("MyApp")).Click();
appium 1.4.16.1 it is working debug messages as follows
info: --> POST /wd/hub/session/78d80129-b6b0-42a6-8a8d-77491efea950/element {"using":"name","value":"MyApp"}
info: [debug] Waiting up to 0ms for condition
info: [debug] Pushing command to appium work queue: ["find",{"strategy":"name","selector":"MyApp","context":"","multiple":false}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"name","selector":"MyApp","context":"","multiple":false}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: find
info: [debug] [BOOTSTRAP] [debug] Finding MyApp using NAME with the contextId: multiple: false
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[DESCRIPTION=MyApp, INSTANCE=0]
info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":{"ELEMENT":"1"}}
info: [debug] Responding to client with success: {"status":0,"value":{"ELEMENT":"1"},"sessionId":"78d80129-b6b0-42a6-8a8d-77491efea950"}
info: <-- POST /wd/hub/session/78d80129-b6b0-42a6-8a8d-77491efea950/element 200 65.656 ms - 87 {"status":0,"value":{"ELEMENT":"1"},"sessionId":"78d80129-b6b0-42a6-8a8d-77491efea950"}
info: --> POST /wd/hub/session/78d80129-b6b0-42a6-8a8d-77491efea950/element/1/click {"id":"1"}
info: [debug] Pushing command to appium work queue: ["element:click",{"elementId":"1"}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"element:click","params":{"elementId":"1"}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: click
info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":true}
info: [debug] Responding to client with success: {"status":0,"value":true,"sessionId":"78d80129-b6b0-42a6-8a8d-77491efea950"}
info: <-- POST /wd/hub/session/78d80129-b6b0-42a6-8a8d-77491efea950/element/1/click 200 186.314 ms - 76 {"status":0,"value":true,"sessionId":"78d80129-b6b0-42a6-8a8d-77491efea950"}
Appium 1.6.3
HTTP] --> POST /wd/hub/session/fe618bfd-4a70-44e0-a0be-b0f2000878af/element {"u
sing":"name","value":" MyApp"}
[debug] [MJSONWP] Calling AppiumDriver.findElement() with args: ["name","MyApp","fe618bfd-4a70-44e0-a0be-b0f2000878af"]
[debug] [BaseDriver] Valid locator strategies for this request: xpath, id, class
name, accessibility id, -android uiautomator
[HTTP] <-- POST /wd/hub/session/fe618bfd-4a70-44e0-a0be-b0f2000878af/element 500
22 ms - 144
[HTTP] --> GET /wd/hub/session/fe618bfd-4a70-44e0-a0be-b0f2000878af/screenshot {
}
please advice
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