【发布时间】:2020-10-28 12:46:45
【问题描述】:
我正在尝试使用 Appium 在 Genymotion 模拟器上模拟 2 个动作:
- 转到特定的 URL,然后网站会重定向到 Google Play 商店。
- 在该 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