Skip to content

Latest commit

 

History

History
59 lines (42 loc) · 1.27 KB

mobile_methods.md

File metadata and controls

59 lines (42 loc) · 1.27 KB

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'