def setUp(self): try: ldtp.launchapp('gcalctool') ldtp.waittillguiexist('frmCalculator*', guiTimeOut=5) except: self.tearDown() raise
def test_startUI(self): ldtp.launchapp("./netzob") selectWorkspaceFrame = "SelectWorkspace" ldtp.waittillguiexist(selectWorkspaceFrame, guiTimeOut=30) ldtp.click(selectWorkspaceFrame, "btnCancel") ldtp.waittillguinotexist(selectWorkspaceFrame)
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 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 setUp(self): ldtp.launchapp('./software-center') assert ldtp.waittillguiexist('frmUbuntuSoftwareCent*') self.msgs = [] a = "Time taken for the frame to open is " + str( time.time() - start_time) self.msgs.append(a)
def open_subscription_manager(self): logger.info("open_subscription_manager") if int(RHSMGuiLocator().get_os_serials()) == "5": ldtp.launchapp2("subscription-manager-gui") else: ldtp.launchapp("subscription-manager-gui") self.check_window_exist("main-window")
def testRmRepository(self): repo_name = "test2" pm_str = "%s/usr/bin/packagemanager" % pkg5unittest.g_proto_area ldtp.launchapp(pm_str,["-R", self.get_img_path()]) ldtp.waittillguiexist('Package Manager', state = ldtp.state.ENABLED) ldtp.selectmenuitem('Package Manager', 'mnuFile;mnuManage Publishers...') ldtp.waittillguiexist('dlgManage Publishers') ldtp.selectrow('dlgManage Publishers', 'Publishers', repo_name) ldtp.click('dlgManage Publishers', 'btnRemove') ldtp.click('dlgManage Publishers', 'btnOK') ldtp.waittillguiexist('dlgManage Publishers Confirmation') ldtp.click('dlgManage Publishers Confirmation', 'btnOK') ldtp.waittillguinotexist('dlgManage Publishers') # Verify result self.pkg('publisher | grep %s' % repo_name, exit=1) # Quit Package Manager ldtp.selectmenuitem('Package Manager', 'mnuFile;mnuQuit')
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 setUp(self): ldtp.launchapp('./software-center') assert ldtp.waittillguiexist('frmUbuntuSoftwareCent*') self.msgs = [] a = "Time taken for the frame to open is: " + str( time.time() - start_time) + " Cpu percentage: " + str(ldtp.getcpustat('software-center')) + " Memory usage in MB: " + str(ldtp.getmemorystat('software-center')) self.msgs.append(a)
def setUp(self): """docstring for setUp""" self.mv_name = "frmOrd-enLey" self.new_c_button_name = "btnNew" self.delete_c_button_name = "btnDelete" self.tree_name_mv = "tbl0" ldtp.launchapp('python', args=['/home/skar/projects/python/orden-ley/ordenley/tests/run.py']) ldtp.guiexist(self.mv_name)
def testStartPackagemanager(self): 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.selectmenuitem('Package Manager', 'mnuFile;mnuQuit')
def do_screenshot(app, app_name): show("Next up is: {} ({})".format(app_name, app)) l.launchapp(app) l.waittillguiexist(app_name) if video: time.sleep(5) l.imagecapture(app_name, os.path.join(basePath, app + ".png")) full_screen=l.imagecapture() shutil.move(full_screen, os.path.join(basePath, "fullscreen-" + app + ".png")) l.generatekeyevent("<alt><f4>")
def setUp(self): ldtp.launchapp('./software-center') assert ldtp.waittillguiexist('frmUbuntuSoftwareCent*') self.msgs = [] a = "Time taken for the frame to open is: " + str( time.time() - start_time) + " Cpu percentage: " + str( ldtp.getcpustat( 'software-center')) + " Memory usage in MB: " + str( ldtp.getmemorystat('software-center')) self.msgs.append(a)
def start(self, app, blockingTitle=None, args=None): """Starts :app and optionally blocks until window opens :blockingTitle title of window to wait for """ if args is None: args = [] launchapp(app, args) if blockingTitle: waittillguiexist(blockingTitle)
def launch_glom(): # Start glom: ldtp.launchapp('glom') # Wait for the initial dialog to appear. The argument matches on the # Window title, so make sure to set a window title in Glade or in the # code for each window. # Wildcard (* and ?) can be used. if ldtp.waittillguiexist(main_window) == 0: raise ldtp.LdtpExecutionError('The Glom main window did not appear.') if ldtp.waittillguiexist(initial_dialog) == 0: raise ldtp.LdtpExecutionError('The Glom initial dialog did not appear.')
def to_list(self,name): # 查找类似"btn文件"的特殊子窗口,需先关闭软件,不然找不到 ldtp.launchapp('liteword') lst1=ldtp.getwindowlist() ldtp.mouseleftclick(define.special_dlg.get(name),name) lst2=ldtp.getwindowlist() ret=list(set(lst1)^set(lst2)) print 'hehe :',ret if ret: for i in ret: if i.startswith("dlg"): return i
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 launch_glom(): # Start glom: ldtp.launchapp('glom') # Wait for the initial dialog to appear. The argument matches on the # Window title, so make sure to set a window title in Glade or in the # code for each window. # Wildcard (* and ?) can be used. if ldtp.waittillguiexist(main_window) == 0: raise ldtp.LdtpExecutionError('The Glom main window did not appear.') if ldtp.waittillguiexist(initial_dialog) == 0: raise ldtp.LdtpExecutionError( 'The Glom initial dialog did not appear.')
def to_uplist(self,name): # 查找类似"btn下划线"的特殊子窗口,需先关闭软件,不然找不到 ldtp.launchapp('liteword') lst1=ldtp.getwindowlist() ldtp.click(define.special_updlg.get(name),name) ldtp.generatekeyevent('<up>') lst2=ldtp.getwindowlist() ret=list(set(lst1)^set(lst2)) print 'hehe :',ret if ret: for i in ret: if i.startswith("dlg"): return i
def main(): """Main processing function. """ if os.name == "nt": exepath = "C:/Users/jimp/Projects/AStyleWx/build/vs2013_3.0/debug/AStyleWxd.exe" else: exepath = "../../AStyleWx/build/cb-gcc/wx3.0/bin/astylewxd" exepath = exepath.replace('/', os.sep) #print(sys.path[0]) os.chdir(sys.path[0]) if not os.path.exists(exepath): print("Cannot find executable: " + exepath) print("The script has terminated!") sys.exit(1) print("Launching AStyleWx") try: ldtp.launchapp(exepath) except ldtp.client_exception.LdtpExecutionError as err: print("Error in launchapp: " + exepath) print(err) print("The script has terminated!") sys.exit(1) if not ldtp.waittillguiexist('*AStyleWx'): print("Error in waittillguiexist") print("The script has terminated!") sys.exit(1) print('\nFile') print(ldtp.listsubmenus('frmAStyleWx', 'mnuFile')) print('\nEdit') print(ldtp.listsubmenus('frmAStyleWx', 'mnuEdit')) print('\nSearch') print(ldtp.listsubmenus('frmAStyleWx', 'mnuSearch')) print('\nView') print(ldtp.listsubmenus('frmAStyleWx', 'mnuView')) print('\nTools') print(ldtp.listsubmenus('frmAStyleWx', 'mnuTools')) print('\nHelp') print(ldtp.listsubmenus('frmAStyleWx', 'mnuHelp')) print() print("Closing AStyleWx") ldtp.selectmenuitem('frmAStyleWx', 'mnuFile;mnuExit') if not ldtp.waittillguinotexist('*AStyleWx'): print("Error in waittillguinotexist") print("The script has terminated!") sys.exit(1)
def step_impl(context, app, lang): retry = 100 applist = l.getapplist() if lang == "C": context._root['my_lang'] = None my_lang = lang elif lang == "automate": my_lang = os.environ['TRANSLATION_LANG'] m = re.search(r"^(.*?)(_.*)?$", my_lang) if (m): post = m.group(2) or "" my_lang = f"{m.group(1)}automate{post}" context._root['my_lang'] = my_lang else: assert False, f"I can't work with the language {my_lang} please set a good language with the environment variable TRANSLATION_LANG" print(f"now: {my_lang}") print(os.environ['TRANSLATION_LANG']) elif lang == "TRANSLATION_LANG": my_lang = os.environ['TRANSLATION_LANG'] context._root['my_lang'] = my_lang else: context._root['my_lang'] = lang my_lang = lang if app not in applist: if len(applist) == 0 and app_is_in_ps(app): #grrrr why doesn't ldtp find the app!? print(app + " was found by ps") return print(app + " needs to be launched") l.launchapp(app, logfiles=("/tmp/%s-stdout.log" % app, "/tmp/%s-stderr.log" % app), lang=my_lang) while True: retry -= 1 assert retry > 0, "Failed to start " + app applist = l.getapplist() if app in applist: time.sleep(1) print(app + " started") break time.sleep(0.5) else: print(app + " is running already")
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 step_impl(context, app): retry = 100 applist = l.getapplist() if app not in applist: if len(applist) == 0 and app_is_in_ps(app): #grrrr why doesn't ldtp find the app!? print(app + " was found by ps") return print(app + " needs to be launched") l.launchapp(app, logfiles=("/tmp/%s-stdout.log" % app, "/tmp/%s-stderr.log" % app)) while True: retry -= 1 assert(retry > 0)#, "Failed to start " + app) applist = l.getapplist() if app in applist: time.sleep(1) print(app + " started") break time.sleep(0.5) else: print(app + " is running already")
def testPmHelp(self): ldtp.launchapp(self.pm_str,["-R", self.get_img_path()]) ldtp.waittillguiexist('Package Manager', state = ldtp.state.ENABLED) ldtp.selectmenuitem('Package Manager', 'mnuHelp;mnuContents') # Verify result ldtp.waittillguiexist('*Online Help') self.assertEqual(ldtp.guiexist('*Online Help'), 1) ldtp.selectmenuitem('*Online Help', 'mnuCloseWindow') ldtp.selectmenuitem('Package Manager', 'mnuHelp;mnuAbout') # Verify result self.assertEqual(ldtp.guiexist('About Package Manager'), 1) ldtp.waittillguiexist('dlgAboutPackageManager') ldtp.click('dlgAboutPackageManager', 'btnClose') # Quit Package Manager ldtp.selectmenuitem('Package Manager', 'mnuFile;mnuQuit')
def step_impl(context): time.sleep(2) # this is so asynchronous... l.launchapp("xfce4-popup-clipman") time.sleep(1) # this doesn't work every time...? l.launchapp("xfce4-popup-clipman") time.sleep(1) # now we are desperate l.launchapp("xfce4-popup-clipman") time.sleep(2) # he doesn't wait for the popup
def step_impl(context): time.sleep(2) # this is so asynchronous... l.launchapp("xfce4-popup-clipman", logfiles=("/tmp/xfce4-popup-clipman-stdout.log", "/tmp/xfce4-popup-clipman-stderr.log")) time.sleep(1) # this doesn't work every time...? l.launchapp("xfce4-popup-clipman", logfiles=("/tmp/xfce4-popup-clipman-stdout.log", "/tmp/xfce4-popup-clipman-stderr.log")) time.sleep(1) # now we are desperate l.launchapp("xfce4-popup-clipman", logfiles=("/tmp/xfce4-popup-clipman-stdout.log", "/tmp/xfce4-popup-clipman-stderr.log")) time.sleep(2) # he doesn't wait for the popup
def testAddRepository(self): repo_name = "test2" pm_str = "%s/usr/bin/packagemanager" % pkg5unittest.g_proto_area ldtp.launchapp(pm_str,["-R", self.get_img_path()]) ldtp.waittillguiexist('Package Manager', state = ldtp.state.ENABLED) ldtp.selectmenuitem('Package Manager', 'mnuFile;mnuAdd Publisher...') ldtp.waittillguiexist('dlgAdd Publisher') ldtp.settextvalue('dlgAdd Publisher', "txtURI", self.dcs[2].get_depot_url()) ldtp.click('dlgAdd Publisher', 'btnAdd') ldtp.waittillguiexist('dlgAdding Publisher Complete') ldtp.click('dlgAdding Publisher Complete', 'btnClose') # Verify result self.pkg('publisher | grep %s' % repo_name, exit=0) # Quit Package Manager 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. "
import os 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 qt_installer = os.path.abspath(sys.argv[1]) print qt_installer ldtp.launchapp(qt_installer) print ldtp.getwindowlist() frm = ooldtp.context('dlgQtSetup') # MaintenanceTool: 'dlgMaintainQt' ldtp.waittillguiexist( frm._window_name ) # ooldtp BUG: should be able to do frm.waittillguiexist() print frm.getobjectlist() wait_for_object(frm, 'btnNext') frm.click('btnNext') wait_for_object(frm, 'btnSkip') frm.click('btnSkip') wait_for_object(frm, 'btnNext>')
def register_rhn_classic(self, username, password): # open rhn_register gui self.set_os_release() ldtp.launchapp("rhn_register") self.check_window_exist("classic-main-window") if self.check_object_status("classic-main-window", "classic-software-update-label", 'ENABLED'): logger.info("It's successful to open rhn-classic-registeration-gui") else: raise FailException("TestFailed - TestFailed to open rhn-classic-registeration-gui") # click software-update-forward button self.click_button('classic-main-window', 'classic-forward-button') if self.check_object_status("classic-main-window", "classic-choose-service-label", 'ENABLED'): logger.info("It's successful to click softwaref update forward button") else: raise FailException("TestFailed - TestFailed to enable classic-software-update-label") # click choose-service-forward button self.click_button('classic-main-window', 'classic-forward-button') time.sleep(5) if self.check_object_status("classic-main-window", "classic-redhat-account-label", 'ENABLED'): logger.info("It's successful to click choose-service-forward button") else: raise FailException("TestFailed - TestFailed to enable classic-redhat-account-label") # input account info self.input_text("classic-main-window", "classic-login-text", username) logger.info("It's successful to input username") self.input_text("classic-main-window", "classic-password-text", password) logger.info("It's successful to input password") # click redhat-account-forward button self.click_button('classic-main-window', 'classic-forward-button') time.sleep(20) if self.check_object_status("classic-main-window", "classic-OS-realeaseversion-label", 'ENABLED'): logger.info("It's successful to click redhat-account-forward button") else: raise FailException("TestFailed - TestFailed to enable redhat-account-forward-label") # click OS-releaseversion-forward button self.click_button('classic-main-window', 'classic-forward-button') self.check_window_exist("classic-confirm-osrelease-window") if self.check_object_exist("classic-confirm-osrelease-window", "classic-confirm-osrelease-window"): logger.info("It's successful to click OS-releaseversion-forward button") else: raise FailException("TestFailed - TestFailed to prompt classic-confirm-osrelease-window") # click classic-confirm-osrelease-window yes-continue button self.click_button('classic-confirm-osrelease-window', 'classic-confirm-osrelease-yes-button') time.sleep(10) if self.check_object_status("classic-main-window", "classic-create-profile-label", 'ENABLED'): logger.info("It's successful to click classic-confirm-osrelease-window yes-continue button") else: raise FailException("TestFailed - TestFailed to enable classic-confirm-osrelease-window yes-continue button") # set system name self.input_text("classic-main-window", "classic-set-systemname-text", "zhangqq") logger.info("It's successful to set system name") # click create-profile-forward button self.click_button('classic-main-window', 'classic-forward-button') time.sleep(50) if self.check_object_status("classic-main-window", "classic-review-subscription-label", 'ENABLED'): logger.info("It's successful to click create-profile-forward button") else: raise FailException("TestFailed - TestFailed to enable classic-review-subscription-label") # click review-subscription-forward button self.click_button('classic-main-window', 'classic-forward-button') if self.check_object_exist("classic-updates-configured-window", "classic-updates-configured-window"): logger.info("It's successful to click review-subscription-forward button") else: raise FailException("TestFailed - TestFailed to prompt updates-configured-window") # click updates-configured-finish button self.click_button('classic-updates-configured-window', 'classic-updates-configured-finish-button') if not self.check_object_exist("classic-updates-configured-window", "classic-updates-configured-window"): logger.info("It's successful to register using firstboot with rhn-classic mode") else: raise FailException("TestFailed - TestFailed to close updates-configured window")
def open_firstboot(self): logger.info("open_firstboot") self.set_os_release() ldtp.launchapp("firstboot") self.check_window_exist('firstboot-main-window')
def run( self ): ldtp.launchapp( "liteword" )
def step_impl(context, app): l.launchapp(app, logfiles=("/tmp/%s-stdout.log" % app, "/tmp/%s-stderr.log" % app)) time.sleep(1)
@copyright: Copyright (c) 2009 Eitan Isaacson @license: LGPL http://ldtp.freedesktop.org This file may be distributed and/or modified under the terms of the GNU Lesser General Public License version 2 as published by the Free Software Foundation. This file is distributed without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose. See "COPYING" in the source distribution for more information. Headers in this file shall remain intact. ''' import ldtp, ooldtp from time import sleep ldtp.launchapp('/home/mingwei/myworks/cfi/python_rw/target_elf/gedit/gedit_final') frm = ooldtp.context('*gedit') frm.waittillguiexist() txt_field = frm.getchild('txt1') txt_field.enterstring('Hello world!<return>bye<return>') ldtp.imagecapture('*gedit', '/tmp/foo.png') mnu_quit = frm.getchild('mnuQuit') mnu_quit.selectmenuitem() alert = ooldtp.context('Question') alert.waittillguiexist() btn = alert.getchild('btnClosewithoutSaving') btn.click() frm.waittillguinotexist()
def do_screenshot(app, app_name): l.launchapp(app) l.waittillguiexist(app_name) l.imagecapture(app_name, os.path.join(basePath, app + ".png")) l.generatekeyevent("<alt><f4>")
if not os.path.exists(basePath): os.mkdir(basePath) def do_screenshot(app, app_name): l.launchapp(app) l.waittillguiexist(app_name) l.imagecapture(app_name, os.path.join(basePath, app + ".png")) l.generatekeyevent("<alt><f4>") full_screen=l.imagecapture() os.rename(full_screen, os.path.join(basePath, "xfce-desktop.png")) # I/O error workaround l.launchapp("xfce4-terminal") time.sleep(1) l.generatekeyevent("<alt><f4>") # move the mouse away to avoid tool tips l.generatemouseevent(800,600, "abs") # appfinder crashes on imagecapture() - (has to window?) l.launchapp("xfce4-appfinder") l.waittillguiexist("ApplicationFinder") full_screen=l.imagecapture() os.rename(full_screen, os.path.join(basePath, "xfce4-appfinder-main.png")) l.generatekeyevent("<alt><f4>") do_screenshot("xfce4-terminal", "Terminal")
def step_impl(context): l.launchapp("xfce4-popup-clipman", logfiles=("/tmp/xfce4-popup-clipman-stdout.log", "/tmp/xfce4-popup-clipman-stderr.log")) time.sleep(1) # this doesn't work every time...?
def open(self, menu_schema=''): ldtp.launchapp(self.LAUNCHER, [menu_schema])
@license: LGPL http://ldtp.freedesktop.org This file may be distributed and/or modified under the terms of the GNU General Public License version 2 as published by the Free Software Foundation. This file is distributed without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose. See "COPYING" in the source distribution for more information. Headers in this file shall remain intact. ''' import ldtp, ooldtp from time import sleep ldtp.launchapp('gedit') frm = ooldtp.context('*gedit') frm.waittillguiexist() txt_field = frm.getchild('txt1') txt_field.enterstring('Hello world!<return>bye<return>') ldtp.imagecapture('*gedit', '/tmp/foo.png') mnu_quit = frm.getchild('mnuQuit') mnu_quit.selectmenuitem() alert = ooldtp.context('Question') alert.waittillguiexist() btn = alert.getchild('btnClosewithoutSaving') btn.click() frm.waittillguinotexist()
@license: LGPL http://ldtp.freedesktop.org This file may be distributed and/or modified under the terms of the GNU Lesser General Public License version 2 as published by the Free Software Foundation. This file is distributed without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose. See "COPYING" in the source distribution for more information. Headers in this file shall remain intact. ''' import ldtp, ooldtp from time import sleep ldtp.launchapp( '/home/mingwei/myworks/cfi/python_rw/target_elf/gedit/gedit_final') frm = ooldtp.context('*gedit') frm.waittillguiexist() txt_field = frm.getchild('txt1') txt_field.enterstring('Hello world!<return>bye<return>') ldtp.imagecapture('*gedit', '/tmp/foo.png') mnu_quit = frm.getchild('mnuQuit') mnu_quit.selectmenuitem() alert = ooldtp.context('Question') alert.waittillguiexist() btn = alert.getchild('btnClosewithoutSaving') btn.click() frm.waittillguinotexist()
def step_impl(context, app): l.launchapp(app) time.sleep(1)
@license: LGPL http://ldtp.freedesktop.org This file may be distributed and/or modified under the terms of the GNU Lesser General Public License version 2 as published by the Free Software Foundation. This file is distributed without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose. See "COPYING" in the source distribution for more information. Headers in this file shall remain intact. ''' import ldtp, ooldtp from time import sleep ldtp.launchapp('gedit') frm = ooldtp.context('*gedit') frm.waittillguiexist() txt_field = frm.getchild('txt1') txt_field.enterstring('Hello world!<return>bye<return>') ldtp.imagecapture('*gedit', '/tmp/foo.png') mnu_quit = frm.getchild('mnuQuit') mnu_quit.selectmenuitem() alert = ooldtp.context('Question') alert.waittillguiexist() btn = alert.getchild('btnClosewithoutSaving') btn.click() frm.waittillguinotexist()
if not os.path.exists(basePath): os.mkdir(basePath) def do_screenshot(app, app_name): l.launchapp(app) l.waittillguiexist(app_name) l.imagecapture(app_name, os.path.join(basePath, app + ".png")) l.generatekeyevent("<alt><f4>") full_screen = l.imagecapture() os.rename(full_screen, os.path.join(basePath, "xfce-desktop.png")) # I/O error workaround l.launchapp("xfce4-terminal") time.sleep(1) l.generatekeyevent("<alt><f4>") # move the mouse away to avoid tool tips l.generatemouseevent(800, 600, "abs") # appfinder crashes on imagecapture() - (has to window?) l.launchapp("xfce4-appfinder") l.waittillguiexist("ApplicationFinder") full_screen = l.imagecapture() os.rename(full_screen, os.path.join(basePath, "xfce4-appfinder-main.png")) l.generatekeyevent("<alt><f4>") do_screenshot("xfce4-terminal", "Terminal") do_screenshot("xfce4-clipman-settings", "Clipman")