def test_run(self): case_name = self.__class__.__name__ logger.info("========== Begin of Running Test Case %s ==========" % self.__class__.__name__) try: try: username = RHSMConstants().get_constant("username") password = RHSMConstants().get_constant("password") if not (self.check_window_exist_fast("main-window")): self.open_subscription_manager() self.register_in_gui(username, password) self.click_all_available_subscriptions_tab() self.click_filters_button() # input garbage in the filter box self.input_text("filter-options-window", "filter-subscriptions-text", "asfsadfasdfasdf") self.click_filter_close_button() self.click_update_button() ldtp.wait() os.execv(__file__, sys.argv) # check if the no subscriptions label is there # THE OBJECT LIST PRINTED HERE IS BUGGY AND WILL NOT REFRESH UNTIL PYTHON IS RESTARTED! # Therefore, we will need to do the check AFTER restarting python, which the following code will handle else: if not (self.check_object_exist("main-window", "nosubscriptions-in-filter-label")): raise FailException("FAILED: Can't find No-subscriptions-label!") except Exception, e: logger.error("Test Failed - ERROR Message:" + str(e)) self.assert_(False, case_name) finally: self.capture_image(case_name) self.restore_gui_environment() logger.info("========== End of Running Test Case: %s ==========" % case_name)
def test_run(self): case_name = self.__class__.__name__ logger.info("========== Begin of Running Test Case %s ==========" % self.__class__.__name__) try: try: username = RHSMConstants().get_constant("username") password = RHSMConstants().get_constant("password") if not(self.check_window_exist_fast('main-window')): self.open_subscription_manager() self.register_in_gui(username, password) self.click_all_available_subscriptions_tab() self.click_filters_button() #input garbage in the filter box self.input_text('filter-options-window','filter-subscriptions-text','asfsadfasdfasdf') self.click_filter_close_button() self.click_update_button() ldtp.wait() os.execv(__file__, sys.argv) #check if the no subscriptions label is there #THE OBJECT LIST PRINTED HERE IS BUGGY AND WILL NOT REFRESH UNTIL PYTHON IS RESTARTED! #Therefore, we will need to do the check AFTER restarting python, which the following code will handle else: if not(self.check_object_exist('main-window','nosubscriptions-in-filter-label')): raise FailException("FAILED: Can't find No-subscriptions-label!") except Exception, e: logger.error("Test Failed - ERROR Message:" + str(e)) self.assert_(False, case_name) finally: self.capture_image(case_name) self.restore_gui_environment() logger.info("========== End of Running Test Case: %s ==========" % case_name)
def start_help(self, app_name, help_widget, help_window): """ It will try to launch the application, and then open application content help window after application is invoked help_widget: application help widget, which includes menuitem and pushbutton help_window: application help window name """ ldtp.launchapp(app_name) ldtp.waittillguiexist(self.name) app = ooldtp.context(self.name) mnu = True if app.verifypushbutton(help_widget) == 1 and app.hasstate(help_widget, 'enabled') == 1: mnu = False if mnu == True: app.getchild(help_widget).selectmenuitem() else: app.getchild(help_widget).click() if platform.processor() == 'sparc': ldtp.wait(45) else: ldtp.wait(30) if ldtp.guiexist(help_window) == 0: raise ldtp.LdtpExecutionError, "The help window " + help_window + " can't be invoked, something wrong with the application help."
def save(self, filename): """ It tries to save the current opened buffer to the filename passed as parameter. TODO: It does not manage the overwrite dialog yet. @type filename: string @param filename: The name of the file to save the buffer to. """ Application.save(self, self.MNU_SAVE) ooldtp.context(self.name) ldtp.waittillguiexist(self.SAVE_DLG) save_dialog = ooldtp.context(self.SAVE_DLG) save_dlg_txt_filename = save_dialog.getchild(self.SAVE_DLG_TXT_NAME) ldtp.wait(2) save_dlg_txt_filename.settextvalue(filename) save_dlg_btn_save = save_dialog.getchild(self.SAVE_DLG_BTN_SAVE) save_dlg_btn_save.click() ldtp.waittillguinotexist(self.SAVE_DLG) ldtp.wait(1)
def change_font(self, category): appearance = ooldtp.context(self.name) appearance.getchild(self.PTABLE).selecttab(self.PTAB_FONTS) appearance.getchild(self.FONTS[category]["BTN"]).click() ldtp.wait(2) if (ldtp.guiexist(self.DLG_PICKAFONT)): pickaFont = ooldtp.context(self.DLG_PICKAFONT) pickaFont.getchild(self.TBL_FAMILY).selectrow(self.FONTS[category]["FAMILY"]) pickaFont.getchild(self.TBL_STYLE).selectrow(self.FONTS[category]["STYLE"]) pickaFont.getchild(self.TBL_SIZE).selectrow(self.FONTS[category]["SIZE"]) pickaFont.getchild(self.BTN_OK).click() else: raise ldtp.LdtpExecutionError, "Failed to setup font properties" ldtp.waittillguiexist(self.WINDOW) #To check the change has been made as expected font_prop = appearance.getchild(self.FONTS[category]["BTN"]).getobjectproperty('children').split(' ') for i in range(len(font_prop)): if (font_prop[i].__contains__(self.FONTS[category]["FAMILY"]) and \ font_prop[i].__contains__(self.FONTS[category]["STYLE"].replace(' ',''))) or \ (font_prop[i] == ('lbl' + self.FONTS[category]["FAMILY"] + self.FONTS[category]["STYLE"].replace(' ',''))) or \ (font_prop[i] == ('lbl' + self.FONTS[category]["FAMILY"])) or \ (font_prop[i].__contains__(self.FONTS[category]["FAMILY"])) or \ (font_prop[i].__contains__(self.FONTS[category]["SIZE"])): pass else: raise ldtp.LdtpExecutionError, "Font properties not changed correctly"
def change_view(self, view): """ To verify the processes quantity will change after the process view is changed """ monitor = ooldtp.context(self.WINDOW) monitor.selecttab(self.PTAB, self.PTAB_PROCESSES) """ To get the current checked view menuitem and processes number """ mnu = [self.MNU_ACTIVE, self.MNU_ALL, self.MNU_MY] for i in mnu: if monitor.getchild(i).hasstate('checked'): mnu_before = i tbl_count_bef = monitor.getchild(self.TBL_PROCESSES).getrowcount() if view == 'Active': mnu_select = self.MNU_ACTIVE elif view == 'All' : mnu_select = self.MNU_ALL elif view == 'My': mnu_select = self.MNU_MY #If the selected menu in test case is as same as the application menu which has checked stats, do nothing if mnu_select == mnu_before: pass else: monitor.getchild(mnu_select).selectmenuitem() ldtp.wait(2) tbl_count_aft = monitor.getchild(self.TBL_PROCESSES).getrowcount() if tbl_count_bef == tbl_count_aft: raise ldtp.LdtpExecutionError, "Processes number didn't change, there's something wrong while selecting " + mnu_select + " menu to change processes view."
def launch_astylewx_ldtp(): """Run the test project astylewx program. """ #print("Launching astylewx ldtp") if os.name == "nt": exepath = (get_astylewx_path() + "/build/" + VS_RELEASE + "_" + WX_RELEASE + "/debug/AStyleWxd_dll.exe") exepath = exepath.replace('/', os.sep) else: exepath = (get_astylewx_path() + "/build/cb-gcc" + "/wx" + WX_RELEASE + "/bin/astylewxd") exeargs = ['--ldtp_test'] try: ldtp.launchapp(exepath, exeargs) except ldtp.client_exception.LdtpExecutionError as err: print("\nError in launchapp: " + exepath) terminate_program(err) if not ldtp.waittillguiexist('*AStyleWx'): terminate_program("\nError in waittillguiexist") ldtp.wait(1) # needed for linux
def change_elements(self, dialog, table): row_count = dialog.getrowcount(table) row = 0 while row < row_count: dialog.getcellvalue(table, row, 1) ldtp.wait(2) row+=1
def change_view(self, view): """ To verify the processes quantity will change after the process view is changed """ monitor = ooldtp.context(self.WINDOW) monitor.selecttab(self.PTAB, self.PTAB_PROCESSES) """ To get the current checked view menuitem and processes number """ mnu = [self.MNU_ACTIVE, self.MNU_ALL, self.MNU_MY] for i in mnu: if monitor.getchild(i).hasstate('checked'): mnu_before = i tbl_count_bef = monitor.getchild(self.TBL_PROCESSES).getrowcount() if view == 'Active': mnu_select = self.MNU_ACTIVE elif view == 'All': mnu_select = self.MNU_ALL elif view == 'My': mnu_select = self.MNU_MY #If the selected menu in test case is as same as the application menu which has checked stats, do nothing if mnu_select == mnu_before: pass else: monitor.getchild(mnu_select).selectmenuitem() ldtp.wait(2) tbl_count_aft = monitor.getchild(self.TBL_PROCESSES).getrowcount() if tbl_count_bef == tbl_count_aft: raise ldtp.LdtpExecutionError, "Processes number didn't change, there's something wrong while selecting " + mnu_select + " menu to change processes view."
def set_file_list(dlg, obj, addObj, removeObj, files): # Clear existing items while (True): try: ldtp.selectrowindex(dlg, obj, 0) ldtp.click(dlg, removeObj) except: break # FIXME compiz and modal windows tend to not work with ldtp set_settings_value('include-list' if obj == 'tblIncludeList' else 'exclude-list', '[%s]' % ', '.join(["'%s'" % os.path.abspath(x) for x in files])) return # Add new items for f in files: ldtp.click(dlg, addObj) waitforgui('dlgChoosefolders') # Make sure path ends in '/' if f[-1] != '/': f += '/' ldtp.selectlastrow('dlgChoosefolders', 'tblPlaces') # must switch away from Recent Files view to get txtLocation ldtp.wait(1) ldtp.settextvalue('dlgChoosefolders', 'txtLocation', f) ldtp.click('dlgChoosefolders', 'btnOpen') ldtp.wait(1) # let dialog close
def revert_font(self): appearance = ooldtp.context(self.name) appearance.getchild(self.PTABLE).selecttab(self.PTAB_FONTS) font_btn = [self.BTN_APPLICATIONFONT, self.BTN_DOCUMENTFONT, self.BTN_DESKTOPFONT, self.BTN_WINDOWTITLEFONT, self.BTN_FIXEDWIDTHFONT] for btn in font_btn: appearance.getchild(btn).click() ldtp.wait() if ldtp.guiexist(self.DLG_PICKAFONT): pickaFont = ooldtp.context(self.DLG_PICKAFONT) if btn == self.BTN_WINDOWTITLEFONT: pickaFont.getchild(self.TBL_FAMILY).selectrow('Sans') pickaFont.getchild(self.TBL_STYLE).selectrow('Bold') elif btn == self.BTN_FIXEDWIDTHFONT: pickaFont.getchild(self.TBL_FAMILY).selectrow('Monospace') pickaFont.getchild(self.TBL_STYLE).selectrow('Regular') else: pickaFont.getchild(self.TBL_FAMILY).selectrow('Sans') pickaFont.getchild(self.TBL_STYLE).selectrow('Regular') pickaFont.getchild(self.TBL_SIZE).selectrow('10') pickaFont.getchild(self.BTN_OK).click() if platform.processor() == 'sparc': ldtp.waittillguiexist(self.WINDOW, 30) else: ldtp.waittillguiexist(self.WINDOW, 10) else: raise ldtp.LdtpExecutionError, "Failed to restore the default font settings"
def walk_restore_prefs(dlg, backend, dest): if backend == 'file': ldtp.comboselect(dlg, 'cboLocation', 'Local Folder') wait_for_combo(dlg, 'cboLocation', 'Local Folder') # this menu acts slowly, because of custom widgets remap(dlg) ldtp.settextvalue(dlg, 'txtFileFolder', dest) ldtp.wait(1) # without this, sometimes ldtp moves so fast, deja-dup doesn't notice dest
def testInstallSimplePackage(self): pkgname = 'package1' pm_str = "%s/usr/bin/packagemanager" % pkg5unittest.g_proto_area self.pkgsend_bulk(self.rurl, self.foo10) self.image_create(self.rurl) ldtp.launchapp(pm_str,["-R", self.get_img_path()]) ldtp.waittillguiexist('Package Manager', state = ldtp.state.ENABLED) ldtp.selectindex('Package Manager', 'Publisher', 0) ldtp.selectrow('Package Manager', 'Packages', pkgname) ldtp.selectmenuitem('Package Manager', 'mnuEdit;mnuSelect All') ldtp.click('Package Manager', 'btnInstall/Update') ldtp.waittillguiexist('dlgInstall Confirmation') ldtp.click('dlgInstall Confirmation', 'btnProceed') while (ldtp.objectexist('dlgInstall/Update', 'btnClose') == 0): ldtp.wait(0.1) ldtp.click('dlgInstall/Update', 'btnClose') ldtp.waittillguinotexist('dlgInstall/Update') # Verify result self.pkg('verify') # Quit packagemanager ldtp.selectmenuitem('Package Manager', 'mnuFile;mnuQuit')
def start_about(self, app_name, about_widget, about_window): """ It will try to open application about window after this application is started. about_widget: application about widget, it might be menu or push button about_window: application about window name """ ldtp.launchapp(app_name) ldtp.waittillguiexist(self.name) mnu = True app = ooldtp.context(self.name) if app.verifypushbutton(about_widget) == 1 and app.hasstate( about_widget, 'enabled') == 1: mnu = False if mnu == True: app.getchild(about_widget).selectmenuitem() else: app.getchild(about_widget).click() ldtp.wait(10) if ldtp.waittillguiexist(about_window) == 0: raise ldtp.LdtpExecutionError, "The " + about_window + " window was not found. "
def wait_for_database_open(): # Wait for the list view to pop up in the main Glom window: # Note that the Window title of the Glom Window changes when the file # has loaded. If we use wildcards for the Window title (*Glom*) here, # then objectexist does not find the notebook_data # (ptlListOrDetailsView) widget, even when it has actually appeared. # TODO: Maybe we can use setcontext(), to avoid this. # TODO: Or maybe this has been fixed in LDTP in the meanwhile, # see bug #583021. while not ldtp.guiexist('Glom-Test') or not ldtp.objectexist( 'Glom-Test', 'ptlListOrDetailsView'): # onwindowcreate calls the callback in a new thread, which # does not really help us since we don't have a mainloop the # callback thread could notify, so we would need to have to # poll an event anyway. Instead, we can simply poll directly # the existance of an error dialog. # Plus, there seems to be a bug in LDTP when running a test # sequence of multiple tests using onwindowcreate: # http://bugzilla.gnome.org/show_bug.cgi?id=586291. if ldtp.guiexist('Warning') or ldtp.guiexist('Error'): # TODO: Read error message from error dialog raise ldtp.LdtpExecutionError('Failed to create new database') # Wait a bit and then try again: ldtp.wait()
def wait_for_object(gui, obj, timeout=5.0, delay=0.5): while (timeout > 0.0): ldtp.wait(delay) if gui.objectexist(obj) and gui.stateenabled(obj): print timeout return True timeout -= delay return False
def chk_enable_a11y(self): """ To check whether the Enable assistive technologies checkbox checked """ at = ooldtp.context(self.WINDOW) if at.getchild(self.CHK_ENABLEASSISTIVETECHNOLOGIES).verifycheck() != 1: raise ldtp.LdtpExecutionError, "Something wrong with the session! Enable assistive technologies checkbox is not checked!" ldtp.wait(1)
def change_picture_to_default(self): about_me = ooldtp.context(self.WINDOW) #set the photo to no image about_me.getchild(self.BTN_0).click() ldtp.wait(2) selectImage = ooldtp.context(self.DLG_SELECTIMAGE) selectImage.getchild(self.BTN_NOIMAGE).click()
def activate_linux_menus(): """Linux must open a menu to call OnMenuOpen() in astylewx to activate or deactivate the submenus. """ if not os.name == "nt": ldtp.selectmenuitem('frmAStyleWx', 'mnuFile') ldtp.keypress('<esc>') ldtp.keyrelease('<esc>') ldtp.wait(1)
def close(self, save=False, filename=''): """ Given a gedit window, it tries to close the application. By default, it closes without saving. This behaviour can be changed to save (or save as) on close. @type save: boolean @param save: If True, the edited file will be saved on close. @type filename: string @param filename: The file name to save the buffer to """ # Exit using the Quit menu gedit = ooldtp.context(self.name) quit_menu = gedit.getchild(self.MNU_QUIT) quit_menu.selectmenuitem() question_dialog = None count = 0 while not gedit.waittillguinotexist(guiTimeOut=1) and \ count < 10: try: question_dialog = ooldtp.context(self.QUESTION_DLG) except: count += 1 else: break # If the text has changed, the save dialog will appear if question_dialog: # Test if the file needs to be saved if save: try: question_dlg_btn_save = question_dialog.getchild(self.QUESTION_DLG_BTN_SAVE) question_dlg_btn_save.click() except ldtp.LdtpExecutionError: # If the Save button was not found, we will try to find the Save As question_dlg_btn_save = question_dialog.getchild(self.QUESTION_DLG_BTN_SAVE_AS) question_dlg_btn_save.click() ldtp.waittillguiexist(self.SAVE_DLG) save_dialog = ooldtp.context(self.SAVE_DLG) save_dlg_txt_filename = save_dialog.getchild(self.SAVE_DLG_TXT_NAME) ldtp.wait(2) save_dlg_txt_filename.settextvalue(filename) save_dlg_btn_save = save_dialog.getchild(self.SAVE_DLG_BTN_SAVE) save_dlg_btn_save.click() ldtp.waittillguinotexist(self.SAVE_DLG) else: question_dlg_btn_close = question_dialog.getchild(self.QUESTION_DLG_BTN_CLOSE) question_dlg_btn_close.click() gedit.waittillguinotexist(guiTimeOut=20)
def chk_enable_a11y(self): """ To check whether the Enable assistive technologies checkbox checked """ at = ooldtp.context(self.WINDOW) if at.getchild( self.CHK_ENABLEASSISTIVETECHNOLOGIES).verifycheck() != 1: raise ldtp.LdtpExecutionError, "Something wrong with the session! Enable assistive technologies checkbox is not checked!" ldtp.wait(1)
def wait_for_quit(): cmd = ['pgrep', '-n', '-x', 'deja-dup'] pid = subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()[0].strip() cmd = ['ps', '-p', pid] while True: sub = subprocess.Popen(cmd, stdout=subprocess.PIPE) if sub.wait() == 0 and sub.communicate()[0].count('defunct') == 0: ldtp.wait(1) else: return
def wait_for_finish(dlg, obj, max_count, prefix=False): count = 0 while count < max_count: if obj is not None and guivisible(dlg, obj, prefix): break elif obj is None and not ldtp.guiexist(dlg): break ldtp.wait(1) count += 1 assert count < max_count, max_count
def chk_keyboard_a11y(self): """ To check the Keyboard Accessibility feature. """ at = ooldtp.context(self.WINDOW) at.getchild(self.BTN_KEYBOARDACCESSIBILITY).click() if ldtp.waittillguiexist(self.DLG_KEYBOARD_PREFERENCES) == 1: ldtp.click(self.DLG_KEYBOARD_PREFERENCES, self.BTN_CLOSE) else: raise ldtp.LdtpExecutionError, "Failed to check Keyboard Accessibility feature" ldtp.wait(1)
def chk_mouse_a11y(self): """ To check the Mouse Accessibility feature. """ at = ooldtp.context(self.WINDOW) at.getchild(self.BTN_MOUSEACCESSIBILITY).click() if ldtp.waittillguiexist(self.DLG_MOUSE_PREFERENCES) == 1: ldtp.click(self.DLG_MOUSE_PREFERENCES, self.BTN_CLOSE) else: raise ldtp.LdtpExecutionError, "Failed to check Mouse Accessibility feature" ldtp.wait(1)
def baobab_scan_filesystem(self): baobab = ooldtp.context(self.name) #Scan the filesystem baobab.getchild(self.MNU_SCANFILESYSTEM).selectmenuitem() buttonStop = baobab.getchild(self.BTN_STOP) while buttonStop.stateenabled(): ldtp.wait(2) #Change the views again to see if that works and we don't get any crash. self.baobab_change_views()
def chk_pref_app(self): """ To check the Preferred Application feature """ at = ooldtp.context(self.WINDOW) at.getchild(self.BTN_PREFERREDAPPLICATIONS).click() if ldtp.waittillguiexist(self.DLG_PREFERRED_APPLICATIONS) == 1: ldtp.click(self.DLG_PREFERRED_APPLICATIONS, self.BTN_CLOSE) else: raise ldtp.LdtpExecutionError, "Failed to check Preferred Applications" ldtp.wait(1)
def test_search_simple(self): """ perform a basic search test """ context = ooldtp.context(self.window_name) context.enterstring(self.availablePaneSearchEntry, "apt") ldtp.wait(1) row_count = context.getrowcount(self.availablePaneAppView) # ensure we get enough hits self.assertTrue(row_count > 10) # ensure apt is the first hit row = 0 column = 0 text = context.getcellvalue(self.availablePaneAppView, row, column) self.assertEqual(text, "\nInstalled\nAdvanced front-end for dpkg")
def baobab_change_views(self): baobab = ooldtp.context(self.name) #Change the graph view. if baobab.guiexist('cboViewasRingsChart'): baobab.comboselect('cboViewasRingsChart', 'mnuViewasTreemapChart') else: baobab.comboselect('cboViewasTreemapChart', 'mnuViewasRingsChart') #Collapse and expand the tree baobab.getchild(self.MNU_EXPANDALL).selectmenuitem() ldtp.wait(2) baobab.getchild(self.MNU_COLLAPSEALL).selectmenuitem()
def close_app(self, app_windowname): """ It tries to close the appliation """ app = ooldtp.context(app_windowname) app.closewindow() ldtp.wait(2) response = ldtp.waittillguinotexist(self.name, '', 100) if response == 0: raise ldtp.LdtpExecutionError, "The " + self.name + " window was not closed."
def open(self): """ Given an application, it tries to open it. """ self._enable_a11y(True) ldtp.launchapp(self.LAUNCHER, args=self.LAUNCHER_ARGS) self._enable_a11y(False) ldtp.wait(2) response = ldtp.waittillguiexist(self.name, '', 20) if response == 0: raise ldtp.LdtpExecutionError, "The " + self.name + " window was not found."
def clean_up_text_values(self, values): about_me = ooldtp.context(self.WINDOW) #clean up all the fields on the for widget, text in values.iteritems(): about_me.settextvalue(widget, '') #there's probably a bug in evolution-data-server or about-me #but if we don't wait to remove another field one of those might not get removed. ldtp.wait(1) ldtp.wait(3) #check that the values were cleaned, otherwise raise an error. for widget, text in values.iteritems(): saved_text = about_me.gettextvalue(widget) if not '' == saved_text: raise AssertionError('the text: %s in widget: %s was not removed' % (saved_text, widget))
def revert_default(self): appearance = ooldtp.context(self.name) appearance.getchild(self.PTABLE).selecttab(self.PTAB_BACKGROUND) appearance.getchild(self.BTN_ADD).click() ldtp.waittillguiexist(self.DLG_ADDWALLPAPER) selectWallpaper = ooldtp.context(self.DLG_ADDWALLPAPER) while selectWallpaper.getchild(self.TBTN).press(): if ldtp.hasstate(self.DLG_ADDWALLPAPER,self.TXT_LOCATION,'SHOWING'): selectWallpaper.settextvalue(self.TXT_LOCATION, self.Default) break selectWallpaper.getchild(self.BTN_OPEN).click() ldtp.wait(2) ldtp.waittillguinotexist(self.DLG_ADDWALLPAPER) ldtp.waittillguiexist(self.WINDOW)
def baobab_scan_home(self): baobab = ooldtp.context(self.name) #Scan the home folder and wait till the end of the scan. baobab.getchild(self.MNU_SCANHOMEFOLDER).selectmenuitem() buttonStop = baobab.getchild(self.BTN_STOP) while buttonStop.stateenabled(): ldtp.wait() self.baobab_change_views() #Scan the home again now this time using the button in the toolbar. baobab.getchild(self.BTN_SCANHOME).click() while buttonStop.stateenabled(): ldtp.wait() self.baobab_change_views()
def _diabled_for_now_test_search_scroll_down_hang(self): context = ooldtp.context(self.window_name) ldtp.wait(2) context.enterstring(self.availablePaneSearchEntry, "a") ldtp.wait(1) row_count = context.getrowcount(self.availablePaneAppView) # ensure we get enough hits self.assertTrue(row_count > 10) ldtp.generatekeyevent("<tab>") # repeating this 100 times will eventually hang s-c, its # currently unclear why for i in range(100): self.generate_page_down() ldtp.wait(1) ldtp.generatekeyevent("<enter>") ldtp.wait(1) ldtp.generatekeyevent("<backspace>") ldtp.wait(1)
def open_app(self, app_launchname): """ Given an application, it tries to open it """ self._enable_a11y(True) try: ldtp.launchapp(app_launchname) except ldtp.LdtpExecutionError: raise ldtp.LdtpExecutionError,"Something went wrong when opening the application" # print "The"+ self.name + "is open" self._enable_a11y(False) ldtp.wait(10) response = ldtp.waittillguiexist(self.name, '', 100) # print app_launchname,"\n" # print ldtp.getwindowlist(),"\n" if response == 0: raise ldtp.LdtpExecutionError, "The " + self.name + " window was not found."
def walk_prefs(backend, dest, includes, excludes): if backend == 'file': ldtp.selecttab('frmBackup', 'ptlCategories', 'Storage') if dest is None: dest = get_temp_name('local') os.system('mkdir -p %s' % dest) elif dest[0] != '/' and dest.find(':') == -1: dest = os.getcwd()+'/'+dest ldtp.comboselect('frmBackup', 'cboLocation', 'Local Folder') wait_for_combo('frmBackup', 'cboLocation', 'Local Folder') # this menu acts slowly, because of custom widgets remap('frmBackup') ldtp.settextvalue('frmBackup', 'txtFileFolder', dest) ldtp.wait(1) # without this, sometimes ldtp moves so fast, deja-dup doesn't notice dest ldtp.selecttab('frmBackup', 'ptlCategories', 'Folders') if includes is not None: set_file_list('frmBackup', 'tblIncludeList', 'btnIncludeListAdd', 'btnIncludeListRemove', includes) if excludes is not None: set_file_list('frmBackup', 'tblExcludeList', 'btnExcludeListAdd', 'btnExcludeListRemove', excludes)
def close_about(self, about_window): """ It tries to close the about window, which is invoked by start_about method. about_window: application about window name """ CLOSE_NAME_1 = "btnClose" CLOSE_NAME_2 = "btnOK" aboutApp = ooldtp.context(about_window) if aboutApp.verifypushbutton(CLOSE_NAME_1) == 1 and aboutApp.hasstate(CLOSE_NAME_1, 'enabled'): CLOSE_WIDGET = CLOSE_NAME_1 elif aboutApp.verifypushbutton(CLOSE_NAME_2) == 1 and aboutApp.hasstate(CLOSE_NAME_2, 'enabled'): CLOSE_WIDGET = CLOSE_NAME_2 else: raise ldtp.LdtpExecutionError, "Can not find enabled Close/OK button in About dialog." aboutApp.getchild(CLOSE_WIDGET).click() ldtp.wait(10) if ldtp.waittillguinotexist(about_window) == 0: raise ldtp.LdtpExecutionError, "The " + about_window + " does not quit as expected, there is something wrong..."
def baobab_scan_folder(self, path): baobab = ooldtp.context(self.name) baobab.getchild(self.BTN_SCANFOLDER).click() ldtp.waittillguiexist(self.DLG_SELECTFOLDER) if (ldtp.guiexist(self.DLG_SELECTFOLDER)): selectFiles = ooldtp.context(self.DLG_SELECTFOLDER) if not (selectFiles.getchild(self.TXT_LOCATION)): ldtp.generatekeyevent('<ctrl>l') textLocation = selectFiles.getchild(self.TXT_LOCATION) textLocation.settextvalue(path) ldtp.generatekeyevent('<return>') ldtp.wait(2) buttonStop = baobab.getchild(self.BTN_STOP) while buttonStop.stateenabled(): ldtp.wait() self.baobab_change_views()
def open_files(self, filename1, filename2, filename3): self.open_file(filename1) ldtp.wait(2) self.open_file(filename2) ldtp.wait(2) self.open_file(filename3) ldtp.wait(10) if ldtp.gettabcount(self.name, 'ptl1') != 3: raise "gedit open multiply file failed."
def close_about(self, about_window): """ It tries to close the about window, which is invoked by start_about method. about_window: application about window name """ CLOSE_NAME_1 = "btnClose" CLOSE_NAME_2 = "btnOK" aboutApp = ooldtp.context(about_window) if aboutApp.verifypushbutton(CLOSE_NAME_1) == 1 and aboutApp.hasstate( CLOSE_NAME_1, 'enabled'): CLOSE_WIDGET = CLOSE_NAME_1 elif aboutApp.verifypushbutton( CLOSE_NAME_2) == 1 and aboutApp.hasstate( CLOSE_NAME_2, 'enabled'): CLOSE_WIDGET = CLOSE_NAME_2 else: raise ldtp.LdtpExecutionError, "Can not find enabled Close/OK button in About dialog." aboutApp.getchild(CLOSE_WIDGET).click() ldtp.wait(10) if ldtp.waittillguinotexist(about_window) == 0: raise ldtp.LdtpExecutionError, "The " + about_window + " does not quit as expected, there is something wrong..."