Skip to content

Instantly share code, notes, and snippets.

@jollychang
Created September 4, 2014 06:51
Show Gist options
  • Save jollychang/144d3399bdc68a4d4965 to your computer and use it in GitHub Desktop.
Save jollychang/144d3399bdc68a4d4965 to your computer and use it in GitHub Desktop.
appium for highlife android script
#!/usr/bin/env python
# coding: utf-8
import os
from time import sleep
from selenium import webdriver
# Returns abs path relative to this file and not cwd
PATH = lambda p: os.path.abspath(os.path.join(os.path.dirname(__file__), p))
desired_caps = {}
desired_caps['device'] = 'Android'
desired_caps['browserName'] = ''
desired_caps['version'] = '4.2'
desired_caps['app'] = PATH(
'/Users/jollychang/tmp/DoubanHighLife-Android-Gradle-test-release.apk'
)
desired_caps['app-package'] = 'com.douban.highlife'
desired_caps['app-activity'] = '.ui.welcome.Splash'
driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
print driver.get_window_size()
def login(email='[email protected]', password='douban123'):
elem = driver.find_element_by_name('登录')
elem.click()
elem = driver.find_element_by_name('豆瓣帐号')
elem.send_keys('[email protected]')
elem = driver.find_elements_by_class_name('android.widget.EditText')[1]
elem.send_keys('douban123')
elem = driver.find_elements_by_class_name('android.widget.Button')[0]
# elem = driver.find_element_by_name('登录')
elem.click()
# driver.quit()
#!/usr/bin/env python
# coding: utf-8
import unittest
import os
from random import randint
from selenium import webdriver
app = "/Users/jollychang/Library/Application Support/iPhone Simulator/7.0/Applications/F83C1B08-D2D2-4CD9-B78D-DE9A9B937006/DoubanChannel.app"
app = os.path.abspath(app)
driver = webdriver.Remote(
command_executor='http://127.0.0.1:4723/wd/hub',
desired_capabilities={
'browserName': '',
'device': 'iPhone Simulator',
'platform': 'Mac',
'version': '7.0',
'app': app
})
e = driver.find_element_by_name('发现')
e.click()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment