【问题标题】:Start (or resume) a driver for an app on the foreground without launching the app?在前台启动(或恢复)应用程序的驱动程序而不启动应用程序?
【发布时间】:2020-10-28 12:46:45
【问题描述】:

我正在尝试使用 Appium 在 Genymotion 模拟器上模拟 2 个动作:

  1. 转到特定的 URL,然后网站会重定向到 Google Play 商店。
  2. 在该 Google Play 商店屏幕上按“安装”。

我已设法获取 URL,但是当我尝试启动 Google Play 应用程序的驱动程序时,它会重新启动该应用程序,这是我不想要的。我需要在重定向到 Google Play 后立即模拟单击安装按钮。我研究过运行并行测试,但似乎每次测试都会启动应用程序。

这是我的代码。任何帮助将不胜感激!

from appium import webdriver

desired_caps_web = dict(
    platformName='Android',
    platformVersion='8',
    deviceName='Google Pixel',
    automationName='UiAutomator1',
    browserName='Chrome',
    chromedriverExecutable='C:\\Users\\Khoa_Ngo\\node_modules\\appium-chromedriver\\chromedriver\\win\\chromedriver.exe')

driver_web = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps_web)

driver_web.get('https://someURL.com')

desired_caps_vending = dict(
    platformName='Android',
    platformVersion='8',
    deviceName='Google Pixel',
    automationName='UiAutomator1',
    app='/Users/Khoa_Ngo/Google Play Store.apk',  #This is bit of a workaround because I kept running into problems about intent action.
    appPackage='com.android.vending',
    )

driver_vending = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps_vending)

driver_vending.find_elements_by_xpath("//*[contains(@id, 'install')]").click() #Not working

另外我应该如何模拟点击(代码块中的最后一行)?

【问题讨论】:

    标签: python android selenium automated-tests appium


    【解决方案1】:

    将功能 autoLaunch=false 添加到所需功能。

    autoLaunch 自动初始化被测应用。如果这是错误的,Appium 不会安装/启动正在测试的应用程序。默认为真

    描述来自:http://appium.io/docs/en/writing-running-appium/caps/#android-only

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-11-01
      • 1970-01-01
      • 2019-12-15
      • 2011-12-08
      • 2014-10-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多