在模拟器上登录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()
本文来自博客园,作者:河北大学-徐小波,转载请注明原文链接:https://www.cnblogs.com/xuxiaobo/p/17056039.html

【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步