在不启动应用程序的情况下在前台启动(或恢复)应用程序的驱动程序



我正试图使用Appium在Genymotion模拟器上模拟两个操作:

  1. 转到特定的URL,然后网站重定向到Google Play商店
  2. 按下";INSTALL";在Google Play商店屏幕上

我已经设法获得了URL,但当我试图启动Google Play应用程序的驱动程序时,它会重新启动该应用程序,这是我不想要的。在我被重定向到Google Play后,我需要模仿点击INSTALL按钮。我曾考虑过运行并行测试,但似乎每次测试都会启动应用程序。

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

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

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

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

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

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

最新更新