diff --git a/tests/python/gaia-ui-tests/gaiatest/apps/settings/app.py b/tests/python/gaia-ui-tests/gaiatest/apps/settings/app.py index 9071cc7fa628..7e3e66b59bb9 100644 --- a/tests/python/gaia-ui-tests/gaiatest/apps/settings/app.py +++ b/tests/python/gaia-ui-tests/gaiatest/apps/settings/app.py @@ -13,6 +13,7 @@ class Settings(Base): _header_text_locator = (By.CSS_SELECTOR, '#root > header > h1') _data_text_locator = (By.ID, 'data-desc') _airplane_switch_locator = (By.XPATH, "//input[@id='airplaneMode-input']/..") + _airplane_checkbox_locator = (By.ID, "airplaneMode-input") _wifi_text_locator = (By.ID, 'wifi-desc') _gps_enabled_locator = (By.XPATH, "//input[@name='geolocation.enabled']") _gps_switch_locator = (By.XPATH, "//input[@name='geolocation.enabled']/..") @@ -30,13 +31,17 @@ class Settings(Base): def launch(self): Base.launch(self) - self.wait_for_element_displayed(*self._airplane_switch_locator) + checkbox = self.marionette.find_element(*self._airplane_checkbox_locator) + self.wait_for_condition(lambda m: checkbox.is_enabled()) - def enable_airplane_mode(self): - self.marionette.find_element(*self._airplane_switch_locator).tap() + def toggle_airplane_mode(self): + checkbox = self.marionette.find_element(*self._airplane_checkbox_locator) + label = self.marionette.find_element(*self._airplane_switch_locator) - def disable_airplane_mode(self): - self.marionette.find_element(*self._airplane_switch_locator).tap() + checkbox_state = checkbox.is_selected() + + label.tap() + self.wait_for_condition(lambda m: checkbox_state is not checkbox.is_selected()) def enable_gps(self): self.marionette.find_element(*self._gps_switch_locator).tap() diff --git a/tests/python/gaia-ui-tests/gaiatest/tests/functional/settings/test_settings_airplane_mode.py b/tests/python/gaia-ui-tests/gaiatest/tests/functional/settings/test_settings_airplane_mode.py index 275910dff76e..05d30a3a2361 100644 --- a/tests/python/gaia-ui-tests/gaiatest/tests/functional/settings/test_settings_airplane_mode.py +++ b/tests/python/gaia-ui-tests/gaiatest/tests/functional/settings/test_settings_airplane_mode.py @@ -10,6 +10,7 @@ class TestAirplaneMode(GaiaTestCase): def setUp(self): GaiaTestCase.setUp(self) + self.data_layer.disable_wifi() self.data_layer.connect_to_cell_data() self.data_layer.connect_to_wifi() self.data_layer.set_setting('geolocation.enabled', 'true') @@ -20,7 +21,7 @@ def test_toggle_airplane_mode(self): settings.launch() # Switch on Airplane mode - settings.enable_airplane_mode() + settings.toggle_airplane_mode() # wait for Cell Data to be disabled, this takes the longest when airplane mode is switched on self.wait_for_condition(lambda s: 'SIM card not ready' in settings.cell_data_menu_item_description) @@ -38,10 +39,10 @@ def test_toggle_airplane_mode(self): self.apps.switch_to_displayed_app() # Switch off Airplane mode - settings.disable_airplane_mode() + settings.toggle_airplane_mode() - #wait for wifi to be connected, because this takes the longest to connect after airplane mode is switched off - self.wait_for_condition(lambda s: 'Connected' in settings.wifi_menu_item_description) + # Wait for wifi to be connected, because this takes the longest to connect after airplane mode is switched off + self.wait_for_condition(lambda s: 'Connected' in settings.wifi_menu_item_description, timeout=40) # check Wifi is enabled self.assertTrue(self.data_layer.is_wifi_connected(self.testvars['wifi']), "WiFi was not connected after switching off Airplane mode")