程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Appium+python+pypharm environment setup and debugging

編輯:Python

https://www.cnblogs.com/softerware/p/10875664.html

Environment preparation and necessary plug-in installation

1 pc The physical machine

1.1.    python3

For detailed steps, please refer to the rookie tutorial https://www.runoob.com/python3/python3-install.html

① from python Download from the official website python3 Installation package , Version number selection 3.7.7 Or more

② install

③ Configure environment variables

④ Install the necessary plug-ins pytest、pytest-html、Appium-Python-Client

open cmd Command line tools

Input execution separately “pip install pytest”、 “pip install pytest-html” “pip install Appium-Python-Client”

1.2.    jdk + Android sdk

Please refer to https://www.cnblogs.com/qican/p/11077107.html

       ① download jdk Installation package , The version number is 1.8.0

   Download address :https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

   Platform selection Windows x86/Windows x64

       ② install jdk

       ③ To configure jdk environment variable

       ④ Download Android sdk Installation package ( Need to climb over the wall )

Download address :https://developer.android.com/studio/index.html

       ⑤ Configure environment variables

1.3.    appium-desktop

① Download installation package

Download address : Appium-windows-1.15.0.exe

1.4.    PyCharm

Download address ( Community Edition , Without registration )

http://www.jetbrains.com/pycharm/download/download-thanks.html?platform=windows

 

2 pc virtual machine

2.1.    python3

Application market download and installation python3, The version number is 3.7.5, The default installation path is C:\ThsSoftware\Python_ths

After the installation is successful, open cmd Command line tools

Input execution separately “pip install pytest”、 “pip install pytest-html” “pip install Appium-Python-Client”

2.2.    PyCharm

Open the application market of desktop ,“ development tool ” Under Options , choice PyCharm The professional version can be installed

PyCharm The default is built-in virtual environment , So it leads to PyCharm Internal python The plug-in is independent of the system environment .

In order to reduce the repeated installation of plug-ins , You need to manually switch to the system environment .

① open PyCharm Of File menu , Click on Settings Options

② Click on project Of the major events project interpreter Small term

③ Click the secondary menu of the right gear Add

④ Select the third item on the left “System Interpreter”, Choose... On the right “C:\ThsSoftware\Python_ths\python.exe”, Then make sure all the way

2.3.    sdk

① download  http://172.19.81.132/download/Sdk.zip

② decompression sdk.zip file

③ Add environment variables

  1) open “ Start ” menu , Click on the user's avatar

  2) Click on the left side of the “ Change my environment variables ”

  3) Find... In the user variables in the upper half “Path” And select , Click the edit button

  4) In the pop-up box “ A variable's value ” In the bar , take “ decompression sdk The path of \platform-tools” Append to variable value , Separated from the previous value by a semicolon

2.4.    jdk

Application market installation and download , Version selection JDK7

2.5.    Appium-desktop

① Download installation package

Download address : Appium-windows-1.15.0.exe

② install

③ Edit the configuration

appium After installation , function . Click... On the startup interface “ Edit the configuration ”, Fill in the extracted file sdk Folder path and jdk Installation path for , Save and restart

2.6 Real connection

④ Open the command line tool , Input “adb connect 10.10.25.153:31454”, It can be completed under normal circumstances adb Remote connection , The connection address can be found on the cloud real machine platform .

If you are prompted failed, Please check your cell phone adb Authorization pop-up status

perform “adb kill-server” retry

 

3 mac

Please refer to the following document

http://172.20.200.191:8003/pages/viewpage.action?pageId=354058459


Framework code specification

Naming style

  1. Folder name 、 file name 、 Variable names use lowercase underline style ( Lowercase letters , Different semantic phrases are underlined ). Such as :report_centerindex_page.pyindex_btn
  2. All words shall be given full English names or abbreviations , Do not use Chinese pinyin .
  3. The class name is big hump style . Such as :HomePage
  4. In general : Folders represent modules , Files represent function points , Pay attention to clear semantics when naming , Do not confuse or mislead .

File hierarchy

page Catalog

  1. For there is a new page Create a new page, Give priority to title block naming , If the title will change, it will be named according to the page function .
  2. All large modules need to create folders , Sub modules can be split and written according to sub pages , The principle is to inherit when there are large module elements , Otherwise, do not inherit .
  3. Page elements are directly defined in classes in the form of attributes .
  4. Pages can be reused 、 Data driven actions are all encapsulated in methods or functions page Under the class , When you need to ensure that test cases are written , You can find the elements and methods to be operated under the class of the current page .
  5. Involving system level operations or those that cannot be classified page Put it in public Under the table of contents .

cases Catalog

  1. Test cases are stored according to the business tree , Single .py Don't prevent too many files case, Split according to its function .
  2. Test case set file naming rules :test_*.py
  3. The internal test cases follow function an ,function Naming rules :test_*
  4. Test cases are generally in accordance with JIRA Test case generation in , The test cases that cannot be implemented are marked with skip label .
  5. The principle is that a single test case can be executed , Package debugging / Test mode , There will be dependent test cases to support a single debug execution , For dependent test cases , In the play dependency label .

common Catalog

  1. This directory encapsulates some system level general functions , It does not involve operations and dependencies on specific page elements
  2. Yes, some appium The built-in functions of , Such as wifi Operation class .

conftest.py

    pytest Default configuration file , Inject machine connection test logic here


1、 Test account problem .
Test premise : The backstage has not passed the audit
Test premise : The background has been approved
Test data : Test premise : Not that year, not that day
Test data : Test premise : There is no official account information submitted by users in the background
expect : Automatic approval passed , There is no need for the operation to pass the manual review again

【 Solution 】 Multiple accounts keep their respective status for verification ., Switch account verification .

2、 The refresh check interval is too short , Verification failed
expect :1、 Show Chrysanthemum 2、 written words : Loading (ios)

【 Solution 】 This test case uses weak verification , Catch an exception where a transient element cannot be found , Continue the verification in the following steps .

3、 Font color verification problem
expect : The title of the article is in black
expect : The title of the article turns grey

【 Solution 】 Add pixel comparison and picture comparison functions ,TODO

4、 Gesture drag
Gesture drag the right side of the column to sort , Drag official account information tab To essence Research Report tab below

【 Solution 】 Encapsulate a drag and drop method support ,TODO

5、 data verification expect : And PC Agreement ( Not likely )

【 Solution 】 Realize data consistency verification through interface test .


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved