How to use _on_close method in Playwright Python

Best Python code snippet using playwright-python

customize_outfit_dialog.py

Source:customize_outfit_dialog.py Github

copy

Full Screen

...56 @CommonExceptionHandler.catch_exceptions(ModInfo.get_identity())57 def open(self) -> None:58 """ Open the dialog for customizing a sims outfit. """59 self.log.format_with_message('Opening customize outfit dialog.', sim=CommonSimNameUtils.get_full_name(self._sim_info))60 def _on_close() -> None:61 if self._on_close is not None:62 self._on_close()63 def _reopen_dialog() -> None:64 option_dialog.show(sim_info=self._sim_info, page=option_dialog.current_page)65 outfit_parts = OCCASPartQueryUtils().get_cas_parts_for_sim(self._sim_info)66 if not outfit_parts:67 CommonOkDialog(68 OCStringId.OC_CUSTOMIZE_OUTFIT_OC,69 OCStringId.OC_NO_OUTFIT_PARTS_FOUND,70 mod_identity=self.mod_identity71 ).show(on_acknowledged=_on_close)72 return73 option_dialog = CommonChooseObjectOptionDialog(74 OCStringId.OC_CUSTOMIZE_OUTFIT_OC,75 0,76 on_close=_on_close,77 mod_identity=self.mod_identity78 )79 def _on_option_chosen(option_identifier: str, choice: _OutfitPartsBy):80 self.log.debug('Opening Outfit Parts: {}'.format(option_identifier))81 self._open_outfit_parts_by(choice, outfit_parts, on_close=_reopen_dialog)82 option_dialog.add_option(83 CommonDialogObjectOption(84 'By Tag',85 _OutfitPartsBy.TAG,86 CommonDialogOptionContext(87 OCStringId.OC_FILTER_BY_TAG,88 0,89 icon=CommonIconUtils.load_arrow_navigate_into_icon()90 ),91 on_chosen=_on_option_chosen92 )93 )94 option_dialog.add_option(95 CommonDialogObjectOption(96 'By Outfit Slot',97 _OutfitPartsBy.OUTFIT_SLOT,98 CommonDialogOptionContext(99 OCStringId.OC_FILTER_BY_OUTFIT_SLOT,100 0,101 icon=CommonIconUtils.load_arrow_navigate_into_icon()102 ),103 on_chosen=_on_option_chosen104 )105 )106 option_dialog.add_option(107 CommonDialogObjectOption(108 'By Author',109 _OutfitPartsBy.AUTHOR,110 CommonDialogOptionContext(111 OCStringId.OC_FILTER_BY_AUTHOR,112 0,113 icon=CommonIconUtils.load_arrow_navigate_into_icon()114 ),115 on_chosen=_on_option_chosen116 )117 )118 option_dialog.show(sim_info=self._sim_info)119 def _open_outfit_parts_by(self, outfit_parts_by: _OutfitPartsBy, outfit_parts: Tuple[OCOutfitPart], on_close: Callable[[], None]):120 self.log.format_with_message('Opening outfit parts by', outfit_parts_by=outfit_parts_by)121 def _on_close() -> None:122 on_close()123 option_dialog = CommonChooseObjectOptionDialog(124 OCStringId.OC_CUSTOMIZE_OUTFIT_OC,125 0,126 on_close=_on_close,127 mod_identity=self.mod_identity128 )129 def _reopen_dialog() -> None:130 option_dialog.show(sim_info=self._sim_info, page=option_dialog.current_page)131 def _on_option_chosen(option_identifier: str, chosen: Tuple[OCOutfitPart]):132 self.log.debug('Opening Outfit Parts By: {}'.format(option_identifier))133 self._open_with_outfit_parts(chosen, on_close_callback=_reopen_dialog)134 def _no_outfit_parts_found() -> None:135 CommonOkDialog(136 OCStringId.OC_CUSTOMIZE_OUTFIT_OC,137 OCStringId.OC_NO_OUTFIT_PARTS_FOUND,138 mod_identity=self.mod_identity139 ).show(on_acknowledged=_on_close)140 if outfit_parts_by == _OutfitPartsBy.NONE:141 self.log.debug('outfit_parts_by was NONE')142 _no_outfit_parts_found()143 return144 self.log.format_with_message('Creating outfit parts by', outfit_parts_by=outfit_parts_by)145 if len(outfit_parts) == 0:146 self.log.debug('No outfit parts found!')147 _no_outfit_parts_found()148 return149 sorted_outfit_parts = sorted(outfit_parts, key=lambda op: op.raw_display_name)150 if not sorted_outfit_parts:151 self.log.debug('Failed to sort outfit parts by name')152 _no_outfit_parts_found()153 return154 self.log.format_with_message('Outfit parts sorted.', sorted_outfit_parts=sorted_outfit_parts)155 outfit_parts_by_value_dict = {}156 for outfit_part in sorted_outfit_parts:157 outfit_part: OCOutfitPart = outfit_part158 self.log.format_with_message('Looking at outfit part.', outfit_part=outfit_part)159 if not CommonCASUtils.is_cas_part_loaded(outfit_part.part_id):160 self.log.debug('Outfit part not loaded.')161 continue162 keys = self._get_outfit_part_key(outfit_part, outfit_parts_by=outfit_parts_by)163 if keys is None:164 self.log.debug('No key found.')165 continue166 for key in keys:167 str_key = str(key)168 by_value = outfit_parts_by_value_dict.get(str_key, list())169 by_value.append(outfit_part)170 outfit_parts_by_value_dict[str_key] = by_value171 self.log.debug('Outfit part loaded.')172 if len(outfit_parts_by_value_dict) == 0:173 self.log.format_with_message('No outfit parts found with outfit parts by!', outfit_parts_by=outfit_parts_by, outfit_parts_by_value_dict=outfit_parts_by_value_dict)174 self.log.debug('No outfit parts found!')175 _no_outfit_parts_found()176 return177 self.log.format_with_message('Finished filtering outfit parts.', outfit_parts_by_value_dict=outfit_parts_by_value_dict)178 sorted_keys = sorted(outfit_parts_by_value_dict.keys())179 self.log.format(sorted_keys=sorted_keys)180 for key in sorted_keys:181 self.log.format_with_message('Building key', key=key)182 outfit_parts_by_value: List[OCOutfitPart] = outfit_parts_by_value_dict[key]183 if len(outfit_parts_by_value) == 0:184 self.log.debug('No parts found in key.')185 continue186 outfit_parts_count = str(len(outfit_parts_by_value))187 self.log.format_with_message('Found outfit parts', count=outfit_parts_count)188 option_dialog.add_option(189 CommonDialogObjectOption(190 key,191 tuple(outfit_parts_by_value),192 CommonDialogOptionContext(193 key,194 OCStringId.OC_OUTFIT_PARTS_COUNT,195 description_tokens=(outfit_parts_count,),196 icon=CommonIconUtils.load_arrow_navigate_into_icon()197 ),198 on_chosen=_on_option_chosen199 )200 )201 if not option_dialog.has_options():202 self.log.debug('No options found in dialog.')203 _no_outfit_parts_found()204 return205 self.log.debug('Showing dialog.')206 option_dialog.show(sim_info=self._sim_info)207 def _get_outfit_part_key(self, outfit_part: OCOutfitPart, outfit_parts_by: _OutfitPartsBy=_OutfitPartsBy.NONE) -> Any:208 if outfit_parts_by == _OutfitPartsBy.NONE:209 return None210 if outfit_parts_by == _OutfitPartsBy.TAG:211 return outfit_part.tags212 elif outfit_parts_by == _OutfitPartsBy.AUTHOR:213 return outfit_part.author,214 return str(CommonCASUtils.get_body_type_of_cas_part(outfit_part.part_id)).replace('BodyType.', ''),215 @CommonExceptionHandler.catch_exceptions(ModInfo.get_identity())216 def _open_with_outfit_parts(self, outfit_parts: Tuple[OCOutfitPart], on_close_callback: Callable[[], None]=None, current_page: int=1):217 self.log.format_with_message('Opening with outfit parts.', outfit_parts=outfit_parts)218 def _on_close() -> None:219 if on_close_callback is not None:220 on_close_callback()221 option_dialog = CommonChooseObjectOptionDialog(222 OCStringId.OC_CUSTOMIZE_OUTFIT_OC,223 0,224 on_close=_on_close,225 mod_identity=self.mod_identity226 )227 def _reopen_dialog() -> None:228 option_dialog.show(sim_info=self._sim_info, picker_type=UiObjectPicker.UiObjectPickerObjectPickerType.OBJECT, page=option_dialog.current_page)229 def _on_option_chosen(option_identifier: str, chosen: str):230 self.log.debug('Chose tag: {}'.format(option_identifier))231 self._open_cas_part_selector(outfit_parts, chosen, on_close_callback=_reopen_dialog)232 def _no_outfit_parts_found() -> None:233 CommonOkDialog(234 OCStringId.OC_CUSTOMIZE_OUTFIT_OC,235 OCStringId.OC_NO_OUTFIT_PARTS_FOUND,236 mod_identity=self.mod_identity237 ).show(on_acknowledged=_on_close)238 if not outfit_parts:239 _no_outfit_parts_found()240 return241 object_categories: List[str] = list()242 for outfit_part in outfit_parts:243 for part_tag in outfit_part.tag_list:244 if str(part_tag) in object_categories:245 continue246 object_categories.append(str(part_tag))247 sorted_object_categories = sorted(object_categories, key=lambda item: item)248 for object_category in sorted_object_categories:249 option_dialog.add_option(250 CommonDialogSelectOption(251 object_category,252 object_category,253 CommonDialogOptionContext(254 object_category,255 0,256 icon=CommonIconUtils.load_arrow_navigate_into_icon()257 ),258 on_chosen=_on_option_chosen259 )260 )261 option_dialog.show(262 sim_info=self._sim_info,263 picker_type=UiObjectPicker.UiObjectPickerObjectPickerType.OBJECT,264 page=current_page265 )266 @CommonExceptionHandler.catch_exceptions(ModInfo.get_identity())267 def _open_cas_part_selector(self, outfit_parts: Tuple[OCOutfitPart], tag: str, on_close_callback: Callable[[], None]=None, current_page: int=1):268 self.log.format_with_message('Opening with outfit parts.', outfit_parts=outfit_parts)269 def _on_close() -> None:270 if on_close_callback is not None:271 on_close_callback()272 def _reopen_dialog() -> None:273 self._open_cas_part_selector(outfit_parts, tag, on_close_callback=on_close_callback, current_page=option_dialog.current_page)274 option_dialog = CommonChooseObjectOptionDialog(275 OCStringId.OC_CUSTOMIZE_OUTFIT_OC,276 0,277 mod_identity=self.mod_identity,278 on_close=_on_close279 )280 outfit_io = CommonSimOutfitIO(self._sim_info, mod_identity=self.mod_identity)281 def _on_option_chosen(option_identifier: str, picked_outfit_part: OCOutfitPart):282 self.log.debug('Chose outfit part: {}'.format(option_identifier))283 self._open_body_type_selection(picked_outfit_part, outfit_io, on_close_callback=_reopen_dialog)284 def _on_remove_chosen() -> None:285 OCOutfitPartUtils.remove_outfit_parts(self._sim_info, outfit_parts)286 _reopen_dialog()287 def _no_outfit_parts_found() -> None:288 CommonOkDialog(289 OCStringId.OC_CUSTOMIZE_OUTFIT_OC,290 OCStringId.OC_NO_OUTFIT_PARTS_FOUND291 ).show(on_acknowledged=_on_close)292 if not outfit_parts:293 _no_outfit_parts_found()294 return295 sorted_outfit_parts = sorted(outfit_parts, key=lambda item: item.raw_display_name)296 option_dialog.add_option(297 CommonDialogActionOption(298 CommonDialogOptionContext(299 OCStringId.OC_REMOVE_ALL,300 0,301 icon=CommonIconUtils.load_x_icon(),302 tooltip_text_identifier=OCStringId.OC_REMOVE_ALL,303 ),304 on_chosen=_on_remove_chosen,305 always_visible=True306 )307 )308 for outfit_part in sorted_outfit_parts:309 if tag not in outfit_part.tag_list:310 continue311 part_id = outfit_part.part_id312 author = outfit_part.author313 icon = CommonIconUtils._load_icon(outfit_part.icon_id) or CommonIconUtils.load_question_mark_icon()314 outfit_part_name = outfit_part.display_name315 # If outfit part is already equipped316 if outfit_io.is_cas_part_attached(part_id):317 outfit_part_name = CommonLocalizationUtils.create_localized_string(CommonStringId.TEXT_WITH_GREEN_COLOR, tokens=(outfit_part_name,))318 option_dialog.add_option(319 CommonDialogObjectOption(320 str(part_id),321 outfit_part,322 CommonDialogOptionContext(323 outfit_part_name,324 OCStringId.OC_AUTHOR,325 description_tokens=(author,),326 icon=icon,327 ),328 on_chosen=_on_option_chosen329 )330 )331 # noinspection PyTypeChecker332 option_dialog.show(333 sim_info=self._sim_info,334 picker_type=UiObjectPicker.UiObjectPickerObjectPickerType.OBJECT,335 page=current_page336 )337 @CommonExceptionHandler.catch_exceptions(ModInfo.get_identity())338 def _open_body_type_selection(self, outfit_part: OCOutfitPart, outfit_io: CommonSimOutfitIO, on_close_callback: Callable[[], None]=None):339 def _on_close() -> None:340 if on_close_callback is not None:341 on_close_callback()342 def _reopen_dialog() -> None:343 self._open_body_type_selection(outfit_part, outfit_io, on_close_callback=on_close_callback)344 def _on_option_chosen(option_identifier: str, picked_body_type: BodyType):345 self.log.debug('Chose body type: {}'.format(option_identifier))346 if outfit_io.is_cas_part_attached(outfit_part.part_id):347 outfit_io.detach_cas_part(outfit_part.part_id)348 outfit_io.attach_cas_part(outfit_part.part_id, body_type=picked_body_type)349 outfit_io.apply()350 _reopen_dialog()351 def _on_remove_chosen() -> None:352 if outfit_io.is_cas_part_attached(outfit_part.part_id):353 outfit_io.detach_cas_part(outfit_part.part_id)...

Full Screen

Full Screen

slider_template_dialog.py

Source:slider_template_dialog.py Github

copy

Full Screen

...45 return 'csf_slider_template_dialog'46 def open(self, sim_info: SimInfo, page: int=1) -> None:47 """ Open the dialog. """48 self.log.format_with_message('Opening dialog.', sim=sim_info)49 def _on_close() -> None:50 self.log.debug('Slider Template dialog closed.')51 if self._on_close is not None:52 self._on_close()53 def _reopen() -> None:54 self.log.debug('Reopening slider template dialog.')55 self.open(sim_info, page=option_dialog.current_page)56 option_dialog = CommonChooseObjectOptionDialog(57 CSFStringId.SLIDER_TEMPLATES_NAME,58 CSFStringId.SLIDER_TEMPLATES_DESCRIPTION,59 mod_identity=self.mod_identity,60 on_close=_on_close,61 per_page=40062 )63 option_dialog.add_option(64 CommonDialogActionOption(65 CommonDialogOptionContext(66 CSFStringId.SELECTED_TEMPLATE,67 0,68 title_tokens=(CSFSliderTemplateDialog._SELECTED_TEMPLATE.template_name if CSFSliderTemplateDialog._SELECTED_TEMPLATE is not None else CSFStringId.NO_TEMPLATE_SELECTED,)69 ),70 on_chosen=lambda *_, **__: self._select_template(sim_info, on_close=_reopen)71 )72 )73 def _on_apply_template_to_sim() -> None:74 self.log.debug('Confirming all sliders reset.')75 if CSFSliderTemplateDialog._SELECTED_TEMPLATE is None:76 def _on_acknowledge(_) -> None:77 _reopen()78 CommonOkDialog(79 CSFStringId.NO_TEMPLATE_SELECTED,80 CSFStringId.PLEASE_SELECT_A_TEMPLATE,81 mod_identity=self.mod_identity82 ).show(on_acknowledged=_on_acknowledge)83 return84 def _on_confirm(_) -> None:85 self.log.debug('Applying template to Sim.')86 CSFSliderTemplateDialog._SELECTED_TEMPLATE.apply_to_sim(sim_info)87 _reopen()88 def _on_cancel(_) -> None:89 self.log.debug('Cancelled template apply.')90 _reopen()91 CommonOkCancelDialog(92 CSFStringId.CONFIRMATION,93 CSFStringId.APPLY_TEMPLATE_TO_SIM_CONFIRMATION_DESCRIPTION,94 description_tokens=(sim_info,),95 mod_identity=self.mod_identity96 ).show(on_ok_selected=_on_confirm, on_cancel_selected=_on_cancel)97 self.log.debug('Opening Customize Slider dialog.')98 option_dialog.add_option(99 CommonDialogActionOption(100 CommonDialogOptionContext(101 CSFStringId.APPLY_TEMPLATE_TO_SIM_NAME,102 CSFStringId.APPLY_TEMPLATE_TO_SIM_DESCRIPTION,103 description_tokens=(sim_info,),104 is_enabled=CSFSliderTemplateDialog._SELECTED_TEMPLATE is not None105 ),106 on_chosen=lambda *_, **__: _on_apply_template_to_sim()107 )108 )109 def _on_save_as_template(_: str, template_name: str, outcome: CommonChoiceOutcome):110 if _ is None or template_name is None or CommonChoiceOutcome.is_error_or_cancel(outcome):111 self.log.debug('No template name entered, dialog closed.')112 _reopen()113 return114 self.log.format_with_message('Template name entered.', template_name=template_name)115 if template_name in self._template_utils.template_library:116 def _on_yes(_) -> None:117 self.log.debug('Saving template.')118 self._template_utils.save_sliders_of(sim_info, template_name)119 _reopen()120 def _on_no(_) -> None:121 self.log.debug('Cancelled saving template.')122 _reopen()123 CommonOkCancelDialog(124 CSFStringId.TEMPLATE_ALREADY_EXISTS_NAME,125 CSFStringId.TEMPLATE_ALREADY_EXISTS_DESCRIPTION,126 description_tokens=(template_name,),127 ok_text_identifier=CSFStringId.YES,128 cancel_text_identifier=CSFStringId.NO,129 mod_identity=self.mod_identity130 ).show(on_ok_selected=_on_yes, on_cancel_selected=_on_no)131 return132 self._template_utils.save_sliders_of(sim_info, template_name)133 _reopen()134 option_dialog.add_option(135 CommonDialogInputTextOption(136 self.mod_identity,137 'Save Template From Sim',138 CommonSimNameUtils.get_full_name(sim_info),139 CommonDialogOptionContext(140 CSFStringId.CREATE_TEMPLATE_FROM_SIM_NAME,141 CSFStringId.CREATE_TEMPLATE_FROM_SIM_DESCRIPTION,142 title_tokens=(sim_info,),143 description_tokens=(sim_info,)144 ),145 on_chosen=_on_save_as_template,146 dialog_description_identifier=CSFStringId.ENTER_A_NAME_FOR_YOUR_NEW_TEMPLATE147 )148 )149 option_dialog.add_option(150 CommonDialogActionOption(151 CommonDialogOptionContext(152 CSFStringId.VIEW_TEMPLATE_NAME,153 CSFStringId.VIEW_TEMPLATE_DESCRIPTION,154 is_enabled=CSFSliderTemplateDialog._SELECTED_TEMPLATE is not None,155 title_tokens=(CSFSliderTemplateDialog._SELECTED_TEMPLATE.template_name if CSFSliderTemplateDialog._SELECTED_TEMPLATE is not None else CSFStringId.NO_TEMPLATE_SELECTED,)156 ),157 on_chosen=lambda *_, **__: self._view_template(sim_info, on_close=_reopen)158 )159 )160 option_dialog.show(161 sim_info=sim_info,162 page=page163 )164 def _select_template(self, sim_info: SimInfo, on_close: Callable[[], None]=None):165 self.log.format_with_message('Opening dialog.', sim=sim_info)166 def _on_close() -> None:167 self.log.debug('Slider Template dialog closed.')168 if on_close is not None:169 on_close()170 option_dialog = CommonChooseObjectOptionDialog(171 CSFStringId.SELECTED_TEMPLATE,172 CSFStringId.PLEASE_SELECT_A_TEMPLATE,173 mod_identity=self.mod_identity,174 on_close=_on_close,175 per_page=400176 )177 self.log.debug('Opening Customize Slider dialog.')178 def _on_chosen(_: str, _chosen_template: CSFSliderTemplate):179 if _chosen_template is None:180 self.log.debug('No template name entered, dialog closed.')181 _on_close()182 return183 self.log.format_with_message('Template name entered.', template_name=_chosen_template.template_name)184 CSFSliderTemplateDialog._SELECTED_TEMPLATE = _chosen_template185 _on_close()186 for (template_name, template) in self._template_utils.template_library.items():187 template: CSFSliderTemplate = template188 option_dialog.add_option(189 CommonDialogObjectOption(190 template_name,191 template,192 CommonDialogOptionContext(193 template.display_name,194 0,195 icon=CommonIconUtils.load_filled_circle_icon() if CSFSliderTemplateDialog._SELECTED_TEMPLATE == template else CommonIconUtils.load_unfilled_circle_icon(),196 ),197 on_chosen=_on_chosen198 )199 )200 if not option_dialog.has_options():201 def _on_acknowledge(_) -> None:202 _on_close()203 CommonOkDialog(204 CSFStringId.NO_TEMPLATES_DETECTED_NAME,205 CSFStringId.NO_TEMPLATES_DETECTED_DESCRIPTION,206 mod_identity=self.mod_identity207 ).show(on_acknowledged=_on_acknowledge)208 return209 option_dialog.show(210 sim_info=sim_info211 )212 def _view_template(self, sim_info: SimInfo, on_close: Callable[[], None]=None):213 self.log.format_with_message('Opening view template dialog.', sim=sim_info)214 def _on_close() -> None:215 self.log.debug('Slider Template dialog closed.')216 if on_close is not None:217 on_close()218 def _reopen() -> None:219 self._view_template(sim_info, on_close=on_close)220 if CSFSliderTemplateDialog._SELECTED_TEMPLATE is None:221 def _on_acknowledge(_) -> None:222 _on_close()223 CommonOkDialog(224 CSFStringId.NO_TEMPLATE_SELECTED,225 CSFStringId.PLEASE_SELECT_A_TEMPLATE,226 mod_identity=self.mod_identity227 ).show(on_acknowledged=_on_acknowledge)228 return229 option_dialog = CommonChooseObjectOptionDialog(230 CSFStringId.VIEW_TEMPLATE_NAME,231 CSFStringId.VIEW_TEMPLATE_DESCRIPTION,232 mod_identity=self.mod_identity,233 on_close=_on_close,234 per_page=400235 )236 for (slider, amount) in CSFSliderTemplateDialog._SELECTED_TEMPLATE.get_sliders(sim_info):237 slider: CSFSlider = slider238 option_dialog.add_option(239 CommonDialogObjectOption(240 slider.unique_identifier,241 slider,242 CommonDialogOptionContext(243 0,244 CSFStringId.STRING_PLUS_STRING,245 description_tokens=(slider.display_name, str(amount),),246 icon=CommonIconUtils.load_arrow_right_icon(),247 is_enabled=False248 ),249 on_chosen=lambda *_, **__: _reopen()250 )251 )252 if not option_dialog.has_options():253 def _on_acknowledge(_) -> None:254 _on_close()255 CommonOkDialog(256 CSFStringId.NO_SLIDERS_DETECTED_NAME,257 CSFStringId.NO_SLIDERS_DETECTED_DESCRIPTION,258 mod_identity=self.mod_identity259 ).show(on_acknowledged=_on_acknowledge)260 return261 option_dialog.show(262 sim_info=sim_info...

Full Screen

Full Screen

websocket_transport.py

Source:websocket_transport.py Github

copy

Full Screen

...129 self.logger.debug(close_status_code)130 self.logger.debug(close_reason)131 self.state = ConnectionState.disconnected132 if self._on_close is not None and callable(self._on_close):133 self._on_close()134 if callback is not None and callable(callback):135 callback()136 def on_reconnect(self):137 self.logger.debug("-- web socket reconnecting --")138 self.state = ConnectionState.disconnected139 if self._on_close is not None and callable(self._on_close):140 self._on_close()141 def on_socket_error(self, app, error):142 """143 Args:144 _: Required to support websocket-client version equal or greater than 0.58.0145 error ([type]): [description]146 Raises:147 HubError: [description]148 """149 self.logger.debug("-- web socket error --")150 self.logger.error(traceback.format_exc(10, True))151 self.logger.error("{0} {1}".format(self, error))152 self.logger.error("{0} {1}".format(error, type(error)))153 self._on_close()154 self.state = ConnectionState.disconnected155 #raise HubError(error)156 def on_message(self, app, raw_message):157 self.logger.debug("Message received{0}".format(raw_message))158 if not self.handshake_received:159 messages = self.evaluate_handshake(raw_message)160 if self._on_open is not None and callable(self._on_open):161 self.state = ConnectionState.connected162 self._on_open()163 if len(messages) > 0:164 return self._on_message(messages)165 return []166 167 return self._on_message(168 self.protocol.parse_messages(raw_message))169 def send(self, message):170 self.logger.debug("Sending message {0}".format(message))171 try:172 self._ws.send(173 self.protocol.encode(message),174 opcode=0x2175 if type(self.protocol) == MessagePackHubProtocol else176 0x1)177 self.connection_checker.last_message = time.time()178 if self.reconnection_handler is not None:179 self.reconnection_handler.reset()180 except (181 websocket._exceptions.WebSocketConnectionClosedException,182 OSError) as ex:183 self.handshake_received = False184 self.logger.warning("Connection closed {0}".format(ex))185 self.state = ConnectionState.disconnected186 if self.reconnection_handler is None:187 if self._on_close is not None and\188 callable(self._on_close):189 self._on_close()190 raise ValueError(str(ex))191 # Connection closed192 self.handle_reconnect()193 except Exception as ex:194 raise ex195 def handle_reconnect(self):196 if not self.reconnection_handler.reconnecting and self._on_reconnect is not None and \197 callable(self._on_reconnect):198 self._on_reconnect()199 self.reconnection_handler.reconnecting = True200 try:201 self.stop()202 self.start()203 except Exception as ex:...

Full Screen

Full Screen

_base_dialog.py

Source:_base_dialog.py Github

copy

Full Screen

...54 self._wnd.Bind(wx.EVT_BUTTON, self._on_close, id=wx.ID_CLOSE)55 self._wnd.Bind(wx.EVT_BUTTON, self._on_save, id=wx.ID_SAVE)56 self._wnd.Bind(wx.EVT_BUTTON, self._on_ok, id=wx.ID_OK)57 self._wnd.Bind(wx.EVT_BUTTON, self._on_close, id=wx.ID_CANCEL)58 def _on_close(self, _event):59 if self._save_pos:60 self._appconfig.set(self._name, 'size', self._wnd.GetSizeTuple())61 self._appconfig.set(self._name, 'position', self._wnd.GetPositionTuple())62 self._wnd.EndModal(wx.ID_CLOSE)63 def _on_ok(self, _evt):64 self._wnd.EndModal(wx.ID_OK)65 def _on_save(self, evt):...

Full Screen

Full Screen

Playwright tutorial

LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.

Chapters:

  1. What is Playwright : Playwright is comparatively new but has gained good popularity. Get to know some history of the Playwright with some interesting facts connected with it.
  2. How To Install Playwright : Learn in detail about what basic configuration and dependencies are required for installing Playwright and run a test. Get a step-by-step direction for installing the Playwright automation framework.
  3. Playwright Futuristic Features: Launched in 2020, Playwright gained huge popularity quickly because of some obliging features such as Playwright Test Generator and Inspector, Playwright Reporter, Playwright auto-waiting mechanism and etc. Read up on those features to master Playwright testing.
  4. What is Component Testing: Component testing in Playwright is a unique feature that allows a tester to test a single component of a web application without integrating them with other elements. Learn how to perform Component testing on the Playwright automation framework.
  5. Inputs And Buttons In Playwright: Every website has Input boxes and buttons; learn about testing inputs and buttons with different scenarios and examples.
  6. Functions and Selectors in Playwright: Learn how to launch the Chromium browser with Playwright. Also, gain a better understanding of some important functions like “BrowserContext,” which allows you to run multiple browser sessions, and “newPage” which interacts with a page.
  7. Handling Alerts and Dropdowns in Playwright : Playwright interact with different types of alerts and pop-ups, such as simple, confirmation, and prompt, and different types of dropdowns, such as single selector and multi-selector get your hands-on with handling alerts and dropdown in Playright testing.
  8. Playwright vs Puppeteer: Get to know about the difference between two testing frameworks and how they are different than one another, which browsers they support, and what features they provide.
  9. Run Playwright Tests on LambdaTest: Playwright testing with LambdaTest leverages test performance to the utmost. You can run multiple Playwright tests in Parallel with the LammbdaTest test cloud. Get a step-by-step guide to run your Playwright test on the LambdaTest platform.
  10. Playwright Python Tutorial: Playwright automation framework support all major languages such as Python, JavaScript, TypeScript, .NET and etc. However, there are various advantages to Python end-to-end testing with Playwright because of its versatile utility. Get the hang of Playwright python testing with this chapter.
  11. Playwright End To End Testing Tutorial: Get your hands on with Playwright end-to-end testing and learn to use some exciting features such as TraceViewer, Debugging, Networking, Component testing, Visual testing, and many more.
  12. Playwright Video Tutorial: Watch the video tutorials on Playwright testing from experts and get a consecutive in-depth explanation of Playwright automation testing.

Run Playwright Python automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful