This Appium Cheat Sheet covers most of the commands and actions used in Appium Projects. This Cheat Sheet is divided into 5 sections based on its function.
In this section, we will see session cheat sheets.
Session Cheat Sheet
|
Command |
Description |
Example / Notes |
|
Create Session |
Starts a new Appium session by sending desired capabilities to the Appium server. |
WebDriver client initiates with driver = new AppiumDriver(url, capabilities) |
|
End Session |
Terminates the session and closes the app/driver |
driver.quit() |
|
newCommandTimeout |
Session capability that defines the maximum seconds Appium waits before ending an idle session. |
Example: newCommandTimeout: 60 |
|
Get Session Details |
Retrieves current session info including capabilities. |
driver.getSession() |
|
Set Orientation |
Changes screen orientation to portrait or landscape. |
driver.rotate(ScreenOrientation.LANDSCAPE) |
|
Get Orientation |
Returns the current screen orientation. |
driver.getOrientation() |
|
Set Geolocation |
Mocks GPS location of device. |
driver.setLocation(new Location(37.7749, -122.4194, 10)) |
|
Get Geolocation |
Returns current device GPS coordinates. |
driver.location() |
|
Get Session Logs |
Fetches logs for various log types (logcat, syslog, crashlog, etc.). |
driver.manage().logs().get("logcat") |
|
Available Log Types |
Lists available log types for the session. |
driver.manage().logs().getAvailableLogTypes() |
|
Start Recording Screen |
Begins capturing device screen. |
driver.startRecordingScreen() |
|
Stop Recording Screen |
Stops capture and returns Base64 video string. |
driver.stopRecordingScreen() |
|
Get Performance Data |
Fetches app/device performance data (Android only). |
driver.getPerformanceData("com.myapp", "cpuinfo", 5) |
|
Events (Start) |
Enable collection of Appium internal events. |
driver.logEvent("eventName") |
|
Events (Retrieve) |
Retrieve recorded event timings. |
driver.getEvents() |