Fix alert dismiss if it appears

Signed-off-by: Serhy <sergii@status.im>
This commit is contained in:
Serhy 2019-12-24 19:19:55 +02:00
parent 8eed77a82a
commit d8db958319
No known key found for this signature in database
GPG Key ID: 5D7C4B9E2B6F500B
1 changed files with 12 additions and 3 deletions

View File

@ -242,6 +242,13 @@ class CrossIcon(BaseButton):
super(CrossIcon, self).__init__(driver) super(CrossIcon, self).__init__(driver)
self.locator = self.Locator.xpath_selector('(//android.view.ViewGroup[@content-desc="icon"])[1]') self.locator = self.Locator.xpath_selector('(//android.view.ViewGroup[@content-desc="icon"])[1]')
class NativeCloseButton(BaseButton):
def __init__(self, driver):
super(NativeCloseButton, self).__init__(driver)
self.locator = self.Locator.id('android:id/aerr_close')
class CrossIconInWelcomeScreen(BaseButton): class CrossIconInWelcomeScreen(BaseButton):
def __init__(self, driver): def __init__(self, driver):
super(CrossIconInWelcomeScreen, self).__init__(driver) super(CrossIconInWelcomeScreen, self).__init__(driver)
@ -338,6 +345,7 @@ class BaseView(object):
self.confirm_button = ConfirmButton(self.driver) self.confirm_button = ConfirmButton(self.driver)
self.connection_status = ConnectionStatusText(self.driver) self.connection_status = ConnectionStatusText(self.driver)
self.cross_icon = CrossIcon(self.driver) self.cross_icon = CrossIcon(self.driver)
self.native_close_button = NativeCloseButton(self.driver)
self.show_roots_button = ShowRoots(self.driver) self.show_roots_button = ShowRoots(self.driver)
self.get_started_button = GetStartedButton(self.driver) self.get_started_button = GetStartedButton(self.driver)
self.ok_got_it_button = OkGotItButton(self.driver) self.ok_got_it_button = OkGotItButton(self.driver)
@ -376,12 +384,13 @@ class BaseView(object):
def close_native_device_dialog(self, alert_text_part): def close_native_device_dialog(self, alert_text_part):
element = self.element_by_text_part(alert_text_part) element = self.element_by_text_part(alert_text_part)
if element.is_element_present(1): if element.is_element_present(1):
self.driver.info("Dismissing %s alert" % alert_text_part) self.driver.info("Closing '%s' alert..." % alert_text_part)
self.dismiss_alert() self.dismiss_alert()
def dismiss_alert(self): def dismiss_alert(self):
self.driver.info("Dismiss alert") self.native_close_button.click()
self.driver.switch_to.alert.dismiss() self.driver.info("Alert closed")
@property @property
def logcat(self): def logcat(self):