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

来源:互联网 发布:文章植入广告php源码 编辑:程序博客网 时间:2024/04/30 01:24

环境搭建

  • 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 webdriverfrom appium import webdriverfrom appium.webdriver.mobilecommand import MobileCommandfrom selenium.webdriver.common import action_chains, keysfrom appium.webdriver.common import touch_action,multi_actionimport time# Returns abs path relative to this file and not cwdPATH = 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:切换到webviewdriver.execute(MobileCommand.SWITCH_TO_CONTEXT, {"name":"WEBVIEW_com.sse.android.ssegwapp"})
native:切换到nativedriver.execute(MobileCommand.SWITCH_TO_CONTEXT, {"name":"NATIVE_APP"}) 
0 0
原创粉丝点击