appium移动自动化测试---Android

环境搭建

  • JDK
  • SDK
  • node.js
  • Python
  • Appium
  • Appium-Python-Client
    pip install Appium-Python-Client /pip3 install Appium-Python-Client 有时需要翻墙才下得动

  • sublime Text 3
    编写脚本


脚本API

  • appium.webdriver
# -*- coding: utf-8 -*-
import os
# from selenium import webdriver
from appium import webdriver
from appium.webdriver.mobilecommand import MobileCommand
from selenium.webdriver.common import action_chains, keys
from appium.webdriver.common import touch_action,multi_action
import time

# 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['platformName'] = 'Android'
desired_caps['deviceName'] = 'Galaxy S6 edge+'
desired_caps['browserName'] = ''
# desired_caps['version'] = '6.0'
desired_caps['app'] = PATH('D:\\APK\\sss\\ssss_s.apk')
desired_caps['app-package'] = 'com.example.android.contactmanager'
desired_caps['app-activity'] = '.controller.LaunchActivity'
# desired_caps['noReset'] = 'True'
desired_caps['chromedriverExecutable'] = PATH('D:\\tools\\aotuTest\\Appium\\node_modules\\appium\\node_modules\\appium-chromedriver\\chromedriver\\win\\chromedriver.exe')
desired_caps['resetKeyboard'] = 'True'
desired_caps['unicodeKeyboard'] = 'True'

driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
action = action_chains.ActionChains(driver)
weview:切换到webview
driver.execute(MobileCommand.SWITCH_TO_CONTEXT, {"name":"WEBVIEW_com.sse.android.ssegwapp"})
native:切换到native
driver.execute(MobileCommand.SWITCH_TO_CONTEXT, {"name":"NATIVE_APP"}) 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值