Reputation: 173
I have this below snippet of code in my automation framework
public void settings() {
try {
//((AndroidDriver) Driver).pressKeyCode(AndroidKeyCode.SETTINGS);
((AndroidDriver) Driver).pressKey(new KeyEvent(AndroidKey.SETTINGS));
updateTestLog(Action, "settings pressed", Status.PASS);
} catch (Exception ex) {
updateTestLog(Action, ex.getMessage(), Status.DEBUG);
Logger.getLogger(KeyActions.class.getName()).log(Level.SEVERE, null, ex);
}
}
I have connected with the mobile and see if it's working fine. In Appium server got log traces that Key code 176 (Settings) worked fine. But no action in mobile screen
I have tried it for different keys like "Menu","home","search" and "enter". I see it is executed and working fine in mobile.
Upvotes: 0
Views: 293
Reputation: 168072
If you need to open Settings Menu I believe the best option would be calling driver.startActivity() function like:
((AndroidDriver) driver).startActivity(new io.appium.java_client.android.Activity("com.android.settings",".Settings"));
If you're looking for a cross-platform solution it might be easier to go for Launch command available via SeeTest Appium Extension
Upvotes: 1