Hi,
I’m using Appium to automate my app.
My code is with Java
Appium UI Version 1.4 or 1.9
Appium Jar: 6.1.0
Junit: 4.9
Device: Android Version 6.0
The problem is that sendKey method doesn’t send the text to the field but appium think that the command pass.
*click action works as expected
This is the code:
private AndroidDriver driver;
private WebDriverWait wait;
@Test
public void my_Test() throws MalformedURLException{
driver = new AndroidDriver<AndroidElement>(new URL("http://127.0.0.1:4723/wd/hub"), GetAndroidCapabilities());
wait = new WebDriverWait(driver, 60);
wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//*[@resource-id='login']")));
driver.findElement(By.xpath("//*[@resource-id='login']")).sendKeys("Test");
}
public static DesiredCapabilities GetAndroidCapabilities()
{
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability(MobileCapabilityType.PLATFORM_NAME, "Android");
cap.setCapability(MobileCapabilityType.PLATFORM_VERSION, "6.0");
cap.setCapability(MobileCapabilityType.DEVICE_NAME, "MiAutoTest");
cap.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, "3000");
cap.setCapability(MobileCapabilityType.NO_RESET, true);
cap.setCapability("appPackage", "com.CL.Mobile");
cap.setCapability("appActivity", "com.CL.Mobile.MainActivity");
return cap;
}
This is the Appium log related to the sendkey command:
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: find
info: [debug] [BOOTSTRAP] [debug] Finding //*[@resource-id=‘PGV2login’] using XPATH with the contextId: multiple: false
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[CLASS=android.widget.EditText, INSTANCE=0]
info: [debug] [BOOTSTRAP] [debug] Returning result: {“status”:0,“value”:{“ELEMENT”:“2”}}
info: [debug] Responding to client with success: {“status”:0,“value”:{“ELEMENT”:“2”},“sessionId”:“35d3816e-ee78-4b27-9cfd-d0b5b3548974”}
info: <-- POST /wd/hub/session/35d3816e-ee78-4b27-9cfd-d0b5b3548974/element 200 128.967 ms - 87 {“status”:0,“value”:{“ELEMENT”:“2”},“sessionId”:“35d3816e-ee78-4b27-9cfd-d0b5b3548974”}
info: --> POST /wd/hub/session/35d3816e-ee78-4b27-9cfd-d0b5b3548974/element/2/value {“id”:“2”,“value”:[“Test”]}
info: [debug] Pushing command to appium work queue: [“element:setText”,{“elementId”:“2”,“text”:“Test”,“replace”:false}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {“cmd”:“action”,“action”:“element:setText”,“params”:{“elementId”:“2”,“text”:“Test”,“replace”:false}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: setText
info: [debug] [BOOTSTRAP] [debug] Using element passed in.
info: [debug] [BOOTSTRAP] [debug] Attempting to clear using UiObject.clearText().
info: [debug] [BOOTSTRAP] [debug] Sending plain text to element: Test
info: [debug] [BOOTSTRAP] [debug] Returning result: {“status”:0,“value”:true}
info: [debug] Responding to client with success: {“status”:0,“value”:true,“sessionId”:“35d3816e-ee78-4b27-9cfd-d0b5b3548974”}
info: <-- POST /wd/hub/session/35d3816e-ee78-4b27-9cfd-d0b5b3548974/element/2/value 200 6004.694 ms - 76 {“status”:0,“value”:true,“sessionId”:“35d3816e-ee78-4b27-9cfd-d0b5b3548974”}