def testShoppingListGenerationFromCard (self): # Test multiplication + no multiplication self.focus_nth_recipe() dp.keyCombo('<Ctrl>o') # open recipe card dp.focus.frame('') dp.click('Actions') dp.click('Shop') # using shop button dp.focus.frame('Shopping List') screenshot('add-to-shopping-list-from-card-w-button.png') dp.keyCombo('<Ctrl>w') dp.focus.frame('') dp.click('Recipe') dp.click("Add to Shopping List") # from menu dp.focus.frame('Shopping List') screenshot('add-to-shopping-list-from-card-w-menu.png') screenshot('Adding Shopping List from Card') dp.keyCombo('<Ctrl>w') dp.focus.frame('') dp.keyCombo('<Alt>y') dp.focus.text() dp.type('12') # double... dp.keyCombo('<Ctrl>l') # from keyboard dp.keyCombo('<Return>') screenshot('add-to-shopping-list-from-card-w-keyboard-multiplied-by-2.png') dp.keyCombo('<Ctrl>w')
def runTest(self): """A version of TestCase.runTest that attempts to take a screenshot of anaconda should a test fail. Subclasses should not override this. See the documentation for _run. """ self.update_scratch_dir() try: self._run() except (AssertionError, SearchError): # Try to take a screenshot of whatever screen anaconda's on, so # we can attempt to figure out what went wrong. screenshot() raise
def checkRunning(self, message, terminate = False): """ Checks whether the application is running, will also see if it crashed and made a core dump; Will write a rhts result, thus serves as a test checkpoint""" result = terminate if self.isAccessible(): printOut ('%s is running!' % self.appname) result = not terminate if terminate: self.kill() if self.isCoreDump() is not False: printError ('%s exited with code %d!' % (self.appname, self.isCoreDump())) result = False screenshot() self.writeResult(message, result) return result
def do_testWebImport (self, url): shortname = url.split('/')[-1] dp.focus.application(APPNAME) dp.focus.frame('Gourmet Recipe Manager') dp.click("File") dp.click('Import webpage') time.sleep(2) dp.focus.frame('Enter website address') print('TYPING URL!') dp.type(url) dp.keyCombo("Return") time.sleep(1) screenshot('manual_web_import-%s.png'%shortname) dp.click('OK') screenshot('manual_web_import_done-%s.png'%shortname) dp.focus.dialog('Gourmet Import/Export') dp.click('Close')
def do_testWebImport (self, url): shortname = url.split('/')[-1] dp.focus.application(APPNAME) dp.focus.frame('Gourmet Recipe Manager') dp.click("File") dp.click('Import webpage') time.sleep(2) dp.focus.frame('Enter website address') print 'TYPING URL!' dp.type(url) dp.keyCombo("Return") time.sleep(1) screenshot('manual_web_import-%s.png'%shortname) dp.click('OK') screenshot('manual_web_import_done-%s.png'%shortname) dp.focus.dialog('Gourmet Import/Export') dp.click('Close')
def test_template_case(self): """ # RHEL7-13710 # [Storage] Add storage pool- dir """ testcase_begin_log(get_current_function_name()) DEFAULT_CASE_RESULT = "FAILED" try: # case body # ...... DEFAULT_CASE_RESULT = "PASSED" except Exception as e: screenshot(get_current_function_name()) exception_log(e) raise finally: # env clear # ...... testcase_finish_log(get_current_function_name(), DEFAULT_CASE_RESULT)
def testEditingNewCard (self): dp.focus.application(APPNAME) dp.focus.frame('Gourmet Recipe Manager') #dp.keyCombo('<Ctrl>n') dp.click('File') dp.click('New') dp.focus.frame('New Recipe (Edit)') dp.keyCombo('<Alt>l') dp.focus.widget('Title Entry') time.sleep(1) dp.type('Testing!') dp.focus.widget('Preparation Time Entry') time.sleep(1) dp.type('30 minutes') dp.focus.widget('Rating Entry') time.sleep(1) dp.type('4') screenshot('Edited_recipe.png') #dp.keyCombo('<Ctrl>w') dp.click("Recipe") dp.click("Close") screenshot('save_changes_to_edited_rec.png') dp.focus.dialog('Question') #dp.keyCombo('<Alt>C') dp.click("Cancel") #self.assertEqual(hasattr(rc,'recipe_editor'),True,'Cancelling save-changes did not work') dp.focus.frame('New Recipe (Edit)') time.sleep(3) dp.keyCombo('<Ctrl>w') time.sleep(3) dp.focus.dialog('Question') dp.keyCombo('<Alt>s') screenshot('new_rec_saved.png')
def testEditingNewCard (self): dp.focus.application(APPNAME) dp.focus.frame('Gourmet Recipe Manager') #dp.keyCombo('<Ctrl>n') dp.click('File') dp.click('New') dp.focus.frame(u'New Recipe (Edit)') dp.keyCombo('<Alt>l') dp.focus.widget('Title Entry') time.sleep(1) dp.type('Testing!') dp.focus.widget('Preparation Time Entry') time.sleep(1) dp.type('30 minutes') dp.focus.widget('Rating Entry') time.sleep(1) dp.type('4') screenshot('Edited_recipe.png') #dp.keyCombo('<Ctrl>w') dp.click("Recipe") dp.click("Close") screenshot('save_changes_to_edited_rec.png') dp.focus.dialog('Question') #dp.keyCombo('<Alt>C') dp.click("Cancel") #self.assertEqual(hasattr(rc,'recipe_editor'),True,'Cancelling save-changes did not work') dp.focus.frame(u'New Recipe (Edit)') time.sleep(3) dp.keyCombo('<Ctrl>w') time.sleep(3) dp.focus.dialog('Question') dp.keyCombo('<Alt>s') screenshot('new_rec_saved.png')
def do_testFileImport (self, fn): shortname = os.path.split(fn)[1] dp.focus.application(APPNAME) dp.focus.frame('Gourmet Recipe Manager') dp.click("File") dp.click("Import file") dp.focus.dialog('Open recipe...') dp.keyCombo("<Alt>l") dp.type(fn) screenshot('import_dialog-%s-.png'%shortname) dp.keyCombo("Return") time.sleep(5) # wait for import to complete... print('DONE SLEEPING -- IMPORT SHOULD BE DONE!') screenshot('import_done-%s.png'%shortname) dp.keyCombo("<Alt>C") # close dialog dp.focus.frame('Gourmet Recipe Manager') screenshot('with_imported_recs-%s.png'%shortname)
def do_testFileImport (self, fn): shortname = os.path.split(fn)[1] dp.focus.application(APPNAME) dp.focus.frame('Gourmet Recipe Manager') dp.click("File") dp.click("Import file") dp.focus.dialog('Open recipe...') dp.keyCombo("<Alt>l") dp.type(fn) screenshot('import_dialog-%s-.png'%shortname) dp.keyCombo("Return") time.sleep(5) # wait for import to complete... print 'DONE SLEEPING -- IMPORT SHOULD BE DONE!' screenshot('import_done-%s.png'%shortname) dp.keyCombo("<Alt>C") # close dialog dp.focus.frame('Gourmet Recipe Manager') screenshot('with_imported_recs-%s.png'%shortname)
def testShoppingListGenerationFromIndex (self): self.focus_nth_recipe(0) dp.click('Actions') dp.click('Add to Shopping List') screenshot('generate_shopping_list_from_index.png') dp.focus.dialog('') dp.click('OK') screenshot('generated_shopping_list_from_index.png') dp.focus.frame('Shopping List') dp.keyCombo('<Ctrl>w') # Add a second recipe to the list... self.focus_nth_recipe(1) dp.keyCombo('<Ctrl>l') # Add with keycombo... dp.focus.dialog('') dp.focus.text() dp.type('12') dp.keyCombo('<Return>') screenshot('shopping list With two recipes+mult.png') dp.keyCombo('<Ctrl>w')
def test_vm_install_url(self): """ # RHEL7-13827 # [Install domain] Install vm from HTTP - qcow2 """ testcase_begin_log(get_current_function_name()) DEFAULT_CASE_RESULT = "FAILED" try: newvm_wizard = vmmAddNewVM(app=self.app) newvm_wizard.open_create_wizard(self.app.root) find_fuzzy(newvm_wizard.rootwindow, "Network Install", "radio").click() find_fuzzy(newvm_wizard.rootwindow, "Forward", "button").click() find_pattern(newvm_wizard.rootwindow, None, "text", "URL").typeText(DEFAULT_TREE) # type kickstart into kernel options for auto installation # toggle button click doesn't work, so user keyCombo instead # uiutils.find_pattern(newvm_wizard, "URL Options", "toggle button").click() newvm_wizard.rootwindow.keyCombo('<Alt>o') find_pattern(newvm_wizard.rootwindow, None, "text", "Kernel options").typeText(DEFAULT_KICKSTART) # auto detect will begin after clicking Forward button find_fuzzy(newvm_wizard.rootwindow, "Forward", "button").click() version = find_pattern(newvm_wizard.rootwindow, "install-os-version-label") time.sleep(1) check_in_loop(lambda: "Detecting" not in version.text and "-" not in version.text) # check auto detecting version self.assertEquals(version.text, OS_VERSION) find_fuzzy(newvm_wizard.rootwindow, "Forward", "button").click() find_fuzzy(newvm_wizard.rootwindow, "Forward", "button").click() find_pattern(newvm_wizard.rootwindow, None, "text", "Name").typeText(GUEST_NAME) find_fuzzy(newvm_wizard.rootwindow, "Finish", "button").click() #time.sleep(.5) progress = find_fuzzy(self.app.root, "Creating Virtual Machine", "frame") # waiting 5 mins, if timeout, maybe a network problem check_in_loop(lambda: not progress.showing, 300) time.sleep(.5) find_fuzzy(self.app.root, GUEST_NAME + " on", "frame") self.assertFalse(newvm_wizard.rootwindow.showing) if self.app.pid is not None: # waiting vm installation complete check_vm_install_complete(self.app.pid, GUEST_NAME) else: self.assertTrue(False, "Error: pid is None") # check ping to guest, this only works for qemu:///system res = ping_vm(GUEST_NAME) self.assertTrue(res) self.app.quit() DEFAULT_CASE_RESULT = "PASSED" except Exception as e: screenshot(get_current_function_name()) exception_log(e) raise finally: testcase_finish_log(get_current_function_name(), DEFAULT_CASE_RESULT)
def testWebImport (self): self.do_testWebImport('file:///home/tom/Projects/grecipe-manager/src/tests/recipe_files/sample_site.html') self.search_and_open("Spaghetti") screenshot('web_imported_recipe_card-sample_site.png')
from dogtail import utils utils.screenshot("this_file.png")