Ejemplo n.º 1
0
def run_ui_typing_helper(cache, text):
    if os.path.isfile(cache):
        os.remove(cache)

    pid = run('gedit {}'.format(cache))
    gedit = tree.root.application('gedit')

    focus.application('gedit')
    focus.text()
    typeText(text)

    keyCombo('<Control>s')

    try:
        # @NOTE: maybe we can't access the menu and click the
        # item `Quit` at menu `File`

        click.menu('File')
        click.menuItem('Quit')
    except Exception as error:
        keyCombo('<Control>q')

    try:
        with open(cache) as fd:
            return fd.read()
    except Exception as error:
        os.kill(pid, signal.SIGKILL)
        return None
Ejemplo n.º 2
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"

        app_name = self.getName(desktopConfig)
        typeText(app_name)
        sleep(1)
        icons = gnomeShell.findChildren(
            GenericPredicate(roleName='label', name=app_name))
        visible_icons = [x for x in icons if x.showing]
        assert wait_until(lambda x: len(x) > 0, visible_icons), \
            "Can't find gnome shell icon for '%s'" % app_name
        visible_icons[0].click()

        assert wait_until(lambda x: x.isRunning(), self, timeout=30),\
            "Application failed to start"
Ejemplo n.º 3
0
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)
Ejemplo n.º 4
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"
Ejemplo n.º 5
0
def add_snapshot(context, name):
    wait = 0
    while len(context.app.findChildren(lambda x: x.roleName == 'push button' and x.showing and not x.name)) == 0:
        sleep(0.25)
        wait += 1
        if wait == 20:
            raise Exception("Timeout: Node %s wasn't found showing" %name)

    context.app.findChildren(lambda x: x.roleName == 'push button' and x.showing and not x.name)[0].click()

    wait = 0
    while len(context.app.findChildren(lambda x: x.roleName == 'toggle button' and x.showing \
                                                                            and x.sensitive and x.name == 'Menu')) == 0:
        sleep(0.25)
        wait += 1
        if wait == 80:
            raise Exception("Timeout: Node %s wasn't found showing" %name)

    sleep(1)
    context.app.findChildren(lambda x: x.roleName == 'toggle button' and x.showing \
                                                                     and x.sensitive and x.name == 'Menu')[-1].click()

    renames = context.app.findChildren(lambda x: x.name == 'Rename' and x.showing)
    if not renames:
        context.app.findChildren(lambda x: x.roleName == 'toggle button' and x.showing and x.sensitive \
                                                                                      and x.name == 'Menu')[-1].click()
        renames = context.app.findChildren(lambda x: x.name == 'Rename' and x.showing)
    renames[0].click()
    sleep(0.5)
    typeText(name)
    context.app.findChildren(lambda x: x.showing and x.name == 'Done')[0].click()
Ejemplo n.º 6
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"

        app_name = self.getName(desktopConfig)
        typeText(app_name)
        sleep(1)
        icons = gnomeShell.findChildren(GenericPredicate(roleName='label',
                                                         name=app_name))
        visible_icons = [x for x in icons if x.showing]
        assert wait_until(lambda x: len(x) > 0, visible_icons), \
            "Can't find gnome shell icon for '%s'" % app_name
        visible_icons[0].click()

        assert wait_until(lambda x: x.isRunning(), self, timeout=30),\
            "Application failed to start"
Ejemplo n.º 7
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>')
Ejemplo n.º 8
0
def type_search_and_check_option_in_find_dialog(context, search_string):
    context.dialog = context.app.get_current_window()
    search_for_panel = context.dialog.child(roleName='panel', name='Search For')
    search_for_panel.child(roleName='combo box').click()
    typeText(search_string)
    context.dialog.child(roleName='check box', name='Other options').click()
    context.dialog.child(roleName='check box', name='Search in all sheets').click()
    search_for_panel.child(roleName='push button', name='Find All').click()
Ejemplo n.º 9
0
def create_a_folder_random_name(context, name=None):
    # Open folder menu
    context.app.instance.child("Content View").click(button=3)
    context.app.instance.child(roleName='window').menuItem('New Folder').click()
    if name:
        typeText(name)
    keyCombo("<Enter>")
    sleep(0.1)
Ejemplo n.º 10
0
def install_tc_linux_package(context, pkg, time):
    if "/" in pkg:
        call("xdotool type --delay 150 'wget %s\n'" %pkg, shell=True)
        call("xdotool type --delay 150 'tce-load -i %s\n'" %pkg.split('/')[-1], shell=True)
    else:
        typeText('tce-load -wi %s\n' %pkg)

    sleep(int(time))
Ejemplo n.º 11
0
def insert_example_data(context, component):
    if component in ['Writer', 'Calc']:
        typeText('Example text')
        pressKey('Enter')
    elif component == 'Impress':
        context.execute_steps(u'''* Set current slide title to "Example"''')
    elif component == 'Draw':
        context.execute_steps(u'''* Select "Insert -> Fields -> File Name" menu''')
Ejemplo n.º 12
0
def insert_example_data(context, component):
    if component in ['Writer', 'Calc']:
        typeText('Example text')
        pressKey('Enter')
    elif component == 'Impress':
        context.execute_steps(u'''* Set current slide title to "Example"''')
    elif component == 'Draw':
        context.execute_steps(u'''* Select "Insert -> Fields -> File Name" menu''')
Ejemplo n.º 13
0
def type_search_and_check_option_in_find_dialog(context, search_string):
    context.dialog = context.app.get_current_window()
    search_for_panel = context.dialog.child(roleName='panel', name='Search For')
    search_for_panel.child(roleName='combo box').click()
    typeText(search_string)
    context.dialog.child(roleName='check box', name='Other options').click()
    context.dialog.child(roleName='check box', name='Search in all sheets').click()
    search_for_panel.child(roleName='push button', name='Find All').click()
Ejemplo n.º 14
0
 def test_typeText(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')
     typeText('something')
     self.assertEqual(textfield.text, 'something')
Ejemplo n.º 15
0
 def _scale_selected(self, scale):
     app = self._app()
     app.keyCombo("C")
     dialog = app.child(roleName="dialog")
     from dogtail import rawinput
     rawinput.keyCombo("Tab")
     rawinput.typeText(str(scale))
     dialog.child(name="OK").click()
     self._wait_cond(lambda: dialog.dead)
Ejemplo n.º 16
0
 def test_typeText(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')
     typeText('something')
     self.assertEqual(textfield.text, 'something')
Ejemplo n.º 17
0
def install_tc_linux_package(context, pkg, time):
    if "/" in pkg:
        call("xdotool type --delay 150 'wget %s\n'" % pkg, shell=True)
        call("xdotool type --delay 150 'tce-load -i %s\n'" %
             pkg.split('/')[-1],
             shell=True)
    else:
        typeText('tce-load -wi %s\n' % pkg)

    sleep(int(time))
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)
Ejemplo n.º 19
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)
Ejemplo n.º 20
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
Ejemplo n.º 21
0
def startViaKRunner(context, app):
    """ Simulates running app through Run command interface (alt-F2...)"""
    os.system('krunner')
    assert wait_until(lambda x: x.application('krunner'), root),\
        "KRunner didn't start"
    typeText(context.app.appCommand)
    sleep(1)
    pressKey('enter')
    assert wait_until(lambda x: isKDEAppRunning(x), context.app, timeout=30),\
        "Application failed to start"
    context.app.instance = root.application(context.app.a11yAppName)
Ejemplo n.º 22
0
def startViaKRunner(context, app):
    """ Simulates running app through Run command interface (alt-F2...)"""
    os.system('krunner')
    assert wait_until(lambda x: x.application('krunner'), root),\
        "KRunner didn't start"
    typeText(context.app.appCommand)
    sleep(1)
    pressKey('enter')
    assert wait_until(lambda x: isKDEAppRunning(x), context.app, timeout=30),\
        "Application failed to start"
    context.app.instance = root.application(context.app.a11yAppName)
Ejemplo n.º 23
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)
Ejemplo n.º 24
0
def insert_text_to_slide(context, number_of_slide, text):

    current_window = context.app.get_current_window()
    # choose right slide
    current_window.child(name='Slides View', roleName='document frame')[int(number_of_slide)-1].click()
    
    
    # find paragraph to write and write
    frame = context.app.get_current_window().findChildren(lambda x: x.roleName == 'document presentation')[0]
    frame.findChildren(lambda x: x.name == 'Paragraph 0')[0].click()
    
    typeText(text)
Ejemplo n.º 25
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)
Ejemplo n.º 26
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)
Ejemplo n.º 27
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()
Ejemplo n.º 28
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()
Ejemplo n.º 29
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)
Ejemplo n.º 30
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)
Ejemplo n.º 31
0
def add_windows_live_account(context, user, password):
    dialog = context.app.instance.dialog('Windows Live account')

    # Input credentials
#    assert wait_until(
#        lambda x: x.findChildren(
    #        GenericPredicate(roleName='entry')) != [], dialog,
    #    timeout=90), "Windows Live auth window didn't appear"
    entry = dialog.child(roleName='entry', description="Email or phone")
    if entry.text != user:
        entry.click()
        typeText(user)
        pressKey('Tab')
        typeText(password)
    doDelay(2)

    dialog.button('Sign in').click()
    doDelay(5)

    # Wait for GNOME icon to appear
    third_party_icon_pred = GenericPredicate(roleName='document web',
                                             name='Let this app access your info?')
    for attempts in range(0, 10):  # pylint: disable=W0612
        if dialog.findChild(third_party_icon_pred,
                            retry=False,
                            requireResult=False) is not None:
            break
        else:
            doDelay(2)

    doDelay(1)
    allow_button = dialog.child("Yes", 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(1)
    allow_button.click()
    assert wait_until(lambda x: x.dead, dialog), \
        "Dialog was not closed"
Ejemplo n.º 32
0
def add_windows_live_account(context, user, password):
    dialog = context.app.instance.dialog('Windows Live account')

    # Input credentials
    #    assert wait_until(
    #        lambda x: x.findChildren(
    #        GenericPredicate(roleName='entry')) != [], dialog,
    #    timeout=90), "Windows Live auth window didn't appear"
    entry = dialog.child(roleName='entry', description="Email or phone")
    if entry.text != user:
        entry.click()
        typeText(user)
        pressKey('Tab')
        typeText(password)
    doDelay(2)

    dialog.button('Sign in').click()
    doDelay(5)

    # Wait for GNOME icon to appear
    third_party_icon_pred = GenericPredicate(
        roleName='document web', name='Let this app access your info?')
    for attempts in range(0, 10):  # pylint: disable=W0612
        if dialog.findChild(third_party_icon_pred,
                            retry=False,
                            requireResult=False) is not None:
            break
        else:
            doDelay(2)

    doDelay(1)
    allow_button = dialog.child("Yes", 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(1)
    allow_button.click()
    assert wait_until(lambda x: x.dead, dialog), \
        "Dialog was not closed"
Ejemplo n.º 33
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"
Ejemplo n.º 34
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)
Ejemplo n.º 35
0
def insert_values_and_create_sum(context):
    context.frame = context.app.get_current_window().child(roleName='document spreadsheet')
    context.frame.child(roleName='table')[0].grabFocus()
    for value in VALUES:
        typeText(value)
        pressKey('enter')
    context.sum_string = '='
    for i in range(1, len(VALUES) + 1):
        if i == len(VALUES):
            context.sum_string = context.sum_string + 'A' + str(i)
        else:
            context.sum_string = context.sum_string + 'A' + str(i) + '+'

    typeText(context.sum_string)
    pressKey('enter')
Ejemplo n.º 36
0
def insert_values_and_create_sum(context):
    context.frame = context.app.get_current_window().child(roleName='document spreadsheet')
    context.frame.child(roleName='table')[0].grabFocus()
    for value in VALUES:
        typeText(value)
        pressKey('enter')
    context.sum_string = '='
    for i in range(1, len(VALUES) + 1):
        if i == len(VALUES):
            context.sum_string = context.sum_string + 'A' + str(i)
        else:
            context.sum_string = context.sum_string + 'A' + str(i) + '+'

    typeText(context.sum_string)
    pressKey('enter')
Ejemplo n.º 37
0
def set_field_to_value_in_message_composer(context, field, value):
    if field in ['To:', 'Cc:', 'Bcc:']:
        #TODO Check that the field is displayed
        context.app.composer.child(field).typeText(value)
        context.app.composer.child(field).text = value
        keyCombo("<Enter>")
        sleep(0.1)

    if field == 'Subject:':
        context.app.composer.childLabelled(field).text = value
        context.app.composer = context.app.instance.window(value)

    if field == 'Text:':
        keyCombo('<Alt>r')
        typeText(value)
 def startViaKRunner(self):
     """ Simulates running app through Run command interface (alt-F2...)"""
     try:
         sleep(self.splashscreen_delay) #
         os.system('krunner')
         sleep(1.5)
         typeText('%s' % self.command)
         sleep(2)
         pressKey('enter')
         sleep(5)
     except:
         printException()
         return False
     self.__PID = self.getHighestPid()
     return self.checkRunning('Running %s via menu Run Command Interface' % self.appname)
Ejemplo n.º 39
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()
Ejemplo n.º 40
0
def add_value_to_cell(context, operation, cell1, cell2, cell_result):
    # reuse of array so has to be empty!

    context.frame = context.app.get_current_window().child(roleName='document spreadsheet')
    try:
        string_to_add = cell1.split(" ")[1] + " " + operation + " " + cell2.split(" ")[1]

        cell = context.frame.child(roleName='table')[CELL_TRANSLATION[cell_result]]
        cell.grabFocus()

        tool_bar = context.frame.parent.parent[2]
        tool_bar.findChildren(lambda x: x.roleName == 'push button')[2].click()
        typeText(string_to_add)
        tool_bar.findChildren(lambda x: x.roleName == 'push button')[2].click()
    except KeyError:
        assert False, "%s is not supported character for this test!" % cell_result
Ejemplo n.º 41
0
def add_value_to_cell(context, operation, cell1, cell2, cell_result):
    # reuse of array so has to be empty!

    context.frame = context.app.get_current_window().child(roleName='document spreadsheet')
    try:
        string_to_add = cell1.split(" ")[1] + " " + operation + " " + cell2.split(" ")[1]
        
        cell = context.frame.child(roleName='table')[CELL_TRANSLATION[cell_result]]
        cell.grabFocus()
        
        tool_bar = context.frame.parent.parent[2]
        tool_bar.findChildren(lambda x: x.roleName == 'push button')[2].click()
        typeText(string_to_add)
        tool_bar.findChildren(lambda x: x.roleName == 'push button')[2].click()
    except KeyError:
        assert False, "%s is not supported character for this test!" % cell_result
Ejemplo n.º 42
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"
 def startViaMenu(self):
     """ Will run the app through the standard application launcher """
     try:
         sleep(self.splashscreen_delay) # time before kwin starts up and the splash screen disappears
         height = Gdk.Display.get_default().get_default_screen().get_root_window().get_height()
         click(self.corner_distance,height - self.corner_distance)
         plasma = root.application('plasma-desktop')
         plasma.child(name='Search:', roleName='label').click()
         typeText(self.command)
         sleep(1)
         pressKey('enter')
         sleep(5)
     except:
         printException()
         return False
     self.__PID = self.getHighestPid()
     return self.checkRunning('Running %s via menu search' % self.appname)
    def startViaCommand(self):
        """
        Start the app via command
        """
        internCritical = (self.critical == 'start')
        if self.forceKill and self.isRunning():
            self.kill()
            time.sleep(2)
            if self.isRunning():
                if internCritical:
                    self.updateResult(False)
                print("!!! The app is running but it shouldn't be")
                return False
            else:
                print("*** The app has been killed succesfully")

        returnValue = 0
        command = "%s %s" % (self.appCommand, self.parameters)
        returnValue = utilsRun(command, timeout=10, dumb=True)

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

        time.sleep(self.timeout)

        # 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
Ejemplo n.º 45
0
    def typeText(self, string):
        """
        Type the given text into the node, with appropriate delays and logging.
        """
        logger.log(str("Typing text into %s: '%s'") % (self.getLogString(), str(string)))

        if self.focusable:
            if not self.focused:
                try:
                    self.grabFocus()
                except Exception:
                    logger.log("Node is focusable but I can't grabFocus!")
            rawinput.typeText(string)
        else:
            logger.log("Node is not focusable; falling back to inserting text")
            et = self.queryEditableText()
            et.insertText(self.caretOffset, string, len(string))
            self.caretOffset += len(string)
            doDelay()
Ejemplo n.º 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")
     # 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)
Ejemplo n.º 47
0
def presentation_from_template(context, presentation_title):
    current_window = context.app.get_current_window()

    # step one
    template_rb = current_window.child(name='From template', roleName='radio button')
    template_rb.click()
    # workaround for the radio button not being checked:
    if not template_rb.checked:
        pressKey('Tab')
        pressKey('Tab')
        pressKey('Down')

    current_window.button('Next').click()

    # step two and three
    current_window.button('Next').click()
    current_window.button('Next').click()

    # step four
    current_window.childLabelled('What is the subject of your presentation?').click()
    typeText(presentation_title)
    current_window.button('Create').click()
    def startViaMenu(self, throughCategories = False):
        self.parseDesktopFile()
        if self.forceKill and self.isRunning():
            self.kill()
            sleep(2)
            assert not self.isRunning(), "Application cannot be stopped"
        try:
            gnomeShell = root.application('gnome-shell')
            pressKey('Super_L')
            sleep(6)
            if throughCategories:
                # menu Applications
                x, y = getDashIconPosition('Show Applications')
                absoluteMotion(x, y)
                time.sleep(1)
                click(x, y)
                time.sleep(4) # time for all the oversized app icons to appear

                # submenu that contains the app
                submenu = gnomeShell.child(
                    name=self.getMenuGroups(), roleName='list item')
                submenu.click()
                time.sleep(4)

                # the app itself
                app = gnomeShell.child(
                    name=self.getName(), roleName='label')
                app.click()
            else:
                typeText(self.getName())
                sleep(2)
                pressKey('Enter')

            assert self.isRunning(), "Application failed to start"
        except SearchError:
            print("!!! Lookup error while passing the path")
        
        return root.application(self.a11yAppName)
Ejemplo n.º 49
0
def add_text_to_sheet_in_spreadsheet_to_cell(context, text_to_add, cell_name, sheet_name):
    # click on right sheet
    page_tab_list = context.app.get_current_window().child(roleName='document spreadsheet').parent[-1].child(
        roleName='page tab list')
    try:
        sheet = page_tab_list.child(name=sheet_name)
        sheet.click()
    except KeyError:
        assert False, "Sheet with name %s is missing" % sheet_name
    # find right cell
    context.frame = context.app.get_current_window().child(roleName='document spreadsheet')
    try:
        cell = context.frame.child(roleName='table')[CELL_TRANSLATION[cell_name]]
        cell.grabFocus()
        # type text
        typeText(text_to_add)
        pressKey("enter")

        DATA.append(sheet_name)
        DATA.append(-1)
        DATA.append(text_to_add)
    except KeyError:
        assert False, "Missing implementation for cell name %s " % cell_name
Ejemplo n.º 50
0
def make_sheet_protected(context):
    select_menuitem(context, "Tools -> Protect Document -> Sheet...")
    dialog_frame_window_is_displayed(context, "Protect Sheet")

    dialog = context.app.get_current_window()
    # fill password
    text_fields = dialog.findChildren(lambda x: x.roleName == 'password text')
    text_fields[0].grabFocus()
    typeText("red hat")
    text_fields[1].grabFocus()
    typeText("red hat")

    selector1 = dialog.child(roleName='check box', name='Select protected cells')
    selector2 = dialog.child(roleName='check box', name='Select unprotected cells')

    if not selector2.checked:
        selector1.doAction('click')
    if not selector2.checked:
        selector1.doAction('click')

    # confirm
    dialog.child(name='OK').click()
    dialog_frame_window_is_displayed(context, "Untitled 1 - LibreOffice Calc")
Ejemplo n.º 51
0
def make_sheet_protected(context):
    select_menuitem(context, "Tools -> Protect Document -> Sheet...")
    dialog_frame_window_is_displayed(context, "Protect Sheet")

    dialog = context.app.get_current_window()
    # fill password
    text_fields = dialog.findChildren(lambda x: x.roleName == 'password text')
    text_fields[0].grabFocus()
    typeText("red hat")
    text_fields[1].grabFocus()
    typeText("red hat")

    selector1 = dialog.child(roleName='check box', name='Select protected cells')
    selector2 = dialog.child(roleName='check box', name='Select unprotected cells')

    if not selector2.checked:
        selector1.doAction('click')
    if not selector2.checked:
        selector1.doAction('click')
    
    # confirm
    dialog.child(name='OK').click()
    dialog_frame_window_is_displayed(context, "Untitled 1 - LibreOffice Calc")
    def startViaMenu(self, throughCategories=False):
        self.parseDesktopFile()
        if self.forceKill and self.isRunning():
            self.kill()
            sleep(2)
            assert not self.isRunning(), "Application cannot be stopped"
        try:
            gnomeShell = root.application('gnome-shell')
            pressKey('Super_L')
            sleep(6)
            if throughCategories:
                # menu Applications
                x, y = getDashIconPosition('Show Applications')
                absoluteMotion(x, y)
                time.sleep(1)
                click(x, y)
                time.sleep(4)  # time for all the oversized app icons to appear

                # submenu that contains the app
                submenu = gnomeShell.child(name=self.getMenuGroups(),
                                           roleName='list item')
                submenu.click()
                time.sleep(4)

                # the app itself
                app = gnomeShell.child(name=self.getName(), roleName='label')
                app.click()
            else:
                typeText(self.getName())
                sleep(2)
                pressKey('Enter')

            assert self.isRunning(), "Application failed to start"
        except SearchError:
            print("!!! Lookup error while passing the path")

        return root.application(self.a11yAppName)
Ejemplo n.º 53
0
def add_snapshot(context, name):
    wait = 0
    while len(
            context.app.findChildren(lambda x: x.roleName == 'push button' and
                                     x.showing and not x.name)) == 0:
        sleep(0.25)
        wait += 1
        if wait == 20:
            raise Exception("Timeout: Node %s wasn't found showing" % name)

    context.app.findChildren(lambda x: x.roleName == 'push button' and x.
                             showing and not x.name)[0].click()

    wait = 0
    while len(context.app.findChildren(lambda x: x.roleName == 'toggle button' and x.showing \
                                                                            and x.sensitive and x.name == 'Menu')) == 0:
        sleep(0.25)
        wait += 1
        if wait == 80:
            raise Exception("Timeout: Node %s wasn't found showing" % name)

    sleep(1)
    context.app.findChildren(lambda x: x.roleName == 'toggle button' and x.showing \
                                                                     and x.sensitive and x.name == 'Menu')[-1].click()

    renames = context.app.findChildren(
        lambda x: x.name == 'Rename' and x.showing)
    if not renames:
        context.app.findChildren(lambda x: x.roleName == 'toggle button' and x.showing and x.sensitive \
                                                                                      and x.name == 'Menu')[-1].click()
        renames = context.app.findChildren(
            lambda x: x.name == 'Rename' and x.showing)
    renames[0].click()
    sleep(0.5)
    typeText(name)
    context.app.findChildren(
        lambda x: x.showing and x.name == 'Done')[0].click()
Ejemplo n.º 54
0
def create_new_vm_via_url(context, url):
    context.app.child('New').click()
    context.app.child('Continue').click()
    context.app.child('Enter URL').click()

    typeText(url)
    context.app.child('Continue').click()

    if url.find('http') != -1:
        half_minutes = 0
        while half_minutes < 120:
            half_minutes += 1
            if context.app.findChild(GenericPredicate(
                    name='Choose express install to automatically '
                    'preconfigure the box with optimal settings.'),
                                     retry=False,
                                     requireResult=False):
                return
            create = context.app.child('Create')
            if create.sensitive and create.showing:
                create.click()
                break
            else:
                sleep(30)
Ejemplo n.º 55
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')
Ejemplo n.º 56
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')