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 exit_application(self): try: win = wx.GetApp().GetTopWindow() if win: win.Destroy() facade.send_close_message_to_window(facade.get_active_window()) finally: wx.GetApp().Exit() Logger.success(self.result_message("Application destroyed"))
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 close_dialog(self): name_or_label = self.arg(1) if name_or_label is None: name_or_label = self.wrapper_win.GetLabel() self.gui_explorer.find_win_by_name_or_label(name_or_label) if self.gui_explorer.is_wx_control(): self.gui_explorer.get_ctrl().Destroy() else: facade.send_close_message_to_window(self.gui_explorer.get_ctrl()) Logger.success(self.result_message("Closed"))
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 _select_listbox_item(self, classname): name_label_or_position = self.arg(1) text = self.arg(2) self.gui_explorer.find_ctrl(self.wrapper_win, name_label_or_position, classname) if self.gui_explorer.is_wx_control(): ctrl = self.gui_explorer.get_ctrl() try: inx = int(text) - 1 except: inx = ctrl.FindString(text) if inx is not wx.NOT_FOUND: Logger.success(self.result_message("Found")) ctrl.SetSelection(inx) evt = wx.CommandEvent(wx.EVT_LISTBOX.evtType[0], ctrl.GetId()) evt.SetInt(inx) wx.PostEvent(ctrl.GetParent(), evt) else: raise NotFoundException("ListBox row(%s) in '%s'" % (text, name_label_or_position)) else: # TODO: # facade.send_text_to_text_control(self.gui_explorer.get_ctrl(), text) pass