appium 1.0 和2.0 对比

       最近看appium 发布了2.0 版本,于是就把当前现有的环境升级到了2.0 ,写下此文,记录以下环境升级过程中,当前碰到的环境相关问题。       

  • appium客户端

       appium客户端对应的python 依赖包是Appium-Python-Client,selenium。不同的python版本,安装的依赖包版本不同,依赖包版本不同,对应的客户端代码也不一样。

      selenium+appium+jdk的版本不同可能导致执行结果不同。

1、老版本组合

selenium(4.9版本及以前)、appium-python-client(2.6.0及以前)、jdk8,appium-server管理员权限运行。

ios设备初始化代码如下:

driver_list = []
if desired_caps is not None:
    for i in range(len(desired_caps)):

        desired_cap = {}
        if desired_caps[i]["desired_caps"]["platformName"].lower() == "android":
            desired_cap["systemPort"] = desired_cap["systemPort"]
            desired_cap["unicodeKeyboard"] = "True"
            desired_cap["resetKeyboard"] = "True"
        elif desired_caps[i]["desired_caps"]["platformName"] == "iOS":
            desired_cap['bundleId'] = desired_caps[i]["desired_caps"]["bundleId"]
            desired_cap['usePrebuiltWDA'] = desired_caps[i]["desired_caps"]["usePrebuiltWDA"]
            desired_cap['useNewWDA'] = desired_caps[i]["desired_caps"]["useNewWDA"]
            desired_cap['xcodeSigningId'] = "iPhone Developer"
            # desired_cap['webDriverAgentUrl'] = desired_caps[i]["desired_caps"]["webDriverAgentUrl"]
            desired_cap['webDriverAgentUrl'] = desired_caps[i]["desired_caps"]["webDriverAgentUrl"] +desired_caps[i]["desired_caps"]["wdaport"]
            desired_cap['wdaLocalPort'] = desired_caps[i]["desired_caps"]["wdaport"]
            desired_cap['skipLogCapture'] = True
        desired_cap['udid'] = desired_caps[i]["desired_caps"]["udid"]
        desired_cap['deviceName'] = desired_caps[i]["desired_caps"]["deviceName"]
        desired_cap['platformVersion'] = desired_caps[i]["desired_caps"]["platformVersion"]
        desired_cap['platformName'] = desired_caps[i]["desired_caps"]["platformName"]
        desired_cap["automationName"] = desired_caps[i]["desired_caps"]['automationName']
        desired_cap["noReset"] = desired_caps[i]["desired_caps"]['noReset']
        desired_cap["newCommandTimeout"] =  desired_caps[i]["desired_caps"]['newCommandTimeout']
        # desired_cap["newCommandTimeout"] = 6000
        # desired_cap['noSign'] = True
        # desired_cap['port'] = desired_caps[i]["desired_caps"]["server_port"]
        print(desired_cap['webDriverAgentUrl'])

        remote = "http://127.0.0.1:" + str(desired_caps[i]["desired_caps"]["server_port"]) + "/wd/hub"
        # remote = "http://127.0.0.1:4723/wd/hub"
        driver = webdriver.Remote(remote, desired_cap)
        driver.implicitly_wait(5)
        driver_list.append(driver)
2、新版本组合

selenium(4.9以后)、appium-python-client(3.1.0及以后)、jdk8,appium-server管理员权限运行。

 ios设备初始化代码如下:

    driver_list = []
    if desired_caps is not None:
        for i in range(len(desired_caps)):
            if desired_caps[i]["desired_caps"]["platformName"] == "iOS":

                option = AppiumOptions()
                option.set_capability("platformName", "Android")
                option.set_capability("platformVersion", "5.1.1")
                option.set_capability("deviceName", "Android Emulator")
                option.set_capability("noReset", True)
                option.set_capability("appPackage", "com.lilysgame.calculatorjw")
                option.set_capability("appActivity", "com.lilysgame.calculator.MainActivity")
                option.set_capability("bundleId", desired_caps[i]["desired_caps"]["bundleId"])
                option.set_capability("usePrebuiltWDA", desired_caps[i]["desired_caps"]["usePrebuiltWDA"])
                option.set_capability("useNewWDA", desired_caps[i]["desired_caps"]["useNewWDA"])
                option.set_capability("xcodeSigningId", "iPhone Developer")
                option.set_capability("webDriverAgentUrl", desired_caps[i]["desired_caps"]["webDriverAgentUrl"] + \
                                                   desired_caps[i]["desired_caps"]["wdaport"])
                option.set_capability("skipLogCapture", True)
                option.set_capability("udid", desired_caps[i]["desired_caps"]["udid"])
                option.set_capability("deviceName", desired_caps[i]["desired_caps"]["deviceName"])
                option.set_capability("platformVersion", desired_caps[i]["desired_caps"]["platformVersion"])
                option.set_capability("platformName", desired_caps[i]["desired_caps"]["platformName"])
                option.set_capability("automationName", desired_caps[i]["desired_caps"]["automationName"])
                option.set_capability("newCommandTimeout", desired_caps[i]["desired_caps"]['newCommandTimeout'])

                remote = "http://127.0.0.1:" + str(desired_caps[i]["desired_caps"]["server_port"])
                # remote = "http://127.0.0.1:4723/wd/hub"
                driver = webdriver.Remote(remote, options=option)
                driver.implicitly_wait(5)
                driver_list.append(driver)

  • appium服务器端

appium服务器端,处理客户端请求的,转交请求给Android设备的app去执行。

  • windows版本
  • Linux版本
  • macOS版本

nodejs 默认已经安装好了,以下只讲windows 版本 appium 命令行安装方式。

1、appium1.0 安装方式

1.0 Appium server绑定各种driver ,一个命令安装即可

命令行安装:

安装特定版本的Appium server:npm install -g appium@1.22.3 ,安装之后,直接在命令行输入appium 就可以正常运行。

1)python 代码命令行启动方式:

cmd = f' start /b appium -a 127.0.0.1 -p port -bp bport -U udid --log-level warn '

2) >appium
[Appium] Welcome to Appium v1.22.3
[Appium] Appium REST http interface listener started on 0.0.0.0:4723

1、appium2.0 安装方式

2.0 appium版本解绑,所以驱动都需要手动安装。

安装appium 命令:

npm install -g appium@next

安装driver 命令:

C:\Users\>appium driver install xcuitest
√ Installing 'xcuitest' using NPM install spec 'appium-xcuitest-driver'
i Driver xcuitest@5.11.7 successfully installed
- automationName: XCUITest
- platformNames: ["iOS","tvOS"]

1)python 代码命令行启动方式:appium -a 127.0.0.1 -p 4725

2)cmd 命令行启动方式:appium

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值