如何处理Chrome中缺少的屏幕

时间:2019-08-06 11:39:55

标签: appium-android python-appium

在执行本机应用程序的测试用例时遇到了问题。问题是当我启动 Chrome 时,流程类似于“接受并继续”>“下一步”>“不用了,谢谢”>指向我的网络应用程序的网址。

有时缺少“下一步”屏幕,并显示不,谢谢屏幕。

我尝试使用if-else和or条件,但它们对我没有帮助

from appium import webdriver
from time import sleep

desired_cap = {
    "platformName": "Android",
    "platformVersion": "8.1",
    "deviceName": "emulator-5554",
    "appPackage": "com.android.chrome",
    "appActivity": "com.google.android.apps.chrome.Main",
    "automationName": "Appium",
    "appReset": "true"}

driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_cap)
driver.implicitly_wait(30)

driver.find_element_by_xpath("//android.widget.Button[@text='ACCEPT & CONTINUE']").click()
choices = driver.find_element_by_xpath("//android.widget.Button[@text='NEXT'] or //android.widget.Button[@text='NO THANKS'][1]").click()

1 个答案:

答案 0 :(得分:0)

尝试:

from appium import webdriver
from time import sleep

desired_cap = {
    "platformName": "Android",
    "platformVersion": "8.1",
    "deviceName": "emulator-5554",
    "appPackage": "com.android.chrome",
    "appActivity": "com.google.android.apps.chrome.Main",
    "automationName": "Appium",
    "appReset": "true"}

driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_cap)
driver.implicitly_wait(30)

driver.find_element_by_xpath("//android.widget.Button[@text='ACCEPT & CONTINUE']").click()
time.sleep(4)

try :

     driver.find_element_by_xpath([@text='NEXT']).click()


except : 
       pass

driver.find_element_by_xpath(Button[@text='NO THANKS']).click()