Welcome to 徐小波’s bl|

河北大学-徐小波

园龄:2年2个月粉丝:1关注:4

在模拟器上登录qq,自动化登录qq

环境:

java version "1.8.0_73"

Python ActivePython 3.8.2

Appium Server GUI

Appium Inspector

夜神模拟器

cmd adb

 

代码:

复制代码
# This sample code uses the Appium python client v2
# pip install Appium-Python-Client
# Then you can paste this into a file and simply run with Python

from appium import webdriver
from appium.webdriver.common.appiumby import AppiumBy

# For W3C actions
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.actions import interaction
from selenium.webdriver.common.actions.action_builder import ActionBuilder
from selenium.webdriver.common.actions.pointer_input import PointerInput

caps = {}
caps["platformName"] = "Android"
caps["appium:platformVersion"] = "7.1.2"
caps["appium:deviceName"] = "127.0.0.1:62001"
caps["appium:appPackage"] = "com.tencent.mobileqq"
caps["appium:appActivity"] = "com.tencent.mobileqq.activity.SplashActivity"
caps["appium:automationName"] = "UiAutomator1"
caps["appium:ensureWebviewsHavePages"] = True
caps["appium:nativeWebScreenshot"] = True
caps["appium:newCommandTimeout"] = 3600
caps["appium:connectHardwareKeyboard"] = True

driver = webdriver.Remote("http://127.0.0.1:4723/wd/hub", caps)


driver.implicitly_wait(5)
el1 = driver.find_element(by=AppiumBy.ACCESSIBILITY_ID, value="同意")
el1.click()


driver.implicitly_wait(10)
el2 = driver.find_element(by=AppiumBy.ID, value="com.tencent.mobileqq:id/btn_login")
el2.click()


driver.implicitly_wait(5)
driver.find_element(AppiumBy.XPATH, '//android.widget.EditText[@content-desc="请输入QQ号码或手机或邮箱"]').clear()
driver.find_element(AppiumBy.XPATH, '//android.widget.EditText[@content-desc="请输入QQ号码或手机或邮箱"]').send_keys("61144510")

driver.implicitly_wait(3)
driver.find_element(AppiumBy.ID, "com.tencent.mobileqq:id/password").click()
driver.find_element(AppiumBy.ID, "com.tencent.mobileqq:id/password").send_keys("aabbccdd")

driver.implicitly_wait(5)
driver.find_element(AppiumBy.ID, "com.tencent.mobileqq:id/login").click()

driver.implicitly_wait(5)
driver.find_element(AppiumBy.ID, "com.tencent.mobileqq:id/dialogRightBtn").click()

driver.implicitly_wait(5)
driver.find_element(AppiumBy.ID, "com.android.packageinstaller:id/permission_allow_button").click()

driver.implicitly_wait(5)
driver.find_element(AppiumBy.ID, "com.android.packageinstaller:id/permission_allow_button").click()

driver.implicitly_wait(10)
driver.find_element(AppiumBy.ID, "com.tencent.mobileqq:id/oog").click()

driver.implicitly_wait(5)
driver.find_element(AppiumBy.ID, "com.android.packageinstaller:id/permission_allow_button").click()


driver.implicitly_wait(100)
#driver.quit()
复制代码

 

posted @   河北大学-徐小波  阅读(194)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示
评论
收藏
关注
推荐
深色
回顶
收起