def assert_closed(self): alternative_names = self.arg(1).split("|") for name in alternative_names: if self._open(name): Logger.failure(self.result_message("Open")) return Logger.success(self.result_message("Closed"))
def select_menu(self): try: self.gui_explorer.find_menu(self.get_all_args()) Logger.success(self.result_message("Found")) wx.GetApp().GetTopWindow().click_menu_item( self.gui_explorer.item_id) except NotFoundException: Logger.failure(self.result_message("NOT Found"))
def _get_wx_control_text(self): ctrl = self.gui_explorer.get_ctrl() text = self.gui_explorer.get_ctrl().GetLabelText() expected_text = self.arg(2) for expected in expected_text.split("|"): if expected.strip() == text.strip(): Logger.success("Text='%s'" % text) return Logger.failure("Text Expected:'%s' Got:'%s'" % (expected, text))
def find_wxctrl(self, classname): alternative_names = [name.strip() for name in self.arg(1).split("|")] for name in alternative_names: try: self.gui_explorer.find_ctrl(self.wrapper_win, name, classname) Logger.success(self.result_message("Found")) return self.gui_explorer.is_wx_control() except NotFoundException: pass Logger.failure(self.result_message("NOT Found"))
def click_mouse(self): """ This method never fails but we keep the catching of NotFoundException in case we should change the code.s """ pos = (int(self.arg(1)), int(self.arg(2))) try: Logger.success(self.result_message("Clicked")) facade.send_lbutton_click_to_window( pos, self.hold_down_ctrl_key_when_clicking()) except NotFoundException: Logger.failure(self.result_message("Failed"))
def run_python_file(args): """Run a python file as if it were the main program on the command line. `args` is the argument array to present as sys.argv, including the first element representing the file being executed. Lifted straight from coverage.py by Ned Batchelder """ try: # In Py 2.x, the builtins were in __builtin__ BUILTINS = sys.modules['__builtin__'] except KeyError: # pragma: no cover - not worried about Python 3 yet... # In Py 3.x, they're in builtins BUILTINS = sys.modules['builtins'] filename = args[0] # Create a module to serve as __main__ old_main_mod = sys.modules['__main__'] main_mod = imp.new_module('__main__') sys.modules['__main__'] = main_mod main_mod.__file__ = filename main_mod.__builtins__ = BUILTINS # Set sys.argv and the first path element properly. old_argv = sys.argv old_path0 = sys.path[0] sys.argv = args sys.path[0] = os.path.dirname(filename) try: sys.stdout = open('outfile.txt', 'w') source = open(filename, 'rU').read() exec compile(source, filename, "exec") in main_mod.__dict__ except Exception, ex: Logger.add_error("%s" % ex) Logger.failure("Exception in application")
def select_listbox_item(self, classname): try: self._select_listbox_item(classname) except NotFoundException: Logger.failure(self.result_message("NOT Found"))