Environment to build
python3
Java JDK
.netFramework
nodejs
android SDK
appium
Appium-Python-Client(pip install Appium-Python-Client)
Connected devices
cmd to open a command line window
enter adb connect 127.0.0.1:62001 connection simulator
input adb shell dumpsys window windows | findstr " Current" to get the current package name
start appium
Common elements positioned
driver.find_element_by_id
driver.find_element_by_class
driver.find_element_by_name
driver.find_element_by_xpath (// * [@ text = 'text attribute'])
Writing a login script
#!/usr/bin/env python # -*- coding: utf-8 -*- from appium import webdriver import unittest import time desired_caps = { 'platformName': 'Android', 'platfromVersion': '5.1', 'deviceName': '127.0.0.1:62001', 'appPackge': 'com.xxxx.artstation', 'appActivity': 'com.xxxx.artstation.main.login.activity.LoginActivity' } # TestCase class, the base class for all test cases inherited class LoginTest (unittest.TestCase): # initialization work before executing the test of DEF the setUp (Self): self.driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_caps) # Test the aftermath of the execution. Such as closing the database connection, exit the application. Whether writing where the last execution DEF tearDown (Self): self.driver.quit() # Test cases must start the Test DEF test_login (Self): self.driver.find_element_by_id('com.xxxx.artstation:id/tv_sure').click() time.sleep(3) # Enter the account password self.driver.find_element_by_id ( ' com.xxxx.artstation: ID / clear_edittext_username ' ) .send_keys ( ' 158xxxxxxxx ' ) self.driver.find_element_by_id( 'com.xxxx.artstation:id/clear_edittext_password').send_keys('123456') # Click the login button self.driver.find_element_by_id ( ' com.xxxx.artstation: the above mentioned id / tv_login ' ) .click time.sleep(3)
Automatic generation of test reports
#!/usr/bin/env python # -*- coding: utf-8 -*- import HTMLTestRunner import unittest from testcase import test_login IF the __name__ == ' __main__ ' : # instantiated test suite, a definition of the test vessel Suite = unittest.TestSuite () # loading test suite.addTest (test_login.LoginTest ( ' test_login ' )) # Using bulk loading methods discover test run # Suite = unittest.defaultTestLoader.discover ( '../ TestCase', '_ * Test. Py') # Runner = unittest.TextTestRunner () # -Defined test reports storage path and report name with Open ( ' HTMLReropt.html ' , ' wb ' ) AS f: runner = HTMLTestRunner.HTMLTestRunner( stream=f, verbosity=2, title = ' XX Log in automated test report ' , Description = " executor: hee ' ) runner.run(suite) # Turn off the test report f.close ()
Hornet's nest how to increase fans http://blog.sina.com.cn/s/blog_184e9f38b0102yyi5.html hornet's nest Travels promotion https://tieba.baidu.com/p/6427032866