Appium+python Automation 26-Analog gesture Click Coordinates (TAP) "Reprint"

Source: Internet
Author: User
Tags appium

? # Preface:
Sometimes when positioning elements, you have resorted to 18 classes of martial arts or not located, how to do? (interviews are often asked)
Then take the trick: coordinates of the location of the point element

Tap usage

1.TAP is analog finger click, General page elements
The syntax has two parameters, the first is positions, is the list type up to five points, the duration is the duration, unit milliseconds

tap(self, positions, duration=None):    on an particular place with up to five fingers, holding for a certain time        模拟手指点击(最多五个手指),可设置按住时间长度(毫秒)        :Args:        - positions - list类型,里面对象是元组,最多五个。如:[(100, 20), (100, 60)] - duration - 持续时间,单位毫秒,如:500 :Usage: driver.tap([(100, 20), (100, 60), (100, 100)], 500)
Coordinate positioning

1. If you position "go to see" The coordinates of this button, you can see the right bonds property: [374,831][654,906]

2. Click the "Search" button in the upper right corner to view the Bonds properties: [615,52][690,146]

Reference case
# Coding:utf-8From AppiumImport WebdriverFrom timeImport Sleepdesired_caps= {' PlatformName ':' Android ',' DeviceName ':' 127.0.0.1:62001 ',' Platformversion ':' 4.4.2 ',' Apppackage ': ' com.baidu.yuedu ',  Appactivity ':  ' com.baidu.yuedu.splash.SplashActivity '}driver = webdriver. Remote ( ' Http://127.0.0.1:4723/wd/hub ', desired_caps) sleep ( 5) # point pop-up box to see Driver.tap ([(374, 831), ( Span class= "DV" >654, 906)], 500) # Return to previous page Driver.back () Sleep (2) # point upper right corner of the search button Driver.tap ([ Span class= "DV" >615, 52), (690, 146)], 500)  
Disadvantages

Coordinate positioning is the bottom of the element positioning, there is no way to use this, in addition, if the phone resolution, the coordinates can not be written dead, to calculate the proportion of the screen.

Appium+python Automation 26-Analog gesture Click Coordinates (TAP) "Reprint"

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.