美文网首页
Appium Appium+Python 在切换到 webvie

Appium Appium+Python 在切换到 webvie

作者: Kingtester | 来源:发表于2021-06-18 08:27 被阅读0次

    脚本如下:

    encoding=utf-8

    from appium import webdriver
    from appium.webdriver.common.touch_action import TouchAction
    import time
    import os
    server = r'http://localhost:4723/wd/hub' # Appium Server, 端口默认为4723
    desired_capabilities = {
    'platformName': 'Android', # 平台
    # 需替换成你的driverName,如果不知 道自己的设备名,用adb命令去查看一下
    'driverName': 'c611c3b4', #手机名称
    'platformVersion': '10.0.0', # 安卓版本
    'appPackage': 'com.webmobile.activity', #APP包名
    'appActivity': '.MainActivityP', # APP启动名
    'noReset':True
    }
    driver = webdriver.Remote(server, desired_capabilities) # 连接手机和APP

    time.sleep(3)

    c=driver.contexts

    driver.switch_to.context("WEBVIEW_com.webmobile.activity")

    driver.find_element_by_id("placeholder").click()

    print(c[1])
    driver.switch_to.context(c[1])

    driver.find_element_by_xpath('//*[@id="username"]').click()
    time.sleep(2)
    driver.find_element_by_xpath('/html/body/div[4]/div[1]/button[2]').click()

    image.png
    image.png

    执行到这一步,发现没问题,没有报错,但是click没有定位到,在浏览器的conlse


    image.png

    定位OK,说明xpath没有毛病,怎么办?去他妈的,放弃治疗,本来想研究一下APP自动化,感觉坑太多,兄弟们,你们加油!

    相关文章

      网友评论

          本文标题:Appium Appium+Python 在切换到 webvie

          本文链接:https://www.haomeiwen.com/subject/rvfkyltx.html