1

I'm facing a problem while executing my test cases for a native app. The thing is when I launch Chrome then the flow is like Accept & Continue > Next > No Thanks > url to my web app.

Sometimes the Next screen is missing and the No Thanks screen is displayed.

I tried using if-else, and or conditions but they didn't work out for me

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()
Gaurav Marothia
  • 163
  • 2
  • 2
  • 14

1 Answers1

0

try this :

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()