zoukankan      html  css  js  c++  java
  • Python+Appium手机纯H5页面测试

    主要以下几点:

    1.浏览器选对,不要选UC之类的,选择Chrome浏览器

    2.具体脚本实则是使用selenium编写,Appium起到启动手机

    3.注意appium里有的方法并不能使用,如tap

    4.关闭Chrome浏览器自动翻译功能:这个只能通过切换到Chromium关闭,加Noreset参数无效,去设置里没有用,因为selenium里打开一个新的网页是不是也没有加载缓存,一个道理

    #coding:utf-8
    from appium import webdriver
    from selenium.webdriver.support.ui import WebDriverWait
    import time,os
    url='https://xxxxxxxxxxxxxxxxxxxxxxxx'
    desired_caps = {'platformName': 'Android',
                    'deviceName': '9a762346',
                    'platformVersion': '6.0.1',
                    'noReset': True,
                    'browserName':'Chrome'
                    }
    
    driver=webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_caps)
    print('浏览器启动成功')
    driver.get(url)
    print(driver.contexts)
    driver.switch_to.context('NATIVE_APP')
    print('切换到原始APP成功')
    try:
        WebDriverWait(driver,10,1).until(lambda x:x.find_element_by_xpath('//*[@text="否"]')).click()
        print('翻译提示已出现')
    except:
        print('翻译提示未出现')
    driver.switch_to.context('CHROMIUM')
    print('切换到CHROMIUM成功')
    WebDriverWait(driver,20,1).until(lambda x:x.find_element_by_xpath('//*[@id="m-tabs-0-0"]/span/div/span')).click()
    print('点击拨号盘成功')
    WebDriverWait(driver,20,1).until(lambda x:x.find_element_by_xpath('xxxxx')).click()print('拨打按钮点击成功')

    运行结果:

    反正一点:切进来了就是用selenium的方法!!!
  • 相关阅读:
    LeetCode 449. Serialize and Deserialize BST
    LeetCode Word Abbreviation
    LeetCode 402. Remove K Digits
    LeetCode 439. Ternary Expression Parser
    LeetCode Frog Jump
    LeetCode 630. Course Schedule III
    LeetCode 729. My Calendar I
    LeetCode 567. Permutation in String
    LeetCode Find Permutation
    LeetCode Number of Atoms
  • 原文地址:https://www.cnblogs.com/luobobobo/p/9900468.html
Copyright © 2011-2022 走看看