Skip to content

Instantly share code, notes, and snippets.

@thu2004
Last active August 29, 2015 14:10
Show Gist options
  • Save thu2004/108139e452daade230b7 to your computer and use it in GitHub Desktop.
Save thu2004/108139e452daade230b7 to your computer and use it in GitHub Desktop.
Automate Android app with Appium - Selendroid - Python
from selenium import webdriver
from selenium.webdriver.common.touch_actions import TouchActions
from time import sleep
desired_caps = {}
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '4.1'
desired_caps['deviceName'] = 'Android'
desired_caps['automationName'] = "selendroid"
desired_caps['app'] = '/Users/chitl/projects/ws_android/InteractiveChartApp/bin/InteractiveChartApp.apk'
desired_caps['app-package'] = 'com.example.android.interactivechart'
desired_caps['app-activity'] = 'com.example.android.interactivechart.MainActivity'
desired_caps['app-wait-activity'] = 'MainActivity'
desired_caps['newCommandTimeout'] = '600'
driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
x=20
y=900
TouchActions(driver).tap_and_hold(x, y).perform()
sleep(2)
TouchActions(driver).move(x+100, y).perform()
sleep(2)
TouchActions(driver).release(x+100, y).perform()
driver.quit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment