python3 操作appium

# -*- coding: utf-8 -*-
# @Time    : 2018/10/9 13:53
# @Author  : cxa
# @File    : start_appium.py
# @Software: PyCharm
from appium import webdriver
import time
import base64
desired_caps = {}
desired_caps['platformName'] = 'Android'  # 设备系统
desired_caps['deviceName'] = '127.0.0.1:62001'  # 设备名称
desired_caps['appPackage'] = 'com.alicom.smartdail'  # 测试app包名
desired_caps['appActivity'] = 'com.alicom.smartdail.view.enter.SplashActivity'  # 测试appActivity
desired_caps['platformVersion'] = '4.4.2'  # 设备系统版本
desired_caps['noReset'] = True  # 启动后结束后不清空应用数据
desired_caps['unicodeKeyboard'] = True  # 此两行是为了解决字符输入不正确的问题
desired_caps['resetKeyboard'] = True  # 运行完成后重置软键盘的状态  
driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)  # 启动app
print(driver.page_source)
# # 开始登录
# id_xpath = '//android.widget.EditText[@content-desc="账户名输入框"]'
# id_node = driver.find_element_by_xpath(id_xpath)
# id_node.clear()
# id_node.send_keys("id")
# pwd=str(base64.b64decode("aiU3QiVGNyVFM3AlRUMlQjAlMDAlMDA="), 'u8')
# pwd_xpath='//android.widget.EditText[@content-desc="密码输入框"]'
# pwd_node = driver.find_element_by_xpath(pwd_xpath)
# pwd_node.clear()
# pwd_node.send_keys(pwd)
# submit="//android.widget.Button[@text='登录']"
# submit_node=driver.find_element_by_xpath(submit)
# submit_node.click()
# time.sleep(10)
print(driver.get_cookies())
time.sleep(20)

  

猜你喜欢

转载自www.cnblogs.com/c-x-a/p/9760420.html