mirror of
https://github.com/appium/appium.git
synced 2026-01-25 11:48:49 -06:00
1.3 KiB
1.3 KiB
Cross platform mobile methods
Reset
Mobile reset will reset the app's state.
Ruby + appium_lib gem
mobile :reset
Ruby without the gem
@driver.execute_script 'mobile: reset'
Android mobile methods
KeyEvent
KeyEvent enables sending a keycode to Android.
Press the system menu button in Java.
HashMap<String, Integer> keycode = new HashMap<String, Integer>();
keycode.put("keycode", 82);
((JavascriptExecutor)driver).executeScript("mobile: keyevent", keycode);
Ruby + appium_lib gem
mobile :keyevent, keycode: 82
Ruby without the gem
@driver.execute_script 'mobile: keyevent', :keycode => 82
Mobile find
Java
JSONArray json = new JSONArray();
json.put("scroll");
json.put(new JSONArray().put(new JSONArray().put(3).put("Gallery")));
json.put(new JSONArray().put(new JSONArray().put(7).put("Gallery")));
// json is now: ["scroll",[[3,"Gallery"]],[[7,"Gallery"]]]
((JavascriptExecutor) driver).executeScript("mobile: find", json);
Ruby + appium_lib gem
scroll_to 'Gallery'