Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def switch_to_keyboard(self, focus=False):
self.marionette.switch_to_frame()
input_window = self.marionette.find_element(*self._input_window_locator)
# if we have software buttons, keyboar's y will not be 0 but the minus height of the button container.
expected_y = -System(self.marionette).software_buttons_height
Wait(self.marionette).until(
lambda m: 'active' in input_window.get_attribute('class') and input_window.location['y'] == expected_y,
message='Keyboard inputWindow not interpreted as displayed. Debug is_displayed(): %s, class: %s.'
% (input_window.is_displayed(), input_window.get_attribute('class')))
keybframe = self.marionette.find_element(*self._keyboard_active_frame_locator)
return self.marionette.switch_to_frame(keybframe, focus)
def a11y_wheel_utility_tray_grippy(self):
self.accessibility.wheel(self.marionette.find_element(*self._grippy_locator), 'up')
Wait(self.marionette).until(
expected.element_not_displayed(*System(self.marionette)._utility_tray_locator))
def dismiss(self):
# Make sure that keyboard is focused, otherwise dismissing it doesn't work
self.switch_to_keyboard(focus=True)
self.marionette.switch_to_frame()
# navigator.mozKeyboard is needed for v1.3 support
self.marionette.execute_script("""
var keyboard = navigator.mozKeyboard || navigator.mozInputMethod;
keyboard.removeFocus();""")
input_window = self.marionette.find_element(*self._input_window_locator)
# if we have software buttons, keyboar's y will not be 0 but the minus height of the button container.
expected_y = int(input_window.size['height']) - System(self.marionette).software_buttons_height
Wait(self.marionette).until(
lambda m: 'active' not in input_window.get_attribute('class') and
not input_window.is_displayed() and
(int(input_window.location['y']) == expected_y),
message="Keyboard was not dismissed. Debug is_displayed(): %s, class: %s."
%(input_window.is_displayed(), input_window.get_attribute('class')))
self.apps.switch_to_displayed_app()
def is_present(self):
self.marionette.switch_to_frame()
from gaiatest.apps.system.app import System
return System(self.marionette).is_element_present(*self._tracking_notice_locator)
def tap_element_from_system_app(self, element=None, add_statusbar_height=False, x=None, y=None):
# Workaround for bug 1109213, where tapping on the button inside the app itself
# makes Marionette spew out NoSuchWindowException errors, see bug 1164078
cx = element.rect['x']
cy = element.rect['y']
cx += element.rect['width']//2 if x is None else x
cy += element.rect['height']//2 if y is None else y
from gaiatest.apps.system.app import System
system = System(self.marionette)
if add_statusbar_height:
cy = cy + system.status_bar.height
system.tap(cx, cy)
def tap_to_confirm_permission(self):
self.marionette.find_element(*self._permission_confirm_button_locator).tap()
from gaiatest.apps.system.app import System
return System(self.marionette)