Appium学习

freerocker 2020-06-12

from appium import webdriver
import unittest
import time

class QQlogin(unittest.TestCase):
    def setUp(self):
        desired_caps = {‘platformName‘: ‘Android‘, # 平台名称
                        ‘platformVersion‘: ‘5.1.1‘,  # 系统版本号
                        ‘deviceName‘: ‘127.0.0.1:62001‘,  # 设备名称。如果是真机,在‘设置->关于手机->设备名称‘里查看
                        ‘appPackage‘: ‘com.tencent.mobileqq‘,  # apk的包名
                        ‘appActivity‘: ‘com.tencent.mobileqq.activity.LoginActivity‘  # activity 名称
                        }
        self.driver = webdriver.Remote("http://127.0.0.1:4723/wd/hub", desired_caps)  # 连接Appium
        self.driver.implicitly_wait(15)
        time.sleep(15)

    def test_login(self):
        el1 = self.driver.find_element_by_id("com.tencent.mobileqq:id/btn_login")
        el1.click()
        el2 = self.driver.find_element_by_accessibility_id("请输入QQ号码或手机或邮箱")
        el2.send_keys("xxxxxx")
        el3 = self.driver.find_element_by_accessibility_id("密码 安全")
        el3.send_keys("xxxxxx")
        el4 = self.driver.find_element_by_accessibility_id("登 录")
        el4.click()

    def tearDown(self):
        self.driver.quit()


if __name__ == ‘__main__‘:
    unittest.main()

QQ登录

相关推荐