Ejemplo n.º 1
0
    def __init__(self, marionette):
        Base.__init__(self, marionette)
        self.marionette.switch_to_frame()

        # wait for the pop up screen to open
        view = Wait(self.marionette, timeout=60).until(
            expected.element_present(*self._iframe_locator))
        Wait(self.marionette).until(expected.element_displayed(view))

        # Change the app to make use of the Facebook developer appId
        Wait(self.marionette, timeout=60).until(
            lambda m: view.get_attribute('data-url') != 'about:blank')

        # Desktop b2g uses this
        str = view.get_attribute('data-url').replace('123456',
                                                     '323630664378726')
        # Device uses this
        str = str.replace('395559767228801', '323630664378726')

        self.marionette.switch_to_frame(view)
        # Wait until the original page has loaded a bit, because sometimes,
        # trying to load the 2nd page directly after the first, causes a blank page
        Wait(self.marionette,
             timeout=60).until(expected.element_present(*self._div_locator))
        self.marionette.navigate(str)
        Wait(self.marionette,
             timeout=60).until(expected.element_present(*self._email_locator))
Ejemplo n.º 2
0
 def _switch_to_fxa_iframe(self):
     self.marionette.switch_to_frame()
     iframe = Wait(self.marionette, timeout=60).until(
         expected.element_present(*self._fxa_iframe_locator))
     Wait(self.marionette).until(expected.element_displayed(iframe))
     Wait(self.marionette, timeout=60).until(lambda m: iframe.get_attribute('data-url') != 'about:blank')
     self.marionette.switch_to_frame(iframe)
Ejemplo n.º 3
0
 def tap_portrait_crop(self):
     element = Wait(self.marionette).until(
         expected.element_present(*self._crop_portrait_locator))
     Wait(self.marionette).until(expected.element_displayed(element))
     element.tap()
     Wait(self.marionette).until(
         lambda m: 'selected' in element.get_attribute('class'))
Ejemplo n.º 4
0
 def __init__(self, marionette):
     Base.__init__(self, marionette)
     self.switch_to_frame()
     # wait for the page to load
     email = Wait(self.marionette).until(
         expected.element_present(*self._email_locator))
     Wait(self.marionette).until(lambda m: email.get_attribute('value') != '')
Ejemplo n.º 5
0
Archivo: app.py Proyecto: pottierg/gaia
 def launch(self, airplane_mode=False):
     Base.launch(self)
     power = Wait(self.marionette).until(
         expected.element_present(*self._power_button_locator))
     if not airplane_mode:
         Wait(self.marionette).until(
             lambda m: power.get_attribute('data-enabled') == 'true')
Ejemplo n.º 6
0
 def _switch_to_fxa_iframe(self):
     self.marionette.switch_to_frame()
     iframe = Wait(self.marionette, timeout=60).until(
         expected.element_present(*self._fxa_iframe_locator))
     Wait(self.marionette).until(expected.element_displayed(iframe))
     Wait(self.marionette, timeout=60).until(lambda m: iframe.get_attribute('data-url') != 'about:blank')
     self.marionette.switch_to_frame(iframe)
Ejemplo n.º 7
0
 def __init__(self, marionette):
     Base.__init__(self, marionette)
     self.switch_to_frame()
     # wait for the page to load
     email = Wait(self.marionette).until(
         expected.element_present(*self._email_locator))
     Wait(self.marionette).until(
         lambda m: email.get_attribute('value') != '')
Ejemplo n.º 8
0
    def tap_next(self):
        next = Wait(self.marionette).until(expected.element_present(*self._next_locator))
        Wait(self.marionette).until(lambda m: next.get_attribute('disabled') != 'true')
        next.tap()

        account = Wait(self.marionette).until(
            expected.element_present(*self._account_prefs_section_locator))
        Wait(self.marionette).until(lambda m: account.location['x'] == 0)

        Wait(self.marionette, timeout=120).until(expected.element_displayed(
            Wait(self.marionette, timeout=120).until(expected.element_present(
                *self._account_prefs_next_locator))))
Ejemplo n.º 9
0
    def __init__(self, marionette):
        Base.__init__(self, marionette)
        self.marionette.switch_to_frame()

        # wait for the pop up screen to open
        view = Wait(self.marionette, timeout=60).until(
            expected.element_present(*self._iframe_locator))
        Wait(self.marionette).until(expected.element_displayed(view))

        # Change the app to make use of the Facebook developer appId
        Wait(self.marionette, timeout=60).until(lambda m: view.get_attribute('data-url') != 'about:blank')

        # Desktop b2g uses this
        str = view.get_attribute('data-url').replace('123456', '323630664378726')
        # Device uses this
        str = str.replace('395559767228801', '323630664378726')

        self.marionette.switch_to_frame(view)
        # Wait until the original page has loaded a bit, because sometimes,
        # trying to load the 2nd page directly after the first, causes a blank page
        Wait(self.marionette, timeout=60).until(expected.element_present(*self._div_locator))
        self.marionette.navigate(str)
        Wait(self.marionette, timeout=60).until(expected.element_present(*self._email_locator))
Ejemplo n.º 10
0
    def enter_email(self, email=None):
        self.marionette.switch_to_frame()
        iframe = Wait(self.marionette, timeout=60).until(
            expected.element_present(*self._iframe_locator))
        Wait(self.marionette).until(expected.element_displayed(iframe))
        Wait(self.marionette, timeout=60).until(lambda m: iframe.get_attribute('data-url') != 'about:blank')
        self.marionette.switch_to_frame(iframe)

        input = Wait(self.marionette, timeout=60).until(
            expected.element_present(*self._input_locator))
        Wait(self.marionette).until(expected.element_displayed(input))
        input.send_keys(email)

        # Wait until the keyboard is completely displayed, otherwise tapping
        # the next button is unreliable
        self.marionette.switch_to_frame()
        Wait(self.marionette).until(lambda m: self.keyboard.is_keyboard_displayed)
        self.marionette.switch_to_frame(iframe)

        self.marionette.find_element(*self._next_locator).tap()
Ejemplo n.º 11
0
    def enter_email(self, email=None):
        self.marionette.switch_to_frame()
        iframe = Wait(self.marionette, timeout=60).until(
            expected.element_present(*self._iframe_locator))
        Wait(self.marionette).until(expected.element_displayed(iframe))
        Wait(self.marionette, timeout=60).until(
            lambda m: iframe.get_attribute('data-url') != 'about:blank')
        self.marionette.switch_to_frame(iframe)

        input = Wait(self.marionette, timeout=60).until(
            expected.element_present(*self._input_locator))
        Wait(self.marionette).until(expected.element_displayed(input))
        input.send_keys(email)

        # Wait until the keyboard is completely displayed, otherwise tapping
        # the next button is unreliable
        self.marionette.switch_to_frame()
        Wait(self.marionette).until(
            lambda m: self.keyboard.is_keyboard_displayed)
        self.marionette.switch_to_frame(iframe)

        self.marionette.find_element(*self._next_locator).tap()
Ejemplo n.º 12
0
Archivo: app.py Proyecto: pottierg/gaia
 def wait_for_radio_off(self):
     power = Wait(self.marionette).until(
         expected.element_present(*self._power_button_locator))
     Wait(self.marionette).until(
         lambda m: not power.get_attribute('data-enabled') == 'true')
Ejemplo n.º 13
0
 def wallpaper_preview_src(self):
     element = Wait(self.marionette).until(
         expected.element_present(*self._wallpaper_preview_locator))
     Wait(self.marionette).until(expected.element_displayed(element))
     return element.get_attribute('src')
Ejemplo n.º 14
0
 def tap_portrait_crop(self):
     element = Wait(self.marionette).until(
         expected.element_present(*self._crop_portrait_locator))
     Wait(self.marionette).until(expected.element_displayed(element))
     element.tap()
     Wait(self.marionette).until(lambda m: 'selected' in element.get_attribute('class'))
Ejemplo n.º 15
0
 def wait_for_radio_off(self):
     power = Wait(self.marionette).until(
         expected.element_present(*self._power_button_locator))
     Wait(self.marionette).until(
         lambda m: not power.get_attribute('data-enabled') == 'true')
Ejemplo n.º 16
0
 def launch(self, airplane_mode=False):
     Base.launch(self)
     power = Wait(self.marionette).until(
         expected.element_present(*self._power_button_locator))
     if not airplane_mode:
         Wait(self.marionette).until(lambda m: power.get_attribute('data-enabled') == 'true')
Ejemplo n.º 17
0
class HTML5Player(PageRegion):
    """Represents HTML5 Player.

    Reference:
    http://www.w3.org/TR/2012/WD-html5-20121025/media-elements.html#media-element
    """

    _video_element_locator = (By.TAG_NAME, 'video')

    def __init__(self, marionette):
        Base.__init__(self, marionette)
        self.root_element = Wait(self.marionette).until(
            expected.element_present(*self._video_element_locator))
        Wait(self.marionette).until(
            expected.element_displayed(self.root_element))

    def wait_for_video_loaded(self):
        # Wait long enough to make sure enough of the video has been loaded
        Wait(self.marionette, timeout=60).until(
            lambda m: int(self.root_element.get_attribute('readyState')) == 4)

    @property
    def is_fullscreen(self):
        return self.marionette.execute_script("""return document.mozFullScreenElement ==
                                                 document.getElementsByTagName("video")[0]""")

    @property
    def is_playing(self):
        return self.root_element.get_attribute('paused') != 'true'

    @property
    def is_muted(self):
        return self.root_element.get_attribute('muted') == 'true'

    @property
    def is_ended(self):
        return self.root_element.get_attribute('ended') == 'true'

    @property
    def controls_visible(self):
        return (int(self.get_location('playButton')[0]) > 0)

    def invoke_controls(self):
        Wait(self.marionette).until(lambda m: not self.controls_visible)
        self.root_element.tap()
        Wait(self.marionette).until(lambda m: self.controls_visible)

    def show_controls(self):
        Wait(self.marionette).until(lambda m: not self.controls_visible)
        self.marionette.execute_script("""
           var a = Components.classes["@mozilla.org/inspector/dom-utils;1"]
               .getService(Components.interfaces.inIDOMUtils)
               .getChildrenForNode(document.getElementsByTagName('video')[0], true);
           var x = a[1].ownerDocument.getAnonymousElementByAttribute(a[1],'class', 'controlBar');
           x.removeAttribute('hidden');
         """, sandbox='system')
        Wait(self.marionette).until(lambda m: self.controls_visible)

    def get_location(self, class_name):
        return self.marionette.execute_script("""
           var a = Components.classes["@mozilla.org/inspector/dom-utils;1"]
               .getService(Components.interfaces.inIDOMUtils)
               .getChildrenForNode(document.getElementsByTagName('video')[0], true);
           var x1 = document.getElementsByTagName('video')[0].getBoundingClientRect().left;
           var x2 = a[1].ownerDocument
                        .getAnonymousElementByAttribute(a[1],'class', '%s')
                        .getBoundingClientRect().left;
           var y1 = document.getElementsByTagName('video')[0]
                            .getBoundingClientRect().top;
           var y2 = a[1].ownerDocument.getAnonymousElementByAttribute(a[1],'class', '%s')
                        .getBoundingClientRect().top;
           return (Math.floor(x2-x1) + ',' + Math.floor(y2-y1));
         """ % (class_name, class_name), sandbox='system').split(',')

    def tap_video_control(self, class_name):
        location = self.get_location(class_name)
        if location[0] <= 0 or location[1] <= 0:
            print 'x=%d, y=%d' % (location[0], location[1])
            self.assertTrue(False)
        self.root_element.tap(x=int(location[0]) + 5, y=int(location[1]) + 5)

    def tap_play(self):
        self.tap_video_control('playButton')
        Wait(self.marionette).until(lambda m: self.is_playing)
        # Tapping the play button makes the controls disappear, wait for that to happen
        Wait(self.marionette).until(lambda m: not self.controls_visible)

    def tap_pause(self):
        self.tap_video_control('playButton')
        Wait(self.marionette).until(lambda m: not self.is_playing)

    def tap_mute(self):
        self.tap_video_control('muteButton')
        Wait(self.marionette).until(lambda m: self.is_muted)

    def tap_unmute(self):
        self.tap_video_control('muteButton')
        Wait(self.marionette).until(lambda m: not self.is_muted)

    def tap_full_screen(self):
        self.tap_video_control('fullscreenButton')

    @property
    def current_timestamp(self):
        return float(self.root_element.get_attribute('currentTime'))
Ejemplo n.º 18
0
 def wallpaper_preview_src(self):
     element = Wait(self.marionette).until(
         expected.element_present(*self._wallpaper_preview_locator))
     Wait(self.marionette).until(expected.element_displayed(element))
     return element.get_attribute('src')
Ejemplo n.º 19
0
class HTML5Player(PageRegion):
    """Represents HTML5 Player.

    Reference:
    http://www.w3.org/TR/2012/WD-html5-20121025/media-elements.html#media-element
    """

    _video_element_locator = (By.TAG_NAME, 'video')

    def __init__(self, marionette):
        Base.__init__(self, marionette)
        self.root_element = Wait(self.marionette).until(
            expected.element_present(*self._video_element_locator))
        Wait(self.marionette).until(
            expected.element_displayed(self.root_element))

    def wait_for_video_loaded(self):
        # Wait long enough to make sure enough of the video has been loaded
        Wait(self.marionette, timeout=60).until(
            lambda m: int(self.root_element.get_attribute('readyState')) == 4)

    @property
    def is_fullscreen(self):
        return self.marionette.execute_script(
            """return document.mozFullScreenElement ==
                                                 document.getElementsByTagName("video")[0]"""
        )

    @property
    def is_playing(self):
        return self.root_element.get_attribute('paused') != 'true'

    @property
    def is_muted(self):
        return self.root_element.get_attribute('muted') == 'true'

    @property
    def is_ended(self):
        return self.root_element.get_attribute('ended') == 'true'

    @property
    def controls_visible(self):
        return (int(self.get_location('playButton')[0]) > 0)

    def invoke_controls(self):
        Wait(self.marionette).until(lambda m: not self.controls_visible)
        self.root_element.tap()
        Wait(self.marionette).until(lambda m: self.controls_visible)

    def show_controls(self):
        Wait(self.marionette).until(lambda m: not self.controls_visible)
        self.marionette.execute_script("""
           var a = Components.classes["@mozilla.org/inspector/dom-utils;1"]
               .getService(Components.interfaces.inIDOMUtils)
               .getChildrenForNode(document.getElementsByTagName('video')[0], true);
           var x = a[1].ownerDocument.getAnonymousElementByAttribute(a[1],'class', 'controlBar');
           x.removeAttribute('hidden');
         """,
                                       sandbox='system')
        Wait(self.marionette).until(lambda m: self.controls_visible)

    def get_location(self, class_name):
        return self.marionette.execute_script("""
           var a = Components.classes["@mozilla.org/inspector/dom-utils;1"]
               .getService(Components.interfaces.inIDOMUtils)
               .getChildrenForNode(document.getElementsByTagName('video')[0], true);
           var x1 = document.getElementsByTagName('video')[0].getBoundingClientRect().left;
           var x2 = a[1].ownerDocument
                        .getAnonymousElementByAttribute(a[1],'class', '%s')
                        .getBoundingClientRect().left;
           var y1 = document.getElementsByTagName('video')[0]
                            .getBoundingClientRect().top;
           var y2 = a[1].ownerDocument.getAnonymousElementByAttribute(a[1],'class', '%s')
                        .getBoundingClientRect().top;
           return (Math.floor(x2-x1) + ',' + Math.floor(y2-y1));
         """ % (class_name, class_name),
                                              sandbox='system').split(',')

    def tap_video_control(self, class_name):
        location = self.get_location(class_name)
        if location[0] <= 0 or location[1] <= 0:
            print 'x=%d, y=%d' % (location[0], location[1])
            self.assertTrue(False)
        self.root_element.tap(x=int(location[0]) + 5, y=int(location[1]) + 5)

    def tap_play(self):
        self.tap_video_control('playButton')
        Wait(self.marionette).until(lambda m: self.is_playing)
        # Tapping the play button makes the controls disappear, wait for that to happen
        Wait(self.marionette).until(lambda m: not self.controls_visible)

    def tap_pause(self):
        self.tap_video_control('playButton')
        Wait(self.marionette).until(lambda m: not self.is_playing)

    def tap_mute(self):
        self.tap_video_control('muteButton')
        Wait(self.marionette).until(lambda m: self.is_muted)

    def tap_unmute(self):
        self.tap_video_control('muteButton')
        Wait(self.marionette).until(lambda m: not self.is_muted)

    def tap_full_screen(self):
        self.tap_video_control('fullscreenButton')

    @property
    def current_timestamp(self):
        return float(self.root_element.get_attribute('currentTime'))