zoukankan      html  css  js  c++  java
  • python3+Appium自动化03-Appium元素检测

    需要导入方法NoSuchElementException

     1 from appium import webdriver
     2 from selenium.common.exceptions import NoSuchElementException
     3 import time
     4 desired_caps = {
     5                 #android的apk
     6                 'platformName': 'Android',
     7                 #手机设备名称
     8                 'deviceName': '192.168.175.101:5555',
     9                 #android系统的版本号
    10                 'platformVersion': '4.4.4',
    11                 # 'deviceName': 'ceshi',
    12                 # 'platformVersion': '7.0',
    13                 # 'udid':'83f04b4b5338424e',
    14 
    15 
    16                 'app':r'C:UserszARTDesktopapp-artmall-release.apk',
    17                 # apk包名
    18                 'appPackage': 'com.baozhenart.artmall',
    19                 # apk的launcherActivity
    20                 'appActivity': 'com.baozhenart.artmall.SplashActivity',
    21                 #默认neReset为false,不要在会话前重置应用状态,每次启动都跟第一次启动一样,变为true则不一样
    22                 'noReset':'True',
    23                 #下面两行代码是为了屏蔽软件盘以至于可以输入中文
    24                 'unicodeKeyboard':True,#使用unicode编码方式发送字符串
    25                 'resetKeyboard':True#将键盘隐藏起来
    26                 }
    27 driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_caps)
    28 #检测跳过按钮
    29 def check_skipBtn():
    30     print('check skipBtn')
    31     try:
    32         skipBtn=driver.find_element_by_id("com.baozhenart.artmall:id/tv_skip")
    33     except NoSuchElementException:
    34         print('no skipBtn')
    35     else:
    36         skipBtn.click()
    37 time.sleep(5)
    38 #检测是否有叉号
    39 def check_closeBtn():
    40     print('check closeBtn')
    41     try:
    42         closeBtn=driver.find_element_by_id("com.baozhenart.artmall:id/iv_close")
    43     except NoSuchElementException:
    44         print('no closeBtn')
    45     else:
    46         closeBtn.click()
    47 check_skipBtn()
    48 check_closeBtn()
  • 相关阅读:
    101. Symmetric Tree(js)
    100. Same Tree(js)
    99. Recover Binary Search Tree(js)
    98. Validate Binary Search Tree(js)
    97. Interleaving String(js)
    96. Unique Binary Search Trees(js)
    95. Unique Binary Search Trees II(js)
    94. Binary Tree Inorder Traversal(js)
    93. Restore IP Addresses(js)
    92. Reverse Linked List II(js)
  • 原文地址:https://www.cnblogs.com/shenhainixin/p/9271890.html
Copyright © 2011-2022 走看看