Example #1
0
def select_menu(frame_object, menu_name, timeout_secs=10):
    """Select menu with the given name

    Args:
        frame_object (Class): Class of the Frame Object that can read this menu
        menu_name (str): Name of the menu to select
        timeout_secs (int): Timeout in seconds for finding the frame object
    """
    # Get the menus:
    # pylint: disable=stbt-wait-until-callable
    menu = stbt.wait_until(frame_object, timeout_secs=timeout_secs)

    # Check if the menu we want exists:
    menu_item = [x for x in menu.menu_items if x.text == menu_name]
    assert menu_item is not None, 'Menu item {0} not found in this screen'.format(menu_name)

    if menu.message == menu_name:
        return

    for i in range(0, MAX_MENU_LENGTH):
        # pylint: disable=stbt-wait-until-callable
        menu = stbt.wait_until(frame_object, timeout_secs=timeout_secs)
        debug('[SELECT_MENU] Screen {0} selected: {1}->{2}'.format(type(menu).__name__, i, menu.message))

        if menu.message == menu_name:
            debug('[SELECT_MENU] Item found: {0} -> {1}->{2}'.format(type(menu).__name__, i, menu.message))
            break
        stbt.press('KEY_DOWN')
        # Give STB 3 seconds to move the highlighted menu entry
        sleep(3)

    assert menu.message == menu_name, \
        '[SELECT_MENU] ({0}) Selected item is not [{1}]'.format(type(menu).__name__, menu_name)
Example #2
0
 def next_page():
     if page_changes[0] < 3:
         stbt.press("FASTFORWARD")
         time.sleep(1)
         page_changes[0] += 1
     else:
         raise stbt.MatchTimeout(None, unselected_image, 0)
Example #3
0
    def navigate_to(self, page, target):
        """Move the selection to the specified character.

        Note that this won't press KEY_OK on the target, it only moves the
        selection there.

        :param stbt.FrameObject page: See ``enter_text``.
        :param str target: The key or button to navigate to, for example "A",
            " ", or "CLEAR".

        :returns: A new FrameObject instance of the same type as ``page``,
            reflecting the device-under-test's new state after the navigation
            completed.
        """

        if target not in self.G:
            raise ValueError("'%s' isn't in the keyboard" % (target,))

        deadline = time.time() + self.navigate_timeout
        current = _selection_to_text(page.selection)
        while current != target:
            assert page, "%s page isn't visible" % type(page).__name__
            assert time.time() < deadline, (
                "Keyboard.navigate_to: Didn't reach %r after %s seconds"
                % (target, self.navigate_timeout))
            keys = list(_keys_to_press(self.G, current, target))
            log.info("Keyboard: navigating from %s to %s by pressing %r",
                     current, target, keys)
            for k in keys[:-1]:
                stbt.press(k)
            assert stbt.press_and_wait(keys[-1], mask=self.mask)
            page = page.refresh()
            current = _selection_to_text(page.selection)
        return page
Example #4
0
 def testWyswietlacza(self):
     stbt.press("KEY_8", self.timeBeforePress)
     stbt.press("KEY_8", self.timeBeforePress)
     stbt.press("KEY_8", self.timeBeforePress)
     time.sleep(5)
     print("Czy wyswietalcz dziala prawidlowo?")
     print("1) Tak")
     print("2) Nie")
     result = input()
     r = int(result)
     if r == 2:
         self.testsResults["display"] = False
         return
     stbt.press("KEY_POWER", self.timeBeforePress)
     print(
         "Czy na wyswietalczu pojawil sie zegar i swieci prawidlowo(przyciemniony)?"
     )
     print("1) Tak")
     print("2) Nie")
     result = input()
     r = int(result)
     if r == 2:
         self.testsResults["display"] = False
         return
     time.sleep(10)
     stbt.press("KEY_POWER", self.timeBeforePress)
     self.testsResults["display"] = True
Example #5
0
def to_roku_home():
    for _ in range(5):
        press("KEY_HOME")
        if wait_until(lambda: find_selection().text == "Home"):
            break
    else:
        assert False, "Failed to find Roku Home after pressing HOME 5 times"
Example #6
0
def find_player(selected_image, unselected_image):
    """Navigates to the specified player.

    Precondition: In the OnDemand Players screen.

    Uses `unselected_image` to find where the player is on screen;
    navigates there;
    uses `selected_image` to know that it has reached the player.
    """

    page_changes = [0]
    def next_page():
        if page_changes[0] < 3:
            stbt.press("FASTFORWARD")
            time.sleep(1)
            page_changes[0] += 1
        else:
            raise stbt.MatchTimeout(None, unselected_image, 0)

    while not _player_selected(selected_image):
        target = stbt.detect_match(unselected_image).next()
        if target.match:
            source = _matches("images/any-player-selected.png").next()
            stbt.debug("find_player: source=%d,%d target=%d,%d" % (
                    source.position.x, source.position.y,
                    target.position.x, target.position.y))
            stbt.press(_next_key(source.position, target.position))
            _wait_for_selection_to_move(source)
        else:
            next_page()
Example #7
0
 def to_home():
     for _ in range(5):
         stbt.press("KEY_HOME")
         menu = wait_until(Menu, predicate=lambda m: m.selection == "Home")
         if menu:
             return menu
     assert False, "Failed to find Roku Home after pressing KEY_HOME 5 times"
Example #8
0
 def to_home():
     for _ in range(5):
         stbt.press("KEY_HOME")
         menu = wait_until(Menu, predicate=lambda m: m.selection == "Home")
         if menu:
             return menu
     assert False, "Failed to find Roku Home after pressing KEY_HOME 5 times"
Example #9
0
def to_roku_home():
    for _ in range(5):
        press("KEY_HOME")
        if wait_until(lambda: find_selection().text == "Home"):
            break
    else:
        assert False, "Failed to find Roku Home after pressing HOME 5 times"
Example #10
0
 def wylaczKomunikatTVNaziemna(self):
     try:
         stbt.mach_text("ANTENA TELEWIZJI NAZIEMNEJ", None,
                        stbt.Region(410, 162, width=460, height=30))
     except MatchTimeout:
         pass
     else:
         stbt.press("KEY_RIGHT", Test.timeBeforePress)
         stbt.press("KEY_OK", Test.timeBeforePress)
Example #11
0
def navigate_to(context):
    for ctxt in KeyPresses:
        if ctxt == context:
            keypresslist = KeyPresses[context]
            break
    print "keypresslist '%s'" % keypresslist
    for key in keypresslist:
        print key
        stbt.press(key)
Example #12
0
def press_digits(digits):
    """Press a sequence of digits

    Args:
        digits (string): digits to input
    """
    for digit in digits:
        button = 'KEY_{0}'.format(digit)
        stbt.press(button)
def setup_backend(env_code):
    """Open Developer mode"""
    itu.clear_test()
    try:
        open_developer_mode()
        stbt.press(env_code)
        sleep(2)
    finally:
        itu.clear_test()
Example #14
0
def test_mydvr_launch():
    f = open("testFile.txt", "w+")
    stbt.press('KEY_EXIT')
    f.write("Step 1: press exit: Passed\n")
    stbt.press('KEY_MYDVR')
    f.write("Step 2: press MyDVR: Passed\n")
    f.close()
    assert stbt.wait_until(lambda: stbt.match("images/dvr/my_dvr.png")), \
    "MyDVR not launched"
Example #15
0
def dismissPopupIfPresent(scope={}):
    if popup.PopupBox():
        #TO DO check if it is safe to press OK to dismiss any popup which appears.
        stbt.press("KEY_OK")
    if stbt.wait_until(lambda: not popup.PopupBox()):
        return
    else:
        stbt.press("KEY_OK")
        assert stbt.wait_until(lambda: not popup.PopupBox())
Example #16
0
 def sprawdzUSB(self, port):
     result = stbt.match_text("USB", None,
                              stbt.Region(682, 162, width=70, height=28))
     if result.match == True:
         stbt.press("KEY_RIGHT", Test.timeBeforePress)
         stbt.press("KEY_OK", Test.timeBeforePress)
         self.testsResults[port] = True
     else:
         self.testsResults[port] = False
Example #17
0
 def dismiss(self):
     # There's a slight race condition here: If we detect the dialog when
     # there's like 1 second left in the countdown, by the time the script
     # calls `dismiss()` the dialog might have disappeared already. In that
     # case pressing EXIT will dump us back to live TV. This may not be a
     # problem in practice.
     stbt.press("KEY_EXIT")
     assert wait_until(lambda: not StillThereDialog()), \
         "'Still There?' dialog didn't disappear after pressing EXIT"
def button_exits_test(button):
    """Open MySky app and close it with the given button"""
    itu.go_to_channel(interactive_constants.CHANNEL_SKY_ONE_HD)
    open_and_basic_check_mysky()

    # Press the button:
    stbt.press(button)
    assert stbt.wait_until(lambda: not MySkyMainMenu().is_visible), \
        '[MySky] MySky menu did not close'
Example #19
0
def navigate_to_tile(image):
    from time import sleep

    for _ in range(15):
        key = _direction(image)
        if key:
            press(key)
            sleep(1)
        else:
            break
def tune_to_channel(channel_number):
    """This function tunes to channel number (channel_number)"""

    stbt.draw_text('Tune to channel                  : Channel %s', channel_number)

    for digit in str(channel_number):
        stbt.press('KEY_' + digit)
        wait(0.5)

    stbt.wait_until(lambda: ChannelBanner().is_visible, timeout_secs=5)
def navigate_to_actionmenuoption(optionName, validate=True):

    optionName = _(optionName)
    print "Optionname to be searched : " + optionName
    print "Value of validate: " + str(validate)
    optionFound = False
    error_message = "Failed to find '%s' after pressing DOWN 10 times" % optionName
    if stbt.wait_until(lambda: dtv_actionmenu_page.DTVActionMenuPage()):
        print "Looking for action menu option '%s'" % optionName
        sleep(2)
        option_list = []
        for num in range(11):
            current_selection_text = stbt.ocr(
                region=stbt.Region(x=373, y=467, right=925, bottom=505),
                mode=stbt.OcrMode.SINGLE_LINE,
                lang='nld',
                # tesseract_config={'load_system_dawg':False, 'load_freq_dawg':False},
            )
            if current_selection_text in option_list:
                print "All options iterated"
                print "No:of options : " + str(num)
                optionFound = False
                error_message = "Failed to find '%s'" % optionName
                break
            option_list.append(current_selection_text)
            print "nkjkjjj '%s'" % dtv_actionmenu_page.DTVActionMenuPage(
            ).selection
            print "action menu option read as '%s'" % current_selection_text
            if ocr_utils.fuzzy_match(current_selection_text, optionName, 0.78):
                print "Option " + optionName + " found"
                optionFound = True
                error_message = ""
                break
            sleep(2)
            stbt.press("KEY_DOWN")
            sleep(4)

    else:
        optionFound = False
        error_message = "Failed to launch Action Menu"
    if validate:
        print "Validating step"
        print "optionFound : " + str(optionFound)
        if optionFound == False:
            assert optionFound, error_message
    else:

        returnvalue = {
            "optionFound": optionFound,
            "option_list": option_list,
            "error_message": error_message
        }
        print "returning value from step navigate_to_actionmenuoption : " + str(
            returnvalue)
        return returnvalue
Example #22
0
def to_roku_home():
    for _ in range(5):
        press("KEY_HOME")

        if wait_until(lambda: match("selftest-screenshots/screenshot.png"),
                      timeout_secs=10):
            passMessageWith_Screenshots("Roku Home Screen is displayed")
            sleep(3)
            break
    else:
        assert False, "Fail/ Failed to find Roku Home after pressing HOME 5 times"
Example #23
0
def verify_logo_position(scope={}):
    if scope['tenAR']:
        icon = "ageRating_logo_Ten"
    elif scope['twelveAR']:
        icon = "ageRating_logo_Twelve"
    elif scope['sixteenAR']:
        icon = "ageRating_logo_Sixteen"
    elif scope['eighteenAR']:
        icon = "ageRating_logo_Eighteen"
    stbt.press("KEY_INFO")
    check_icon_on_screen(icon)
Example #24
0
def enter_menu(frame_object, menu_name, timeout_secs=10):
    """Select and enter menu with the given name

    Args:
        frame_object (Class): Class of the Frame Object that can read this menu
        menu_name (str): Name of the menu to enter
        timeout_secs (int): Timeout in seconds for finding the frame object
    """
    select_menu(frame_object, menu_name, timeout_secs)

    # Open menu:
    stbt.press('KEY_SELECT')
Example #25
0
def getProgram_Title(scope={}):
    print "Looking for title"
    stbt.press("KEY_INFO")
    stbt.wait_until(lambda: infobanner.Infobanner())
    sleep(2)
    current_selection_text = stbt.ocr(
        region=stbt.Region(x=317, y=633, right=838, bottom=683),
        mode=stbt.OcrMode.SINGLE_LINE,
        lang='nld',
        # tesseract_config={'load_system_dawg':False, 'load_freq_dawg':False},
    )
    return {"programTitle": current_selection_text}
Example #26
0
def tune_to_agerating_event(scope={}):
    coordinatesTen = getCoordinatesOfIcon("ageRating_icon_Ten")
    coordinatesTwelve = getCoordinatesOfIcon("ageRating_icon_Twelve")
    coordinatesSixteen = getCoordinatesOfIcon("ageRating_icon_Sixten")
    coordinatesEighteen = getCoordinatesOfIcon("ageRating_icon_Eighteen")
    try:
        for num in range(200):
            stbt.press("KEY_DOWN")
            sleep(2)
            tenAR = bool(
                stbt.match(coordinatesTen['image'],
                           region=stbt.Region(
                               x=coordinatesTen['x'],
                               y=coordinatesTen['y'],
                               right=coordinatesTen['right'],
                               bottom=coordinatesTen['bottom'])))
            twelveAR = bool(
                stbt.match(coordinatesTwelve['image'],
                           region=stbt.Region(
                               x=coordinatesTwelve['x'],
                               y=coordinatesTwelve['y'],
                               right=coordinatesTwelve['right'],
                               bottom=coordinatesTwelve['bottom'])))
            sixteenAR = bool(
                stbt.match(coordinatesSixteen['image'],
                           region=stbt.Region(
                               x=coordinatesSixteen['x'],
                               y=coordinatesSixteen['y'],
                               right=coordinatesSixteen['right'],
                               bottom=coordinatesSixteen['bottom'])))
            eighteenAR = bool(
                stbt.match(coordinatesEighteen['image'],
                           region=stbt.Region(
                               x=coordinatesEighteen['x'],
                               y=coordinatesEighteen['y'],
                               right=coordinatesEighteen['right'],
                               bottom=coordinatesEighteen['bottom'])))
            if (tenAR or twelveAR or sixteenAR or eighteenAR):
                stbt.press("KEY_OK")
                sleep(2)
                break
            else:
                print "Continue  through zap list"
        return {
            "status": True,
            "tenAR": tenAR,
            "twelveAR": twelveAR,
            "sixteenAR": sixteenAR,
            "eighteenAR": eighteenAR
        }
    except Exception, e:
        print "Couldnt find Channel with Age Rating"
        return {"status": False}
Example #27
0
def runChannel(number):
    keys = [
        "KEY_0", "KEY_1", "KEY_2", "KEY_3", "KEY_4", "KEY_5", "KEY_6", "KEY_7",
        "KEY_8", "KEY_9"
    ]
    counter = 0
    num = str(number)
    length = len(num)
    while counter < length:
        key = num[counter:counter + 1]
        stbt.press(keys[int(key)], timeBeforePress)
        counter += 1
Example #28
0
    def enter_text(self, page, text):
        """
        Enter the specified text using the on-screen keyboard.

        :param stbt.FrameObject page: An instance of a `stbt.FrameObject`
            sub-class that describes the appearance of the on-screen keyboard.
            It must implement the following:

            * ``selection`` — property that returns the name of the currently
              selected character, for example "A" or " ". This property can
              return a string, or an object with a ``text`` attribute that is
              a string.

            The ``page`` instance that you provide must represent the current
            state of the device-under-test.

        :param str text: The text to enter. If your keyboard only supports a
            single case then you need to convert the text to uppercase or
            lowercase, as appropriate, before passing it to this method.

        Typically your FrameObject will provide its own ``enter_text`` method,
        so your test scripts won't call this ``Keyboard`` class directly. For
        example::

            class YouTubeSearch(stbt.FrameObject):
                _kb = stbt.Keyboard('''
                    A B KEY_RIGHT
                    ...etc...
                    ''')

                @property
                def is_visible(self):
                    ...  # implementation not shown

                @property
                def selection(self):
                    ...  # implementation not shown

                def enter_text(self, text):
                    self._kb.enter_text(page=self, text=text.upper())
                    self._kb.navigate_to(page=self, target="SEARCH")
                    stbt.press("KEY_OK")
        """

        for letter in text:
            if letter not in self.G:
                raise ValueError("'%s' isn't in the keyboard" % (letter,))

        for letter in text:
            page = self.navigate_to(page, letter)
            stbt.press("KEY_OK")
        return page
Example #29
0
def open_Show(test,image):
    for _ in range(3): 
            result=match(image ,region=Region.ALL)
            episode=getText(result.region.x,135,result.region.right,result.region.bottom)   
            if Read_Data_CSV(test,'Episode') in episode:
                        key_press("KEY_OK","Episode")
                        break
            else:   
                press("KEY_RIGHT") 
                sleep(3)   
            
    else:
        assert False, failMessageWith_Screenshots("The particular Episode is not displaying in the screen")
def open_and_basic_check_manage_your_account():
    """Open the Manage your account menu and make basic checks"""
    open_and_basic_check_mysky()

    # Open menu:
    stbt.press('KEY_DOWN')
    assert stbt.wait_until(lambda: MySkyMainMenu().message == sky_plus_strings.MANAGE_YOUR_ACCOUNT), \
        '[MySky] Selected item is not [{0}]'.format(sky_plus_strings.MANAGE_YOUR_ACCOUNT)
    stbt.press('KEY_SELECT')

    menu = stbt.wait_until(ManageYourAccountMenu)
    assert menu.is_visible, '[ManageYourAccount] Menu is not visible'
    return menu
Example #31
0
def key_press(key,Keyname):
    try:      
       press(key)
       
       sleep(2)
       res = requests.get('http://10.244.7.52/api/v1/device/screenshot.png')
       fh = open("imageToSave-"+str(datetime.datetime.now().strftime('%Y-%m-%d %H-%M-%S'))+".png" , "wb")
       fh.write(res.content)
       fh.close() 
       print "Pass/ The Icon "+Keyname+" pressed successfully. screenshot :"+fh.name
    except Exception,e:
        print  "Fail/ Error While pressing The Key. Exception/  %s " % e.args
        raise e
Example #32
0
def open_and_basic_check_interactive_menu():
    """Open the My Messages app and make basic checks"""
    stbt.press('KEY_INTERACTIVE')
    sleep(1)
    menu = stbt.wait_until(InteractiveMainMenu)
    assert menu.is_visible, '[Interactive] Main menu is not visible'

    menu_items = menu.menu_items
    for item in menu_items:
        debug('Item text: {0}'.format(item.text))
        debug('Item selected: {0}'.format(item.selected))
    assert len(menu_items) == 9, '[Interactive] Main menu should have 9 items, but has {0}'.format(len(menu_items))
    return menu
def test_acceptance_simple_my_account_yellow_button():
    """Open My Account menu and go back to MySky main menu
    Automates: https://interactiveqa.testrail.net/index.php?/cases/view/27
    """
    itu.clear_test()
    try:
        itu.go_to_channel(interactive_constants.CHANNEL_SKY_ONE_HD)
        mysky_frame_objects.open_and_basic_check_manage_your_account()
        stbt.press('KEY_YELLOW')
        sleep(1)
        mysky_frame_objects.basic_check_mysky()
    finally:
        itu.clear_test()
Example #34
0
def test_DVR_on_reboot():
    count = 0
    while True:
        if stbt.is_screen_black(): break
        count += 1
        sleep(3)
        assert count < 10, \
        "STB did not reboot within 30 seconds with osdiag RebootNow"
    count = 0
    while True:
        stbt.press('KEY_POWER')
        sleep(5)
        if stbt.match('images/menu/stick_around.png') or stbt.match(
                'images/menu/reboot_logo.png'):
            break
        sleep(5)
        count += 1
        assert count < 18, \
        "Stick Around screen is not shown after reboot within 3 minutes"
    stbt.wait_for_motion(timeout_secs=300)
    stbt.press('KEY_RECORD')
    assert stbt.wait_until(lambda: stbt.match("images/dvr/edit_ep_rec.png") or stbt.match("images/dvr/ch_bar_rec.png")), \
    "RECORD press on live TV did not set recording, or prompt for edit recording"
    mydvr_launch()
    count = 0
    while True:
        stbt.press('KEY_ENTER')
        if stbt.match('images/cta/watch.png'): break
        count += 1
        assert count < 16, \
        "Could not find recording to play in DVR page"
    stbt.press('KEY_ENTER')
    assert stbt.wait_for_motion(timeout_secs=20)
Example #35
0
def test_that_image_is_rotated_by_arrows():
    press("KEY_LEFT")
    wait_for_match('stb-tester-left.png')
    press("KEY_RIGHT")
    wait_for_match('stb-tester-right.png')
    press("KEY_UP")
    wait_for_match('stb-tester-up.png')
    press("KEY_DOWN")
    wait_for_match('stb-tester-down.png')
Example #36
0
def test_entering_the_settings_menu():
    to_roku_home()

    for _ in range(5):
        press("KEY_DOWN")
        if wait_until(lambda: find_selection().text == "Settings",
                      timeout_secs=2):
            break
    else:
        assert False, "Failed to find 'Settings' menu item"

    press("KEY_OK")
    assert wait_until(lambda: find_selection().text == "Network"), \
        "Failed to find 'Network' settings sub-menu"

    press("KEY_BACK")
    assert wait_until(lambda: find_selection().text == "Settings"), \
        "Pressing BACK didn't take me back to 'Settings' menu item"
def test_that_roku_home_says_streaming_channels():
    stbt.press('KEY_HOME')
    assert stbt.wait_until(lambda: stbt.match_text("Streaming Channels"))
Example #38
0
def checkers_via_gamut():
    """Change input video to "gamut" patterns, then "checkers" pattern"""
    wait_for_match("videotestsrc-redblue.png")
    press("gamut")
    wait_for_match("videotestsrc-gamut.png")
    press("checkers-8")
def test_that_live_tv_is_playing():
    stbt.press('KEY_CLOSE')  # Close any open menus
    assert stbt.wait_for_motion()
def test_read_menu():
    stbt.press('KEY_CLOSE')
    sleep(1)
    stbt.press('KEY_MENU')
    sleep(1)
    print stbt.ocr()
def test_that_stb_tester_logo_is_shown():
    stbt.press('KEY_CHANNELUP')
    assert stbt.wait_for_match('stb-tester-logo.png')
Example #42
0
def checkers_via_gamut():
    """Change input video to "gamut" patterns, then "checkers" pattern"""
    wait_for_match("videotestsrc-redblue.png", consecutive_matches=24)
    press("15")
    wait_for_match("videotestsrc-gamut.png", consecutive_matches=24)
    press("10")
Example #43
0
def test_that_custom_key_is_recognised():
    press("KEY_CUSTOM")
    wait_for_match('stb-tester-up.png', timeout_secs=1)
Example #44
0
def test_that_image_returns_to_normal_on_OK():
    press("KEY_OK")
    wait_for_match('stb-tester-350px.png')
Example #45
0
import glob
import os
import sys
import time

import stbt

for arg in sys.argv[1:]:
    print "Command-line argument: %s\n" % arg

# Fail if this script is run more than once from the same $scratchdir
n_runs = len(glob.glob("../????-??-??_??.??.??*"))  # includes current run
if n_runs == 2:
    raise stbt.UITestError("Not the system-under-test's fault")
elif n_runs > 2:  # UITestFailure
    stbt.wait_for_match("videotestsrc-checkers-8.png", timeout_secs=1)

stbt.press("gamut")
stbt.wait_for_match("videotestsrc-gamut.png")

time.sleep(float(os.getenv("sleep", 0)))

stbt.press("smpte")
stbt.wait_for_motion()