Beispiel #1
0
def open_file_via_menu(context, filename):
    keyCombo("<Ctrl>O")
    context.execute_steps(u"""
        * file select dialog with name "Open Image" is displayed
        * In file select dialog select "%s"
    """ % filename)
    sleep(0.5)
Beispiel #2
0
    def closeViaShortcut(self):
        """
        Close the app via shortcut
        """
        internCritical = (self.critical == 'quit')

        if not self.isRunning():
            if internCritical:
                self.updateResult(False)
            #print "!!! The app does not seem to be running"
            return False

        keyCombo(self.shortcut)
        sleep(self.timeout)

        if self.isRunning():
            if self.forceKill:
                self.kill()
            if internCritical:
                self.updateResult(False)
            #print "!!! The app is running but it shouldn't be"
            return False
        else:
            if self.existsCoreDump() != 0:
                if internCritical:
                    self.updateResult(False)
                # print "!!! The app closed with core dump created. Signal %d"\
                #        % self.existsCoreDump()
                return False
            if internCritical:
                self.updateResult(True)
            #print "*** The app was successfully closed"
            return True
def select_first_suggestion_as_field_typing_name(context, field, name):
    context.app.composer.child(field).grab_focus()
    typeText(name)
    sleep(1)
    keyCombo("<Down>")
    keyCombo("<Enter>")
    sleep(0.5)
Beispiel #4
0
    def __init__(self,
                 appName,
                 shortcut='<Control><Q>',
                 a11yAppName=None,
                 forceKill=True,
                 parameters='',
                 recordVideo=False):
        """
        Initialize object App
        appName     command to run the app
        shortcut    default quit shortcut
        a11yAppName app's a11y name is different than binary
        forceKill   is the app supposed to be kill before/after test?
        parameters  has the app any params needed to start? (only for startViaCommand)
        recordVideo start gnome-shell recording while running the app
        """
        self.appCommand = appName
        self.shortcut = shortcut
        self.forceKill = forceKill
        self.parameters = parameters
        self.internCommand = self.appCommand.lower()
        self.a11yAppName = a11yAppName
        self.recordVideo = recordVideo
        self.pid = None

        # a way of overcoming overview autospawn when mouse in 1,1 from start
        pressKey('Esc')
        absoluteMotion(100, 100, 2)

        # attempt to make a recording of the test
        if self.recordVideo:
            keyCombo('<Control><Alt><Shift>R')
Beispiel #5
0
    def startViaMenu(self, throughCategories=False):  # pylint: disable=W0613
        """
        Start the app via Gnome Shell menu
        """
        desktopConfig = self.parseDesktopFile()

        if self.forceKill and self.isRunning():
            self.kill()
            assert wait_until(lambda x: not x.isRunning(), self, timeout=30),\
                "Application cannot be stopped"

        # panel button Activities
        gnomeShell = root.application('gnome-shell')
        os.system("dbus-send --session --type=method_call " +
                  "--dest='org.gnome.Shell' " +
                  "'/org/gnome/Shell' " +
                  "org.gnome.Shell.FocusSearch")
        textEntry = gnomeShell.textentry('')
        assert wait_until(lambda x: x.showing, textEntry), \
            "Can't find gnome shell search textbar"

        typeText(self.desktopFileName)
        keyCombo('<Enter>')

        assert wait_until(lambda x: x.isRunning(), self, timeout=30),\
            "Application failed to start"
def search_for_message(context, name):
    # Clear existing search
    for attempts in range(0, 10):
        try:
            context.search_bar.text = ''
            break
        except (GLib.GError, AttributeError):
            sleep(0.1)
            continue
    context.search_bar.grab_focus()
    context.search_bar.keyCombo('<Enter>')
    sleep(1)

    # Perform the search
    for attempts in range(0, 10):
        try:
            context.search_bar.text = name
            break
        except (GLib.GError, AttributeError):
            sleep(0.1)
            continue
    context.search_bar.grab_focus()
    sleep(0.5)
    context.search_bar.keyCombo('<Enter>')
    context.app.instance.child(name='Messages', roleName='panel').click()
    keyCombo('<Home>')
Beispiel #7
0
    def kill(self):
        """
        Kill the app via 'killall'
        """
        try:
            # first try to quit graciously
            GnomeShell().clickApplicationMenuItem(
                self.getName(self.parseDesktopFile()), "Quit")
            assert wait_until(lambda x: not x.isRunning(), self, timeout=30)
        except (AssertionError, SearchError):
            try:
                # okay, didn't work. Kill by pid
                self.process.kill()
                assert wait_until(lambda x: not x.isRunning(),
                                  self, timeout=30)
            except:  # pylint: disable=bare-except
                # send SIGKILL if sigterm didn't work
                Popen("killall -9 " + self.appCommand + " > /dev/null",
                      shell=True).wait()
        self.pid = None

        if self.recordVideo:
            keyCombo('<Control><Alt><Shift>R')
            if self.recordVideoName is not None:
                # Rename the last screencast according to the template in
                # self.recordVideoName
                scrcast_list = sorted(glob.glob(
                    os.path.join(os.path.expanduser('~/Videos'),
                                 'Screencast*')))
                last_scrcast = scrcast_list[-1]
                curtime = datetime.datetime.now().strftime('%Y-%m-%dT%H-%M-%S')
                os.rename(last_scrcast,
                          os.path.expanduser('~/Videos/%s_%s.webm' %
                                             (self.recordVideoName, curtime)))
Beispiel #8
0
def type_text_to_paragraph(context, replaced_text, replacement):
    """
    In this method we use shortcut CTRL+h to fire replace dialog window,
    then submit changes.
    """
    # fire dialog with ctrl+h
    keyCombo('<Control>h')
    dialog = context.app.get_current_window()
    # Search Field
    dialog.findChildren(lambda x: x.name == 'Search For' and x.roleName=='panel')[0].\
        child(roleName='text').typeText(replaced_text)
    dialog.findChildren(lambda x: x.roleName == 'push button' and x.name == 'Find All' and x.showing)[0].click()
    # Replace Field
    dialog.findChildren(lambda x: x.name == 'Replace With' and x.roleName=='panel')[0].\
        child(roleName='text').typeText(replacement)
    dialog.findChildren(lambda x: x.roleName == 'push button' and x.name == 'Replace All' and x.showing)[0].click()

    # this is used for wait of alert - it takes some time to render and not in all situation its gets showed instantly
    sleep(1)
    alert_dialog = context.app.get_current_window()
    click_button_in_dialog_window(context, "OK")

    assert not alert_dialog.showing, "Alert Dialog is still showing and probably also have focus"
    assert context.paragraph.text == replacement, "Incorrect text in paragraph, expected '%s' but was '%s'" % (
        replacement, context.paragraph.text)

    dialog.findChildren(lambda x: x.roleName == 'push button' and x.name == 'Close' and x.showing)[0].click()
Beispiel #9
0
def select_file_in_dialog(context, name, path):
    # click search button
    context.app.dialog.findChildren(lambda x: x.roleName == 'toggle button' and x.showing)[0].click()

    full_path = os.path.join(path, name)
    typeText(full_path)
    keyCombo('<enter>')
def show_attendee_field(context, field):
    context.app.event_editor.menu('View').click()
    menuItem = context.app.event_editor.menu('View').menuItem('%s Field' % field.capitalize())
    if not menuItem.checked:
        menuItem.click()
    else:
        keyCombo('<Esc>')
def add_new_reminder_with_following_options(context):
    context.app.reminders.button('Add').click()
    dialog = context.app.instance.dialog('Add Reminder')

    for row in context.table:
        if row['Field'] in ['Action', 'Period', 'Before/After', 'Start/End']:
            value = row['Value']
            combo = dialog.child(value, roleName='menu item').parent.parent
            if combo.combovalue != value:
                combo.combovalue = value
        elif row['Field'] == 'Num':
            spin_button = dialog.child(roleName='spin button')
            spin_button.text = row['Value']
            spin_button.grab_focus()
            keyCombo('<Enter>')
        elif row['Field'] == 'Message':
            dialog.child('Custom message').click()
            # dialog.childLabelled('Message:').text = row['Value']
            dialog.child(roleName='text').text = row['Value']
        else:
            dialog.childLabelled(row['Field']).text = row['Value']

    dialog.button('OK').click()

    assert wait_until(lambda x: x.dead, dialog), "Add Reminder dialog was not closed"
Beispiel #12
0
def insert_table(context):
    keyCombo('<Control><F12>')
    context.app.get_current_window().findChildren(
        lambda x: x.roleName == 'push button' and x.name == 'Insert' and x.showing)[0].click()

    assert len(context.app.get_current_window().findChildren(
        lambda x: x.showing and x.roleName == 'table')) != 0, "In paragraph should be at least one table"
Beispiel #13
0
def undo_replace_text_with_shortcut(context):
    # this take context.paragraph.text which is stored on first place in type_text_to_paragraph
    # and compare if its the same with text after undo changes
    keyCombo('<Control>z')

    assert context.paragraph.text == context.original_paragraph_text, \
        "Incorrect text in paragraph, expected '%s' but was '%s'" % (
            context.original_paragraph_text, context.paragraph.text)
Beispiel #14
0
def select_menu_action(context, action):
    keyCombo("<Super_L><F10>")
    if action == 'About':
        pressKey('Down')
    if action == 'Quit':
        pressKey('Down')
        pressKey('Down')
    pressKey('Enter')
Beispiel #15
0
def hit_keycombo(context, keycombo):
    sleep(0.2)
    if keycombo == "Enter":
        pressKey("Enter")
    else:
        keyCombo('%s'%keycombo)

    sleep(0.2)
 def kill(self):
     """
     Kill the app via 'killall'
     """
     if self.recordVideo:
         keyCombo('<Control><Alt><Shift>R')
     print("*** Killing all '%s' instances" % self.appCommand)
     return Popen("pkill " + self.appCommand, shell=True).wait()
Beispiel #17
0
def quit_boxes(context):
    keyCombo('<Ctrl><Q>')
    counter = 0
    while call('pidof gnome-boxes > /dev/null', shell=True) != 1:
        sleep(0.5)
        counter += 1
        if counter == 100:
            raise Exception("Failed to turn off Boxes in 50 seconds")
Beispiel #18
0
def file_save_to_path(context, path, name):

    full_path = os.path.join(path, name)
    context.app.dialog = context.app.get_current_window()
    context.app.dialog.findChildren(lambda x: x.roleName == 'text')[0].set_text_contents(full_path)
    context.app.dialog.findChildren(lambda x: x.roleName == 'text')[0].grab_focus()
    keyCombo('<Enter>')
    sleep(1)
Beispiel #19
0
def file_open_on_path(context, path, name):

    full_path = os.path.join(path, name)
    context.app.dialog = context.app.get_current_window()
    context.app.dialog.childLabelled('Location:').set_text_contents(full_path)
    context.app.dialog.childLabelled('Location:').grab_focus()
    keyCombo('<Enter>')
    sleep(1)
Beispiel #20
0
def select_menu_action(context, action):
    keyCombo("<Super_L><F10>")
    gs = GnomeShell()
    buttons = gs.getApplicationMenuList()
    sleep(0.5)
    for button in buttons:
        if button.name == action:
            button.click()
            break
Beispiel #21
0
    def closeViaShortcut(self):
        """
        Close the app via shortcut
        """
        if not self.isRunning():
            raise Exception("App is not running")

        keyCombo(self.shortcut)
        assert not self.isRunning(), "Application cannot be stopped"
Beispiel #22
0
    def closeViaShortcut(self):
        """
        Close the app via shortcut
        """
        if not self.isRunning():
            raise Exception("App is not running")

        keyCombo(self.shortcut)
        assert not self.isRunning(), "Application cannot be stopped"
Beispiel #23
0
def insert_table(context):
    keyCombo("<Control><F12>")
    context.app.get_current_window().findChildren(
        lambda x: x.roleName == "push button" and x.name == "Insert" and x.showing
    )[0].click()

    assert (
        len(context.app.get_current_window().findChildren(lambda x: x.showing and x.roleName == "table")) != 0
    ), "In paragraph should be at least one table"
Beispiel #24
0
    def closeViaShortcut(self):
        """
        Close the app via shortcut
        """
        if not self.isRunning():
            raise Exception("App is not running")

        keyCombo(self.shortcut)
        assert wait_until(lambda x: not x.isRunning(), self, timeout=30),\
            "Application cannot be stopped"
Beispiel #25
0
def rename_vm(context, machine, name, way):
    if way == 'button':
        context.app.child(machine, roleName='push button').click()
    if way == 'label':
        context.app.child('General').child('Name').parent.child(roleName='text').click()
        keyCombo('<Ctrl><a>')
    context.execute_steps(u"""
        * Type text "%s" and return
        """ % name )
    sleep(0.5)
def select_first_suggestion_as_attendee(context, name):
    context.app.event_editor.button('Add').click()
    typeText(name)
    sleep(1)

    # Again, cell renderer is not avaiable here
    keyCombo("<Down>")
    keyCombo("<Enter>")

    sleep(0.5)
Beispiel #27
0
def select_file_in_dialog(context, name):
    location_button = context.app.dialog.child('Enter Location')
    if pyatspi.STATE_ARMED not in location_button.getState().getStates():
        location_button.click()

    location_text = context.app.dialog.child(roleName='text')
    location_text.set_text_contents(name)
    doDelay(0.2)
    location_text.grab_focus()
    keyCombo('<Enter>')
Beispiel #28
0
def select_file_in_dialog(context, name):
    location_button = context.app.dialog.child('Enter Location')
    if pyatspi.STATE_ARMED not in location_button.getState().getStates():
        location_button.click()

    location_text = context.app.dialog.child(roleName='text')
    location_text.set_text_contents(name)
    doDelay(0.2)
    location_text.grab_focus()
    keyCombo('<Enter>')
Beispiel #29
0
def rename_vm(context, machine, name, way):
    if way == 'button':
        context.app.child(machine, roleName='push button').click()
        sleep(0.5)
    if way == 'label':
        context.app.child('General').child('Name').parent.child(roleName='text').click()
        keyCombo('<Ctrl><a>')
    typeText(name)
    pressKey('Enter')
    sleep(0.5)
def delete_all_emails_with_in_folder(context, subject, name):
    context.execute_steps(u'* Open "%s" folder' % name)
    search_for_message(context, subject)
    keyCombo('<Ctrl>A')
    context.app.instance.menu('Edit').click()
    mnu = context.app.instance.menu('Edit').menuItem('Delete Message')
    if pyatspi.STATE_ENABLED in mnu.getState().getStates():
        mnu.click()
    else:
        context.app.instance.menu('Edit').click()
Beispiel #31
0
    def closeViaShortcut(self):
        """
        Close the app via shortcut
        """
        if not self.isRunning():
            raise Exception("App is not running")

        keyCombo(self.shortcut)
        assert wait_until(lambda x: not x.isRunning(), self, timeout=30),\
            "Application cannot be stopped"
Beispiel #32
0
    def startViaCommand(self):
        """
        Start the app via command
        """
        internCritical = (self.critical == 'start')
        if self.forceKill and self.isRunning():
            self.kill()
            sleep(2)
            if self.isRunning():
                if internCritical:
                    self.updateResult(False)
                #print "!!! The app is running but it shouldn't be"
                return False
            else:
                pass
                #print "*** The app has been killed succesfully"

        returnValue = 0
        command = "%s %s &" % (self.appCommand, self.parameters)
        import os
        os.system(command)
        returnValue = 1
        #returnValue = utilsRun(command, timeout = 1, dumb = True)

        #if there is a polkit
        if self.polkit:
            sleep(3)
            typeText(self.polkitPass)
            keyCombo('<Enter>')

        start_time = 0
        while start_time < self.timeout:
            if self.isRunning():
                break
            sleep(0.5)
            start_time += 0.5

        #check the returned values
        if returnValue is None:
            if internCritical:
                self.updateResult(False)
            #print "!!! The app command could not be found"
            return False
        else:
            if self.isRunning():
                if internCritical:
                    self.updateResult(True)
                #print "*** The app started successfully"
                return True
            else:
                if internCritical:
                    self.updateResult(False)
                    #print "!!! The app did not started despite " \
                    #        + "the fact that the command was found"
                return False
Beispiel #33
0
def file_open_on_path(context, path, name):

    full_path = os.path.join(path, name)
    context.app.dialog = context.app.get_current_window()
    if not context.app.dialog.childLabelled('Location:').showing:
        context.app.dialog.findChildren(lambda x: x.name == 'Type a file name')[0].click()

    context.app.dialog.childLabelled('Location:').set_text_contents(full_path)
    context.app.dialog.childLabelled('Location:').grab_focus()
    keyCombo('<Enter>')
    sleep(1)
def mail_viewer_has_attachment_named(context, name, filename):
    keyCombo('<Alt>a')

    context.execute_steps(u"""
        * file select dialog with name "Save Attachment" is displayed
        * in file save dialog save file to "%s" clicking "Save"
    """ % filename)
        # Handle replace dialog
    alert = context.app.instance.findChild(GenericPredicate(roleName='alert', name='Question'), retry=False, requireResult=False)
    if alert:
        alert.button("Replace").click()
Beispiel #35
0
def rename_vm(context, machine, name, way):
    if way == 'button':
        context.app.child(machine, roleName='push button').click()
        sleep(0.5)
    if way == 'label':
        context.app.child('General').child('Name').parent.child(
            roleName='text').click()
        keyCombo('<Ctrl><a>')
    typeText(name)
    pressKey('Enter')
    sleep(0.5)
Beispiel #36
0
def handle_authentication_window(context, password='******'):
    # Get a list of applications
    app_names = []
    for attempt in range(0, 15):
        try:
            app_names = map(lambda x: x.name, root.applications())
            break
        except GLib.GError:
            sleep(1)
            continue
    if 'gcr-prompter' in app_names:
        # Non gnome shell stuf
        passprompt = root.application('gcr-prompter')
        continue_button = passprompt.findChild(
            GenericPredicate(name='Continue'),
            retry=False,
            requireResult=False)
        if continue_button:
            passprompt.findChildren(
                GenericPredicate(roleName='password text'))[-1].grab_focus()
            sleep(0.5)
            typeText(password)
            # Don't save passwords to keyring
            keyCombo('<Tab>')
            # Click Continue
            keyCombo('<Tab>')
            keyCombo('<Tab>')
            keyCombo('<Enter>')
    elif 'gnome-shell' in app_names:
        shell = root.application('gnome-shell')
        # if wait_until(lambda x: x.findChildren(
        #         lambda x: x.roleName == 'password text' and x.showing) != [], shell):
        #     pswrd = shell.child(roleName='password text')
        #     pswrd.text = password
        #     st = shell.child('Add this password to your keyring')
        #     if not st.parent.parent.checked:
        #         st.click()
        #     continue_button = shell.button('Continue')
        #     shell.button('Continue').click()
        #     sleep(3)
        if wait_until(
                lambda x: x.findChildren(lambda x: x.roleName ==
                                         'password text' and x.showing) != [],
                shell):
            st = shell.child('Add this password to your keyring')
            if not st.parent.parent.checked:
                st.click()
            pswrd = shell.child(roleName='password text')
            pswrd.click()
            typeText(password)
            keyCombo('<Enter>')
            wait_until(st.dead)
            sleep(1)
    def kill(self):
        """
        Kill the app via 'killall'
        """
        if self.recordVideo:
            keyCombo('<Control><Alt><Shift>R')

        try:
            self.process.kill()
        except:
            # Fall back to killall
            Popen("killall " + self.appCommand, shell=True).wait()
Beispiel #38
0
 def test_03_scale(self):
     app = self._app()
     app.keyCombo("C")
     dialog = self._app().child(roleName="dialog")
     from dogtail import rawinput
     rawinput.keyCombo("Tab")
     rawinput.typeText("200")
     dialog.child(name="OK").click()
     self._wait_cond(lambda: dialog.dead)
     app.keyCombo("<ctrl>Left")  # rotate left
     self._assert_selected("2")
     self._assert_page_size(558.8, 431.8)
Beispiel #39
0
def add_sheet_in_spreadsheet(context, sheet_name):
    menu_item_insert = context.app.get_current_window().child(roleName='menu bar')[3]
    menu_item_insert.click()
    menu_item_insert.child(name='Sheet...').click()
    context.dialog = context.app.get_current_window()
    assert context.dialog.name == "Insert Sheet", "Name of dialog is: %s, should be %s" % (
        context.dialog.name, "Insert Sheet")

    context.dialog.child(roleName='text', name='Name:').grabFocus()
    keyCombo("<CTRL>a")
    pressKey("del")
    typeText(sheet_name)
    context.dialog.child(name='OK', roleName='push button').click()
Beispiel #40
0
def select_on_table(from_cell, from_cell_index, number_of_columns, number_of_rows):
    """
    Select part of table defined by number_of_columns and number_of_rows from particular cell
    """

    CELLS[from_cell_index] = from_cell
    from_cell.grabFocus()

    for i in range(0, number_of_columns - 1):
        keyCombo("<SHIFT><Right>")

    for i in range(0, number_of_rows - 1):
        keyCombo("<SHIFT><Down>")
Beispiel #41
0
 def keyCombo(self, comboString):
     if config.debugSearching:
         logger.log(str("Pressing keys '%s' into %s") %
                    (str(comboString), self.getLogString()))
     if self.focusable:
         if not self.focused:
             try:
                 self.grabFocus()
             except Exception:
                 logger.log("Node is focusable but I can't grabFocus!")
     else:
         logger.log("Node is not focusable; trying key combo anyway")
     rawinput.keyCombo(comboString)
Beispiel #42
0
def select_cell(context, text, column_name, row_name):

    keyCombo('<F5>')
    sleep(1)
    context.dialog = context.app.get_current_window()
    assert "Navigator" == context.dialog.name, "Name of dialog is: %s, should be: %s"\
                                               % (context.dialog.name, "Navigator")

    column_field = context.dialog.child(name='Column', roleName='text')
    row_field = context.dialog.child(name='Row', roleName='text')
    column_field.text = column_name
    row_field.text = row_name
    pressKey("enter")
    typeText(text)
Beispiel #43
0
    def __init__(self,
                 appName,
                 shortcut='<Control><Q>',
                 desktopFileName=None,
                 timeout=5,
                 a11yAppName=None,
                 forceKill=True,
                 parameters='',
                 recordVideo=False,
                 recordVideoName=None):
        """
        Initialize object App
        appName     command to run the app
        shortcut    default quit shortcut
        a11yAppName app's a11y name is different than binary
        timeout     timeout for starting and shuting down the app
        forceKill   is the app supposed to be kill before/after test?
        parameters  has the app any params needed to start? (only for
                    startViaCommand)
        recordVideo start gnome-shell recording while running the app
        recordVideoName filename template for renaming the screencast video
        desktopFileName = name of the desktop file if other than
                          appName (without .desktop extension)
        """
        self.appCommand = appName
        self.shortcut = shortcut
        self.timeout = timeout
        self.forceKill = forceKill
        self.parameters = parameters
        self.internCommand = self.appCommand.lower()
        self.a11yAppName = a11yAppName
        self.recordVideo = recordVideo
        self.recordVideoName = recordVideoName
        self.pid = None

        # a way of overcoming overview autospawn when mouse in 1,1 from start
        pressKey('Esc')
        absoluteMotion(100, 100, 2)

        # set correct desktop file name
        if desktopFileName is None:
            desktopFileName = self.appCommand
        self.desktopFileName = desktopFileName

        # attempt to make a recording of the test
        if self.recordVideo:
            # Screencasts stop after 30 secs by default, see https://bugzilla.redhat.com/show_bug.cgi?id=1163186#c1
            cmd = "gsettings set org.gnome.settings-daemon.plugins.media-keys max-screencast-length 600"
            Popen(cmd, shell=True, stdout=PIPE).wait()
            keyCombo('<Control><Alt><Shift>R')
Beispiel #44
0
    def quit(self):
        """
        Quit the app via 'Ctrl+Q'
        """
        if self.recordVideo:
            keyCombo('<Control><Alt><Shift>R')

        try:
            #os.system("pkill -9 gnome-boxes")
            keyCombo('<Ctrl><Q>')
            if self.isRunning():
                self.kill()
        except:
            pass
Beispiel #45
0
def create_table_in_design_mode(context, name, dbname):
    select_menuitem(context, "Insert -> Table Design...")
    window_is_displayed(
        context,
        dbname + ".odb : " + "Table1" + " - LibreOffice Base: Table Design")
    # fill out values for table
    create_table_window = context.app.get_current_window()
    master_table = create_table_window.findChildren(
        lambda x: x.roleName == 'table' and x.name == 'Table')[0]

    # this part is kind of magic - it uses TAB for moving in table and grabFocus
    # and typeText because original type text on object of table is not implemented in current version of dogtail
    master_table[1].grabFocus()
    typeText(TABLE_FIELDS[0]['name'])

    pressKey('\t')
    pressKey('\t')
    typeText(TABLE_FIELDS[0]['description'])

    pressKey('\t')

    typeText(TABLE_FIELDS[1]['name'])
    pressKey('\t')
    pressKey('\t')
    typeText(TABLE_FIELDS[1]['description'])

    pressKey('\t')

    typeText(TABLE_FIELDS[2]['name'])
    pressKey('\t')
    pressKey('\t')
    typeText(TABLE_FIELDS[2]['description'])

    # click na save as
    create_table_window.findChildren(
        lambda x: x.roleName == 'push button' and x.name == 'Save' and x.
        showing)[0].click()
    dialog = context.app.get_current_window()
    sleep(2)
    assert dialog.name == 'Save As', "probably bad dialog because name of dialog should be Save as, but was '%s'" % (
        dialog.name)
    dialog.textentry('Table Name').typeText(name)
    dialog.button('OK').click()

    if context.app.get_current_window().name == 'LibreOffice Base':
        context.app.get_current_window().button('Yes').click()
    # close edit table window
    keyCombo('<Control>w')
Beispiel #46
0
 def test_02_properties(self):
     self._mainmenu("Edit Properties")
     dialog = self._app().child(roleName="dialog")
     creatorlab = dialog.child(roleName="table cell", name="Creator")
     creatorid = creatorlab.parent.children.index(creatorlab) + 1
     creatorval = creatorlab.parent.children[creatorid]
     creatorval.keyCombo("enter")
     from dogtail import rawinput
     rawinput.typeText('["Frodo", "Sam"]')
     dialog.child(name="OK").click()
     self._mainmenu("Edit Properties")
     dialog = self._app().child(roleName="dialog")
     rawinput.keyCombo("enter")
     rawinput.typeText('Memories')
     rawinput.keyCombo("enter")
     dialog.child(name="OK").click()
Beispiel #47
0
def refresh_addressbook(context):
    #Clear the search
    icons = context.app.search_bar.findChildren(lambda x: x.roleName == 'icon')
    if icons != []:
        icons[-1].click()
    else:
        for attempts in range(0, 10):
            try:
                context.app.search_bar.text = ''
                break
            except (GLib.GError, AttributeError):
                sleep(0.1)
                continue
        context.app.search_bar.grab_focus()
        keyCombo('<Enter>')
    context.execute_steps(u"* Wait for email to synchronize")
Beispiel #48
0
def add_google_account(context, user, password):
    dialog = get_showing_node_name('Google account', context.app.instance)
    #idialog = context.app.instance.dialog('Google account')

    # Input credentials
    entry = get_showing_node_name('Enter your email', dialog)
    if entry.text != user:
        entry.click()
        typeText(user)
    if dialog.findChildren(lambda x: x.roleName == 'password text') == []:
        dialog.child('Next').click()
    get_showing_node_name('Password', dialog).click()
    typeText(password)
    keyCombo('<Enter>')
    #get_showing_node_name('Sign in', dialog).click()

    # Wait for Allow to appear
    third_party_icon_pred = GenericPredicate(roleName='push button',
                                             name='Allow')
    for attempts in range(0, 40):  # pylint: disable=W0612
        if dialog.findChild(third_party_icon_pred,
                            retry=False,
                            requireResult=False) is not None:
            break
        else:
            doDelay(0.5)

    allow_button = dialog.child("Allow", roleName='push button')
    if not allow_button.showing:
        # Scroll to confirmation button
        scrolls = dialog.findChildren(GenericPredicate(roleName='scroll bar'))
        scrolls[-1].value = scrolls[-1].maxValue
        pressKey('space')
        pressKey('space')

    # Wait for button to become enabled
    for attempts in range(0, 10):
        if pyatspi.STATE_SENSITIVE in \
                allow_button.getState().getStates():
            break
        else:
            doDelay(0.5)

    sleep(1)
    allow_button.click()
    assert wait_until(lambda x: x.dead, dialog), \
        "Dialog was not closed"
Beispiel #49
0
    def kill(self):
        """
        Kill the app via 'killall'
        """
        if self.recordVideo:
            keyCombo('<Control><Alt><Shift>R')

        try:
            # Kill by pid
            kill(self.pid, SIGTERM)
            assert wait_until(lambda x: not x.isRunning(),
                              self, timeout=10)
        except:
            # send SIGKILL if sigterm didn't work
            Popen("killall -9 " + self.processName + " > /dev/null",
                  shell=True).wait()
        self.pid = None
Beispiel #50
0
def selec_values_from_and_to_in_random_number_dialog_and_confirm(context, from_number, to_number):
    parameters_section = context.dialog_random.child(name="Random Number Generator")

    minimum_text_field = parameters_section.child(roleName="text", name="Minimum")
    minimum_text_field.grabFocus()
    keyCombo("<CTRL>a")
    pressKey("del")
    minimum_text_field.typeText(from_number)

    maximum_text_field = parameters_section.child(roleName="text", name="Maximum")
    maximum_text_field.grabFocus()
    keyCombo("<CTRL>a")
    pressKey("del")
    maximum_text_field.typeText(to_number)

    context.dialog_random.child(name="Apply").click()
    context.dialog_random.child(name="OK").click()
Beispiel #51
0
def enter_records_to_table(context):
    table = context.app.get_current_window().findChildren(
        lambda x: x.roleName == 'table' and x.name == 'Table' and x.showing)[0]
    table[1].grabFocus()
    for record in TABLE_RECORDS:
        typeText(record['id'])
        pressKey('\t')
        typeText(record['name'])
        pressKey('\t')
        typeText(record['address'])
        pressKey('\t')
        typeText(record['phone'])
        pressKey('\t')
    context.app.get_current_window().findChildren(
        lambda x: x.roleName == 'push button' and x.name ==
        'Save current record' and x.showing)[0].click()
    # close edit table window
    keyCombo('<Control>w')
Beispiel #52
0
def enter_records_to_table(context):
    table = context.app.get_current_window().findChildren(
        lambda x: x.roleName == 'table' and x.name == 'Table' and x.showing)[0]
    table[1].grabFocus()
    for record in TABLE_RECORDS_NON_ENGLISH:
        #Converting strings to unicode,to work with F23
        typeText(record['id'].decode('utf-8'))
        pressKey('\t')
        typeText(record['name'].decode('utf-8'))
        pressKey('\t')
        typeText(record['address'].decode('utf-8'))
        pressKey('\t')
        typeText(record['phone'].decode('utf-8'))
        pressKey('\t')
    sleep(10)
    context.app.get_current_window().findChildren(
        lambda x: x.roleName == 'push button' and x.name ==
        'Save current record' and x.showing)[0].click()
    # close edit table window
    keyCombo('<Control>w')
Beispiel #53
0
 def test_keyCombo_multi(self):
     self.runDemo('Clipboard')
     try:
         wnd = self.app.child('Clipboard demo', roleName='frame', retry=False, recursive=False)
     except SearchError:
         wnd = self.app.child('Clipboard', roleName='frame', retry=False, recursive=False)
     textfield = wnd.child(roleName='text')
     textfield.text = 'something'
     keyCombo('<Control>a')
     keyCombo('<Control>c')
     keyCombo('<Control>v')
     keyCombo('<Control>v')
     self.assertEqual(textfield.text, 'somethingsomething')
Beispiel #54
0
def kde_common_after_scenario(context, scenario, kill=True):
    common_after_scenario(context, scenario, kill=kill)

    # Stop video recording
    keyCombo("<Control><Alt>s")

    line = context.recordvideo_stdout.readline()
    while line:
        if line == 'Goodbye!\r\n':
            break
        print(line)
        line = context.recordvideo_stdout.readline()

    if hasattr(context, "embed"):
        # Attach video in the report
        try:
            context.embed('video/webm',
                          open("/tmp/screencast.ogv", 'r').read(),
                          caption="Video")
        except Exception as e:
            print("Failed to attach the video to the report: %s" % str(e))
Beispiel #55
0
def select_file_in_dialog(context, name):
    # Find an appropriate button to click
    # It will be either 'Home' or 'File System'

    home_folder = context.app.dialog.findChild(GenericPredicate(name=translate('Home')),
                                               retry=False,
                                               requireResult=False)
    if home_folder:
        home_folder.click()
    else:
        context.app.dialog.childNamed(translate('File System')).click()
    location_button = context.app.dialog.child(translate('Enter Location'))
    if not pyatspi.STATE_SELECTED in location_button.getState().getStates():
        location_button.click()

    location_text = context.app.dialog.child(roleName='text')
    location_text.set_text_contents(name)
    sleep(0.2)
    location_text.grab_focus()
    keyCombo('<Enter>')
    assert wait_until(lambda x: x.dead, context.app.dialog), "Dialog was not closed"
Beispiel #56
0
def table_created(context, type_of_records, tbname, dbname):
    button = context.app.get_current_window().findChildren(
        lambda x: x.roleName == 'tree item' and x.text == tbname)[0]
    button.doubleClick()

    if button.showing:
        button.doubleClick()

    w = context.app.get_current_window()
    table = w.findChildren(
        lambda x: x.roleName == 'table' and x.name == 'Table' and x.showing)[0]
    i = 1

    tab_rec = []
    if type_of_records == "non-english":
        tab_rec = TABLE_RECORDS_NON_ENGLISH
    if type_of_records == "english":
        tab_rec = TABLE_RECORDS

    for record in tab_rec:

        assert table[i].text == record['id'],\
            "Incorrect text in column " + "id" + " and row " + str(i) + ", expected '%s' but was '%s'" % (
            record['id'], table[i].text)
        assert table[i + 1].text == record['name'],\
            "Incorrect text in column " + "name" + " and row " + str(i) + ", expected '%s' but was '%s'" % (
            record['name'], table[i + 1].text)
        assert table[i + 2].text == record['address'],\
            "Incorrect text in column " + "address" + " and row " + str(i) + ", expected '%s' but was '%s'" % (
            record['address'], table[i + 2].text)
        # there is commented assert for last column in table because thrue the accessibility its imposible to reach it
        # assert table[i+3].text == record['phone'], "Incorrect text in paragraph,\
        #  expected '%s' but was '%s'" % (record['phone'], table[i+3].text)
        i += len(record)

    j = 1
    for record in tab_rec:
        table[j].grabFocus()
        for i in range(0, len(tab_rec[0]) - 1):
            pressKey('\t')
        keyCombo('<Control>c')
        table[j + 1].grabFocus()
        keyCombo('<Control>a')
        keyCombo('<Control>v')
        keyCombo('<Enter>')
        assert table[j + 1].text == record[
            'phone'], "Incorrect text in paragraph, expected '%s' but was '%s'" % (
                record['phone'], table[j + 1].text)

        j += len(tab_rec[0])
Beispiel #57
0
 def test_02_properties(self):
     self._mainmenu("Edit Properties")
     dialog = self._app().child(roleName="dialog")
     creatorlab = dialog.child(roleName="table cell", name="Creator")
     creatorid = creatorlab.parent.children.index(creatorlab) + 1
     creatorval = creatorlab.parent.children[creatorid]
     creatorval.keyCombo("enter")
     from dogtail import rawinput
     rawinput.typeText('["Frodo", "Sam"]')
     dialog.child(name="OK").click()
     self._mainmenu("Edit Properties")
     dialog = self._app().child(roleName="dialog")
     rawinput.keyCombo("enter")
     rawinput.typeText('Memories')
     rawinput.keyCombo("enter")
     # FIXME: depending on where the test is ran the previous enter close
     # the dialog or do not close it.
     try:
         dialog.child(name="OK").click()
     except Exception:
         print("'Edit Properties dialog' closed by 'enter'.")
     self._wait_cond(lambda: dialog.dead)
Beispiel #58
0
    def kill(self):
        """
        Kill the app via 'killall'
        """
        try:
            # first try to quit graciously
            GnomeShell().clickApplicationMenuItem(
                self.getName(self.parseDesktopFile()), "Quit")
            assert wait_until(lambda x: not x.isRunning(), self, timeout=30)
        except (AssertionError, SearchError):
            try:
                # okay, didn't work. Kill by pid
                self.process.kill()
                assert wait_until(lambda x: not x.isRunning(),
                                  self,
                                  timeout=30)
            except:  # pylint: disable=bare-except
                # send SIGKILL if sigterm didn't work
                Popen("killall -9 " + self.appCommand + " > /dev/null",
                      shell=True).wait()
        self.pid = None

        if self.recordVideo:
            keyCombo('<Control><Alt><Shift>R')
            if self.recordVideoName is not None:
                # Rename the last screencast according to the template in
                # self.recordVideoName
                scrcast_list = sorted(
                    glob.glob(
                        os.path.join(os.path.expanduser('~/Videos'),
                                     'Screencast*')))
                last_scrcast = scrcast_list[-1]
                curtime = datetime.datetime.now().strftime('%Y-%m-%dT%H-%M-%S')
                os.rename(
                    last_scrcast,
                    os.path.expanduser('~/Videos/%s_%s.webm' %
                                       (self.recordVideoName, curtime)))
Beispiel #59
0
def select_contact_with_name(context, contact_name):
    # heading shows the name of currently selected contact
    # We have to keep on pressing Tab to select the next contact
    # Until we meet the first contact
    # WARNING - what if we will have two identical contacts?
    fail = False
    selected_contact = None

    # HACK
    # To make the contact table appear
    # we need to focus on search window
    # and send Tabs to have the first contact focused
    context.app.search_bar.grab_focus()
    sleep(0.1)
    # Switch to 'Any field contains' (not reachable in 3.6)
    icons = context.app.search_bar.findChildren(GenericPredicate(roleName='icon'))

    if icons != []:
        icons[0].click()
        wait_until(lambda x: x.findChildren(
            GenericPredicate(roleName='check menu item', name='Any field contains')) != [],
            context.app)
        context.app.menuItem('Any field contains').click()
        for attempts in range(0, 10):
            try:
                context.app.search_bar.text = contact_name
                break
            except (GLib.GError, AttributeError):
                sleep(0.1)
                continue
        keyCombo("<Enter>")
        context.app.search_bar.grab_focus()

    keyCombo("<Tab>")
    first_contact_name = context.app.child(roleName='heading').text

    while True:
        selected_contact = context.app.child(roleName='heading')
        if selected_contact.text == contact_name:
            fail = False
            break
        keyCombo("<Tab>")
        # Wait until contact data is being rendered
        sleep(1)
        if first_contact_name == selected_contact.text:
            fail = True
            break

    context.assertion.assertFalse(
        fail, "Can't find contact named '%s'" % contact_name)
    context.selected_contact_text = selected_contact.text
Beispiel #60
0
def delete_all_contacts_containing(context, part):
    context.app.search_bar.grab_focus()
    for attempts in range(0, 10):
        try:
            context.app.search_bar.text = part
            break
        except (GLib.GError, AttributeError):
            sleep(0.1)
            continue
    keyCombo("<Enter>")
    context.execute_steps(u"* Wait for email to synchronize")
    context.app.search_bar.grab_focus()
    keyCombo("<Tab>")
    sleep(3)
    heading = context.app.findChild(
        GenericPredicate(roleName='heading'),
        retry=False, requireResult=False)
    if heading:
        keyCombo("<Control>a")
        context.execute_steps(u"* Delete selected contact")
        sleep(3)