zoukankan      html  css  js  c++  java
  • 6-3-2绕过appium的iOS测试

    1.WDA自带的inspector

    • 1.1.启动WDA
      + Xcode启动:product-test,适合个人调试
      + 命令行启动:适合持续集成
    UDID=$(idevice_id -l)
    xcodebuild -project WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination "id=$UDID" test-without-building
    
    • 1.2.iproxy 8100 8100
      不启动iproxy,inspector不能访问
    • 1.3.查看WDA自带的inspector
      浏览器输入127.0.0.1:8100/status,查看连接状态,inspector查找元素。
    xcodebuild -project WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination "id=${UDID}" test-without-building
    
    注意:WDA自带的inspect没有xpath

    2使用wdaproxy获取页面

    • 2.1停止iproxy,使用wdaproxy
    • 2.2安装:brew install openatx/tap/wdaproxy
    • 2.3启动:wdaproxy -p 8100
    • 浏览器输入127.0.0.1:8100/,会发现有4个选项,inspectorstatuspackages emote。package可以查看安装的应用和包名,remote可以直接操作手机,sessionid,udid
    ## 3.启动appium的inspector ### 1. 使用bundleId启动 ### 2.使用bundleId+sessionId启动 ## 4.代码 ### 4.1测试脚本1 ```#python from appium import webdriver import time,selenium

    caps = {}
    caps["bundleId"] = "com.example.apple-samplecode.UICatalogcsj815379479"

    driver = webdriver.Remote("http://127.0.0.1:8100/wd/hub", caps)
    def wait_element(xpath,timeout=30):
    deadline=time.time()+timeout
    while time.time() < deadline:
    try:
    el=driver.find_element_by_xpath(xpath)
    return el
    except selenium.common.exceptions.NoSuchElementException:
    time.sleep(.2)
    raise RuntimeError("NoSuchElementException in wait_element")
    wait_element("//[@name="Action Sheets"]").click()
    wait_element("//
    [@name="Okay / Cancel"]").click()
    el3 = wait_element("//XCUIElementTypeButton[@name="OK"]")
    try:
    assert el3.text=='OK',"button is not OK"
    except AssertError as e:
    print(e)
    driver.quit()

    
    ###    4.2测试脚本2
    

    python

    from appium import webdriver

    import time,selenium
    driver = webdriver.Remote("http://127.0.0.1:8100/wd/hub",{"bundleId":"com.taobaobj.moneyshield"})

    driver.implicitly_wait(30)没有实现这个接口,可以使用函数来代替

    def wait_element(elem,timeout=30):
    deadline = time.time() + timeout
    while time.time() < deadline:
    try:
    el_xpath = driver.find_element_by_xpath(elem)
    return el_xpath
    except selenium.common.exceptions.NoSuchElemention:
    time.sleep(0.2)
    raise RuntimeError("Element not found " + el_xpath)

    print(driver.session_id)
    time.sleep(3)
    driver.find_element_by_accessibility_id("工具箱").click()
    driver.find_element_by_accessibility_id("诈骗举报").click()
    driver.find_element_by_xpath("//XCUIElementTypeStaticText[@name="电话诈骗举报"]").click()
    driver.find_element_by_xpath("//XCUIElementTypeScrollView/XCUIElementTypeOther/XCUIElementTypeOther[1]").send_keys("13693347586")
    driver.find_element_by_xpath("(//XCUIElementTypeImage[@name="radiobox_normal"])[3]").click()
    driver.find_element_by_accessibility_id("请简要描述一下诈骗来电的内容,比如来电时间,对方特征,被骗方式等").send_keys("骗子,大骗子")
    driver.find_element_by_accessibility_id("诈骗内容").click()
    driver.find_element_by_accessibility_id("提交举报").click()

    
    
    ##    5使用anyproxy抓包和调试
    安装:npm i -g anyproxy
  • 相关阅读:
    maven 创建web项目出错
    poj1699--Best Sequence(dfs+剪枝)
    HDU-1042-N!(Java大法好 &amp;&amp; HDU大数水题)
    “XXX.Index”不扩展类“System.Web.UI.Page”,因此此处不同意的问题
    scala模式匹配
    scala匿名函数
    scala特质
    group by的使用
    liux之我用过的zip解压命令
    liunx之zip格式的解压命令
  • 原文地址:https://www.cnblogs.com/csj2018/p/9670660.html
Copyright © 2011-2022 走看看