私はモバイルオートメーションを初めて使いました。私はAndroidで(Javaを使用して)ソフトキーボードを閉じる方法を見つけようとしています。私がこれまでに遭遇した最高のソリューションは、このポストからだった:ソフトキーボードを閉じるためにアクティビティから関数を呼び出すandroid
Close/hide the Android Soft Keyboard
私はそこから使用しようとしている機能は次のとおりです。
public static void hideKeyboard(Activity activity) {
InputMethodManager imm = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
//Find the currently focused view, so we can grab the correct window token from it.
View view = activity.getCurrentFocus();
//If no view currently has focus, create a new one, just so we can grab a window token from it
if (view == null) {
view = new View(activity);
}
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
私のことができるようにしたいですキーボードがポップアップしたときにこの関数を呼び出しますが、私が理解していないことは、この関数を呼び出すときにアクティビティをどのように渡すかです。 Activityオブジェクトの参照を意味=>activity
// Create object of DesiredCapabilities class and specify android platform
DesiredCapabilities capabilities = DesiredCapabilities.android();
// set the capability to execute test in android app
capabilities.setCapability(MobileCapabilityType.PLATFORM, Platform.ANDROID);
capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, "Android");
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "Emulator_1");
capabilities.setCapability(MobileCapabilityType.VERSION, "8.0");
capabilities.setCapability("appPackage", "com.spreeza.shop.stag.debug");
capabilities.setCapability("appActivity", "com.spreeza.shop.ui.features.splash.EntryPointActivity");
driver = new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
// click on the login button
driver.findElement(By.id(identifierName)).click();
// close the keyboard
hideKeyboard();
KeyBoardアクティビティがあるときにポップアップします。 hideKeyboard(YourActivity.this)または単にhideKeyboard(this)を呼び出します。 – ADM
あなたのアクティビティが開いたときにキーボードがポップアップしますか? – tahsinRupam