【问题标题】:How to instantiate Appium Driver based on platform?如何基于平台实例化Appium Driver?
【发布时间】:2017-10-12 15:28:27
【问题描述】:

我是自动化测试的初学者。我正在尝试为我的 android 和 ios 应用程序编写通用测试项目。 ios 和 android 上的应用程序具有几乎相同的 UI 和流程。我想知道如何基于平台实例化 Appium 驱动程序。 到目前为止,我正在考虑有一个布尔变量 isAndroid,我必须在运行测试之前手动更改代码。基于 isAndroid,我将 AppiumDriver 实例化为 AndroidDriver 或 IOSDriver,元素将根据 @AndroidFindby 或 @IOSFindBy 定位 当我从终端启动 Appium 时,我提到了参数 platformName,有没有办法在我的代码中获取该信息,这样我就不必手动更改 isAndroid 变量并且运行完全相同的测试代码两个平台。

【问题讨论】:

    标签: android ios automation appium appium-ios


    【解决方案1】:

    您能否尝试一个平台,捕获异常,然后再尝试另一个?

    try:
        driver = webdriver.Remote('http://localhost:4723/wd/hub', ios_caps)
        run_iOS_tests(driver)
    except selenium.common.exceptions.WebDriverException:
        driver = webdriver.Remote('http://localhost:4723/wd/hub', android_caps)
        run_android_tests(driver)
    

    否则您需要使用一些外部方法来查看连接了哪些设备(androidios)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-01-19
      • 1970-01-01
      • 1970-01-01
      • 2019-07-12
      • 1970-01-01
      • 2017-01-19
      相关资源
      最近更新 更多