[英]Not able to click on button in android native app using appium 1.6.4
[英]Not able to click a button which is not enabled using Appium Java for Android app
首先设置以下功能:
capabilities.setCapability("unicodeKeyboard", true);
capabilities.setCapability("resetKeyboard", true);
第二种尝试通过以下方式隐藏键盘:
driver.hideKeyboard(); // doesn't work on newer versions of appium
或尝试以下方法:
driver.pressKeyCode(AndroidKeyCode.BACK); //this also doesn't work on all devices but give it a try
对于日期控件,我不太确定您使用的是日期选择器还是某些自定义的日期控件,但是在每个操作上都尝试隐藏键盘。
嗨,您可以使用以下代码段隐藏软键盘。 这个对我有用。
public void someMethod(){
driver.getKeyboard();
try {
if (checkSoftKeyboard())
driver.hideKeyboard();
} catch (IOException e) {
e.printStackTrace();
}
}
public boolean checkSoftKeyboard() throws IOException {
boolean isKeyboardPresent = false;
Process p = Runtime.getRuntime().exec("adb shell dumpsys input_method | grep mInputShown");
BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
String outputText = "";
while ((outputText = in.readLine()) != null) {
if(!outputText.trim().equals("")){
String keyboardProperties[]=outputText.split(" ");
String keyValue[]=keyboardProperties[keyboardProperties.length-1].split("=");
String softkeyboardpresenseValue=keyValue[keyValue.length-1];
if(softkeyboardpresenseValue.equalsIgnoreCase("false")){
isKeyboardPresent=false;
}else{
isKeyboardPresent=true;
}
}
}
in.close();
return isKeyboardPresent;
}
checkSoftKeyboard方法将检查软键盘是否已经存在? 如果在那里,它将仅隐藏软键盘。 然后您将能够看到“ 转移”按钮。
希望这对您有用。 谢谢!
我能够解决这个问题。 我的方法是先单击“金额”字段,然后向sendkeys输入金额的值。 有关详细信息,请参见以下代码:-
//locating the amount field using xpath
MobileElement amount = driver.findElement(By.xpath("//android.widget.EditText[@resource-id='com.abc.rbanking:id/workflow_step_amount_value']"));
amount.click();
amount.sendKeys("1.25");
//clicking and sendkeys would enable the disabled 'Transfer' button
//locating the 'Date' field and click it. Clicking it would get rid of soft android keyboard
driver.findElement(By.xpath("//*[@text = 'Date']")).click();
Thread.sleep(3000);
driver.findElement(By.id("com.abc.rbanking:id/back_button")).click();
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
driver.findElement(By.xpath("//android.widget.Button[@resource-id='com.abc.rbanking:id/PrimaryButton' and @text='Transfer']")).click();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.