How to use parent_frame method in Playwright Python

Best Python code snippet using playwright-python

pages.py

Source:pages.py Github

copy

Full Screen

1"""Provide pages for Command line interface App."""2import functools3import numpy4import six5import urwid6from urwid.compat import with_metaclass7from ..core import PKG_LOGGER, get_client, validate_connection8from ..util import wrap_connection_error9from .widgets import (FormFieldHorizontal, FormFieldHorizontalEdit,10 FormFieldHorizontalPass, TicketCell, TicketColumn)11ZENDESK_LOGO = \12 " `////////////////. :///////////////. \n" + \13 " mNNNNNNNNNNNNNNN- dNNNNNNNNNNNNNm/ \n" + \14 " -mNNNNNNNNNNNNN+ dNNNNNNNNNNNNs` \n" + \15 " .smNNNNNNNNNh- dNNNNNNNNNNh. \n" + \16 " `:+syyso/` :: dNNNNNNNNm/ \n" + \17 " .yN+ dNNNNNNNo` \n" + \18 " +NNN+ dNNNNNh. \n" + \19 " :dNNNN+ dNNNm: \n" + \20 " .yNNNNNN+ dNNo` \n" + \21 " `oNNNNNNNN+ dy. ` \n" + \22 " :mNNNNNNNNN+ - -ohmNNNmho- \n" + \23 " .hNNNNNNNNNNN+ -hNNNNNNNNNNNh- \n" + \24 " `oNNNNNNNNNNNNN+ -NNNNNNNNNNNNNNN- \n" + \25 " /mNNNNNNNNNNNNNN+ yNNNNNNNNNNNNNNNy\ "26class AppElementMixin(with_metaclass(urwid.MetaSuper)):27 """28 Functionality common to app elements.29 - Run `refresh_widgets` whenever `render` or `keypress` is called.30 - Handle events.31 """32 # A mapping of keys to actions (override this).33 key_actions = {}34 def refresh_widgets(self, size):35 pass36 def _mix_render(self, size, focus=False):37 """Wrap super `render` to refresh widgets."""38 PKG_LOGGER.debug('{} rendering, size={} focus={}'.format(39 self.__class__.__name__, size, focus40 ))41 self.refresh_widgets(size)42 def _mix_keypress(self, size, key):43 """Wrap super `keypress` to refresh widgets."""44 PKG_LOGGER.debug('{} keypress, size={} key={}'.format(45 self.__class__.__name__, size, repr(key)46 ))47 # TODO: replace logic with urwid.command_map ?48 if key in self.key_actions:49 getattr(self, '_action_{}'.format(self.key_actions[key]))(50 size, key51 )52 self.refresh_widgets(size)53 def _action_exit(self, *_):54 raise urwid.ExitMainLoop()55 def _get_markup(self, ticket_dict, key, formatter=None):56 formatter = formatter or id57 unformatted = ticket_dict.get(key, '')58 try:59 return formatter(unformatted)60 except UnicodeEncodeError:61 if not isinstance(unformatted, six.text_type):62 unformatted = six.text_type(unformatted)63 unformatted = (unformatted).encode('ascii', errors='ignore')64 return formatter(unformatted)65 def modal_fatal_error(self, message=None, exc=None):66 """Cause a fatal error to be displayed and the program to exit."""67 message = "Error: {}".format(message) if message else "Fatal Error"68 # This could be called from a parent frame or a page.69 parent_frame = getattr(self, 'parent_frame', self)70 if message:71 PKG_LOGGER.critical(message)72 parent_frame.pages['ERROR'].page_title = message73 details = []74 if exc:75 PKG_LOGGER.critical(exc)76 details.insert(0, str(exc))77 details.append("press ctrl-c to exit")78 parent_frame.pages['ERROR'].error_details = "\n\n".join(details)79 parent_frame.set_page('ERROR')80class AppPageMixin(AppElementMixin):81 """Provide the interface for a page within an app."""82 _usage = ""83 _title = ""84 def __init__(self):85 """Wrap super __init__ as per `urwid.MetaClass` spec."""86 assert self.parent_frame87 self.__super.__init__()88 @property89 def page_usage(self):90 """Provide the usage message for this page."""91 return self._usage92 @property93 def page_title(self):94 """Provide the title for this page."""95 return self._title96 @property97 def page_status(self):98 """Provide an optional status line for this page."""99 return ""100class BlankPage(urwid.ListBox, AppPageMixin):101 """A blank app page."""102 def __init__(self, parent_frame, *args, **kwargs):103 """Wrap super `__init__` with extra metadata."""104 self.parent_frame = parent_frame105 self.__super.__init__(urwid.SimpleListWalker([]))106def mix_render_keypress(cls):107 """108 Shorthand for adding these methods into sublasses multiple times.109 Since each subclass of `AppElementMixin` calls the mixin keypress and110 render, this saves lots of redundant code111 """112 def keypress(self, size, key):113 """Wrap super `keypress` and perform actions."""114 # Scroll regardless of if a move was made115 self._mix_keypress(size, key)116 super(cls, self).keypress(size, key)117 def render(self, size, focus=False):118 """Wrap super and mixin `render`s."""119 self._mix_render(size, focus)120 return super(cls, self).render(size, focus)121 cls.keypress = keypress122 cls.render = render123 return cls124@mix_render_keypress125class TicketListPage(urwid.Columns, AppPageMixin):126 """An app page which displays a table of ticket information."""127 _selectable = True128 header_size = 1129 footer_size = 0130 # how quickly the scrolls when paging131 page_speed = 1132 _usage = (133 u"UP / DOWN / PAGE UP / PAGE DOWN scrolls. "134 u"SPACE / ENTER selects. "135 u"F8 exits."136 )137 _title = "Ticket List"138 key_actions = {139 ' ': 'open',140 'enter': 'open',141 'up': 'scroll',142 'down': 'scroll',143 'page up': 'scroll',144 'page down': 'scroll',145 }146 def __init__(self, parent_frame, *args, **kwargs):147 """Wrap super `__init__` with extra metadata."""148 # Cache access to generator to avoid api calls149 self._ticket_cache = []150 # Offset into the generator of the first visible element151 self.offset = 0152 # Index of the highlighted element153 self.index_highlighted = 0154 # Force a space of 1 between columns155 kwargs['dividechars'] = 0156 self.parent_frame = parent_frame157 self._ticket_generator = None158 self.__super.__init__(159 self.initial_column_widgets(), *args, **kwargs160 )161 @property162 def ticket_generator(self):163 """Try and get generator of tickets from API otherwise use cache."""164 if self._ticket_generator is not None:165 return self._ticket_generator166 client = self.parent_frame.client167 cache = client.tickets.cache.mapping['ticket'].cache168 # if we are in offline mode169 if cache.__class__.__name__ != 'TTLCache':170 self._ticket_generator = cache.values().__iter__()171 else:172 self._ticket_generator = wrap_connection_error(173 functools.partial(client.tickets, timeout=5),174 attempting="Connecting to API",175 on_fail=functools.partial(self.modal_fatal_error),176 on_success=functools.partial(177 PKG_LOGGER.info, "Connected to API"178 )179 )180 return self._ticket_generator181 @property182 def next_ticket(self):183 # get before wrap so that we don't wrap twice184 generator = self.ticket_generator185 if generator is None:186 # want to exit getting ticket_generator cleanly in case there187 # was an error that needs to be displayed188 raise StopIteration()189 response = wrap_connection_error(190 injected=functools.partial(next, generator),191 attempting="Making an API request",192 on_fail=functools.partial(self.modal_fatal_error),193 )194 if response is None:195 raise StopIteration()196 return response197 @property198 def nonbody_overhead(self):199 """Rows taken up by the header and footer."""200 return self.header_size + self.footer_size201 @AppPageMixin.page_status.getter202 def page_status(self):203 """Provide the status message for this page."""204 # TODO: paging progress ("X - Y of Z")205 return ""206 def initial_column_widgets(self):207 """208 Generate the initial list of column widgets.209 Widget size is not known until render time, so no ticket entries are210 added to the widget list initially.211 """212 # First column is a selection indicator213 widget_list = [214 ('fixed', 1, TicketColumn(215 header=urwid.Divider(),216 body=urwid.Divider(),217 key='_selected'218 ))219 ]220 # Other widget columns show ticket data221 for key, meta in self.parent_frame.column_meta.items():222 if 'list_view' in meta and not meta['list_view']:223 continue224 title = meta.get('title', key.title())225 column_widget = TicketColumn(226 header=TicketCell(title),227 body=urwid.ListBox(urwid.SimpleListWalker([])),228 key=key229 )230 if 'sizing' in meta:231 column_widget = tuple(meta['sizing'] + [column_widget])232 widget_list.append(column_widget)233 return widget_list234 def get_tickets(self, offset, limit):235 """236 Fetch `limit` tickets from the generator starting at `offset`.237 Prefetch and cache 2 * `limit` tickets from the API.238 Args239 ----240 offset (:obj:`int`): the index of the first ticket required241 limit (:obj:`int`): the number of tickets required242 """243 prefetch_index = 2 * (limit) + offset244 try:245 while self.ticket_generator is not None:246 if prefetch_index < len(self._ticket_cache):247 break248 self._ticket_cache.append(self.next_ticket)249 except StopIteration:250 pass251 return self._ticket_cache[offset:offset + limit]252 def _get_cell_widgets(self, key, visible_tickets, index_highlighted):253 meta = self.parent_frame.column_meta.get(key, {})254 formatter = meta.get('formatter', str)255 cell_kwargs = {256 'align': meta.get('align', urwid.LEFT)257 }258 cell_widgets = []259 for index, ticket in enumerate(visible_tickets):260 cell_kwargs['markup'] = self._get_markup(261 ticket.to_dict(), key, formatter262 )263 if key == '_selected' and index == index_highlighted:264 cell_kwargs['markup'] = '>'265 cell_widget = TicketCell(**cell_kwargs)266 if index == index_highlighted:267 cell_widget = urwid.AttrWrap(cell_widget, 'important')268 cell_widgets.append(cell_widget)269 return cell_widgets270 def refresh_widgets(self, size):271 """272 Populate frame body of each column with visible tickets.273 Args274 ----275 size (:obj:`tuple` of :obj:`int`): The allowed size of the widget276 """277 PKG_LOGGER.debug('refreshing, size={}'.format(size))278 self._action_scroll(size)279 _, maxcol = size280 visible_tickets = self.get_tickets(281 self.offset, maxcol - self.nonbody_overhead282 )283 index_highlighted = numpy.clip(284 self.index_highlighted,285 0,286 min(maxcol - self.nonbody_overhead, len(visible_tickets)) - 1287 )288 for column, _ in self.contents:289 cell_widgets = self._get_cell_widgets(290 column.key, visible_tickets, index_highlighted291 )292 # TODO: test for memory leaks293 column.body = urwid.ListBox(urwid.SimpleListWalker(cell_widgets))294 def _action_scroll(self, size, key=None):295 """296 Move highlighted index by `movement`, scroll `offset` at boundaries.297 Even if movement is 0 it is useful to refresh these values since the298 widget can be resized.299 """300 PKG_LOGGER.debug('scrolling, size={} key={}'.format(301 size, key302 ))303 _, maxcol = size304 # Map key value to scroll movement amount305 page_jump = int(self.page_speed * (maxcol - self.nonbody_overhead))306 key_movements = {307 'up': -1,308 'down': 1,309 'page up': -page_jump,310 'page down': page_jump311 }312 movement = key_movements.get(key, 0)313 # move highlighted index until boundaries314 can_move_to = numpy.clip(315 self.index_highlighted + movement,316 0,317 maxcol - self.nonbody_overhead - 1318 )319 # determine remaining movement to potentially move the offset320 movement = movement - (can_move_to - self.index_highlighted)321 self.index_highlighted = can_move_to322 # offset can't exceed ticket cache323 self.offset = numpy.clip(324 self.offset + movement,325 0,326 max(len(self._ticket_cache) - 1, 0)327 )328 def _action_open(self, *_):329 """Open view of selected ticket."""330 ticket = self._ticket_cache[self.offset + self.index_highlighted]331 PKG_LOGGER.debug('Actioning ticket id={}'.format(ticket))332 self.parent_frame.pages['TICKET_VIEW'].current_ticket = ticket333 self.parent_frame.set_page('TICKET_VIEW')334@mix_render_keypress335class TicketViewPage(urwid.ListBox, AppPageMixin):336 """An app page which displays a single ticket's information."""337 _usage = (338 u"ESC is back. "339 u"F8 exits."340 )341 _title = "Ticket View"342 def __init__(self, parent_frame, *args, **kwargs):343 """Wrap super `__init__` with extra metadata."""344 self.parent_frame = parent_frame345 self.current_ticket = None346 self.__super.__init__(urwid.SimpleListWalker(347 self.initial_row_widgets()348 ))349 def initial_row_widgets(self):350 """Initialize the row widgets to be updated later."""351 widget_list = []352 for key, meta in self.parent_frame.column_meta.items():353 field_label = meta.get('title', key.title())354 field_class = meta.get('field_class', FormFieldHorizontal)355 widget_list.append(field_class(field_label, key=key))356 return widget_list357 def refresh_widgets(self, size):358 """Refresh the row widgets."""359 ticket_dict = {}360 if self.current_ticket:361 ticket_dict = self.current_ticket.to_dict()362 for wg_field in self.body.contents:363 meta = self.parent_frame.column_meta.get(wg_field.key, {})364 _, (wg_field_value, _) = wg_field.contents365 formatter = meta.get('formatter', str)366 markup = self._get_markup(ticket_dict, wg_field.key, formatter)367 if wg_field_value.text != markup:368 wg_field_value.set_text(markup)369@mix_render_keypress370class ErrorPage(urwid.Overlay, AppPageMixin):371 """An app page which displays an error."""372 _usage = (373 u"F8 / ESC exits."374 )375 key_actions = {376 'f8': 'exit',377 'esc': 'exit',378 'ctrl c': 'exit',379 }380 def __init__(self, parent_frame, *args, **kwargs):381 """Wrap super `__init__` with extra metadata."""382 self.parent_frame = parent_frame383 self._title = kwargs.get('error_message', 'Error')384 self.error_details = kwargs.get('error_details', 'An Error occured.')385 self.__super.__init__(386 urwid.AttrWrap(387 urwid.LineBox(388 urwid.ListBox(urwid.SimpleFocusListWalker([389 urwid.Divider(),390 urwid.Text(self.error_details, align='center')391 ])),392 title=self.page_title393 ),394 'header'395 ),396 self.parent_frame.current_page,397 align='center', width=('relative', 50),398 valign='middle', height=('relative', 50),399 min_width=24, min_height=8,400 )401 @AppPageMixin.page_title.setter402 def page_title(self, value):403 self._title = value404 def refresh_widgets(self, *_):405 _, (wg_top, _) = self.contents406 wg_title = wg_top.original_widget.title_widget407 if wg_title.text != self.page_title:408 wg_title.set_text(self.page_title)409 wg_details = wg_top.original_widget.original_widget.body[1]410 if wg_details.text != self.error_details:411 wg_details.set_text(self.error_details)412@mix_render_keypress413class WelcomePage(urwid.Overlay, AppPageMixin):414 _title = "Welcome"415 key_actions = {416 'enter': 'login'417 }418 _usage = (419 u"F8 / ESC exits."420 )421 def __init__(self, parent_frame, *args, **kwargs):422 """Wrap super `__init__` with extra metadata."""423 self.parent_frame = parent_frame424 config = self.parent_frame.config425 self.form_fields = [426 cls(label_text, getattr(config, key, ''), key=key)427 for key, (cls, label_text) in {428 'subdomain': (FormFieldHorizontalEdit, 'Subdomain: '),429 'email': (FormFieldHorizontalEdit, 'Email: '),430 'password': (FormFieldHorizontalPass, 'Password: '),431 }.items()432 ]433 widget_list = [434 urwid.Divider(),435 urwid.Text(ZENDESK_LOGO, align='center'),436 urwid.Divider(),437 ] + self.form_fields + [438 urwid.Divider(),439 urwid.Button(440 "Login", on_press=self._action_login441 )442 ]443 self.__super.__init__(444 urwid.AttrWrap(445 urwid.LineBox(446 urwid.ListBox(urwid.SimpleFocusListWalker(447 widget_list448 )),449 ),450 'column_header'451 ),452 self.parent_frame.current_page,453 align='center', width=('relative', 50),454 valign='middle', height=('relative', 80),455 min_width=24, min_height=8,456 )457 def _action_login(self, *args):458 for wg_field in self.form_fields:459 value = wg_field.get_value_text()460 setattr(461 self.parent_frame.config, wg_field.key, value462 )463 if wg_field.key == 'password':464 value = "*" * len(value)465 PKG_LOGGER.info("updated config[{}] = {}".format(466 wg_field.key, value467 ))468 # The Ticket Viewer should handle the API being unavailable469 wrap_connection_error(470 functools.partial(validate_connection, self.parent_frame.config),471 attempting="Validate connection",472 on_fail=functools.partial(self.modal_fatal_error),473 on_success=functools.partial(474 PKG_LOGGER.info, "Connection validated"475 )476 )477 self.parent_frame.client = wrap_connection_error(478 functools.partial(get_client, self.parent_frame.config),479 attempting="Create client",480 on_fail=functools.partial(self.modal_fatal_error),481 on_success=functools.partial(482 PKG_LOGGER.info, "Client created"483 )484 )485 # if no error screen is showing486 if self.parent_frame.current_page_id == 'WELCOME':...

Full Screen

Full Screen

user.py

Source:user.py Github

copy

Full Screen

...155 if 0 == self.select_table_row(self.avu_table, vm):156 self.logger.info("********** 要分配的虚拟机不存在,测试结束! *********")157 self.send_click_closeAVU()158 self.sleep(1)159 self.driver.switch_to.parent_frame()160 self.sleep(1)161 self.driver.switch_to.parent_frame()162 self.sleep(1)163 self.send_click_closeR()164 return165 self.sleep(1)166 self.allocate_vm_user()167 self.sleep(2)168 result = self.get_element_text(self.avu_result)169 if "成功" in result:170 self.logger.info("********** 为用户分配虚拟机功能测试通过! *********")171 self.sleep(1)172 self.send_click_submitR()173 self.sleep(1)174 self.driver.switch_to.parent_frame()175 self.sleep(1)176 self.driver.switch_to.parent_frame()177 self.sleep(1)178 self.send_click_closeR()179 else:180 self.logger.info("为用户分配虚拟机功能测试失败,失败原因:%s" % result)181 self.sleep(1)182 self.send_click_submitR()183 self.sleep(1)184 self.send_click_closeAVU()185 self.sleep(1)186 self.driver.switch_to.parent_frame()187 self.sleep(1)188 self.driver.switch_to.parent_frame()189 self.sleep(1)190 self.send_click_closeR()191# 测试移除分配给用户的虚拟机功能192 def test_remove_vm_user(self, user, vm):193 self.send_click_user()194 self.sleep(1)195 if 0 == self.send_click_allocatevm(self.table, user):196 self.logger.info("********** 要移除虚拟机权限的用户不存在,测试结束! *********")197 return198 self.sleep(1)199 self.driver.switch_to.frame(self.driver.find_element_by_tag_name("iframe"))200 self.sleep(1)201 if 0 == self.select_table_row(self.rvu_table, vm):202 self.logger.info("********** 要移除的虚拟机不存在,测试结束! *********")203 self.send_click_closeRVU()204 self.sleep(1)205 self.driver.switch_to.parent_frame()206 self.sleep(1)207 self.send_click_closeR()208 return209 self.sleep(1)210 self.send_click_removevm()211 self.sleep(1)212 self.remove_vm_user()213 self.sleep(1)214 result = self.get_element_text(self.rvu_result)215 if "成功" in result:216 self.logger.info("********** 移除分配给用户的虚拟机功能测试通过! *********")217 self.sleep(1)218 self.send_click_submitR()219 self.sleep(1)220 self.driver.switch_to.parent_frame()221 self.sleep(1)222 self.send_click_closeR()223 else:224 self.logger.info("移除分配给用户的虚拟机功能测试失败,失败原因:%s" % result)225 self.sleep(1)226 self.send_click_submitR()227 self.sleep(1)228 self.driver.switch_to.parent_frame()229 self.sleep(1)230 self.send_click_closeR()231# 测试为用户组分配虚拟机功能232 def test_allocate_vm_group(self, group, vm):233 self.send_click_group()234 self.sleep(1)235 if 0 == self.send_click_allocatevm(self.table, group):236 self.logger.info("********** 要分配虚拟机权限的用户组不存在,测试结束! *********")237 return238 self.sleep(1)239 self.driver.switch_to.frame(self.driver.find_element_by_tag_name("iframe"))240 self.sleep(1)241 self.send_click_addvm()242 self.sleep(1)243 self.driver.switch_to.frame(self.driver.find_element_by_tag_name("iframe"))244 self.sleep(1)245 if 0 == self.select_table_row(self.avg_table, vm):246 self.logger.info("********** 要分配的虚拟机不存在,测试结束! *********")247 self.send_click_closeAVG()248 self.sleep(1)249 self.driver.switch_to.parent_frame()250 self.sleep(1)251 self.driver.switch_to.parent_frame()252 self.sleep(1)253 self.send_click_closeR()254 return255 self.sleep(1)256 self.allocate_vm_group()257 self.sleep(2)258 result = self.get_element_text(self.avg_result)259 if "成功" in result:260 self.logger.info("********** 为用户组分配虚拟机功能测试通过! *********")261 self.sleep(1)262 self.send_click_submitR()263 self.sleep(1)264 self.driver.switch_to.parent_frame()265 self.sleep(1)266 self.driver.switch_to.parent_frame()267 self.sleep(1)268 self.send_click_closeR()269 else:270 self.logger.info("为用户组分配虚拟机功能测试失败,失败原因:%s" % result)271 self.sleep(1)272 self.send_click_submitR()273 self.sleep(1)274 self.send_click_closeAVG()275 self.sleep(1)276 self.driver.switch_to.parent_frame()277 self.sleep(1)278 self.driver.switch_to.parent_frame()279 self.sleep(1)280 self.send_click_closeR()281# 测试移除分配给用户组的虚拟机功能282 def test_remove_vm_group(self, group, vm):283 self.send_click_group()284 self.sleep(1)285 if 0 == self.send_click_allocatevm(self.table, group):286 self.logger.info("********** 要移除虚拟机权限的用户组不存在,测试结束! *********")287 return288 self.sleep(1)289 self.driver.switch_to.frame(self.driver.find_element_by_tag_name("iframe"))290 self.sleep(1)291 if 0 == self.select_table_row(self.rvg_table, vm):292 self.logger.info("********** 要移除的虚拟机不存在,测试结束! *********")293 self.send_click_closeRVG()294 self.sleep(1)295 self.driver.switch_to.parent_frame()296 self.sleep(1)297 self.send_click_closeR()298 return299 self.sleep(1)300 self.send_click_removevm()301 self.sleep(1)302 self.remove_vm_group()303 self.sleep(1)304 result = self.get_element_text(self.rvg_result)305 if "成功" in result:306 self.logger.info("********** 移除分配给用户组的虚拟机功能测试通过! *********")307 self.sleep(1)308 self.send_click_submitR()309 self.sleep(1)310 self.driver.switch_to.parent_frame()311 self.sleep(1)312 self.send_click_closeR()313 else:314 self.logger.info("移除分配给用户组的虚拟机功能测试失败,失败原因:%s" % result)315 self.sleep(1)316 self.send_click_submitR()317 self.sleep(1)318 self.driver.switch_to.parent_frame()319 self.sleep(1)320 self.send_click_closeR()321# 测试为用户组分配用户功能322 def test_allocate_user_group(self, group, user):323 self.send_click_group()324 self.sleep(1)325 if 0 == self.send_click_allocateuser(self.table, group):326 self.logger.info("********** 要分配用户的用户组不存在,测试结束! *********")327 return328 self.sleep(1)329 self.driver.switch_to.frame(self.driver.find_element_by_tag_name("iframe"))330 self.sleep(1)331 self.send_click_adduser()332 self.sleep(1)333 self.driver.switch_to.frame(self.driver.find_element_by_tag_name("iframe"))334 self.sleep(1)335 if 0 == self.select_table_row(self.aug_table, user):336 self.logger.info("********** 要分配的用户不存在,测试结束! *********")337 self.send_click_closeAUG()338 self.sleep(1)339 self.driver.switch_to.parent_frame()340 self.sleep(1)341 self.driver.switch_to.parent_frame()342 self.sleep(1)343 self.send_click_closeR()344 return345 self.sleep(1)346 self.allocate_user_group()347 self.sleep(2)348 result = self.get_element_text(self.aug_result)349 if "成功" in result:350 self.logger.info("********** 为用户组分配虚拟机功能测试通过! *********")351 self.sleep(1)352 self.send_click_submitR()353 self.sleep(1)354 self.driver.switch_to.parent_frame()355 self.sleep(1)356 self.driver.switch_to.parent_frame()357 self.sleep(1)358 self.send_click_closeR()359 else:360 self.logger.info("为用户组分配虚拟机功能测试失败,失败原因:%s" % result)361 self.sleep(1)362 self.send_click_submitR()363 self.sleep(1)364 self.send_click_closeAUG()365 self.sleep(1)366 self.driver.switch_to.parent_frame()367 self.sleep(1)368 self.driver.switch_to.parent_frame()369 self.sleep(1)370 self.send_click_closeR()371# 测试移除分配给用户组的用户372 def test_remove_user_group(self, group, user):373 self.send_click_group()374 self.sleep(1)375 if 0 == self.send_click_allocateuser(self.table, group):376 self.logger.info("********** 要移除用户的用户组不存在,测试结束! *********")377 return378 self.sleep(1)379 self.driver.switch_to.frame(self.driver.find_element_by_tag_name("iframe"))380 self.sleep(1)381 if 0 == self.select_table_row(self.rug_table, user):382 self.logger.info("********** 要移除的用户不存在,测试结束! *********")383 self.send_click_closeRUG()384 self.sleep(1)385 self.driver.switch_to.parent_frame()386 self.sleep(1)387 self.send_click_closeR()388 return389 self.sleep(1)390 self.send_click_removeuser()391 self.sleep(1)392 self.remove_user_group()393 self.sleep(1)394 result = self.get_element_text(self.rug_result)395 if "成功" in result:396 self.logger.info("********** 移除分配给用户组的用户功能测试通过! *********")397 self.sleep(1)398 self.send_click_submitR()399 self.sleep(1)400 self.driver.switch_to.parent_frame()401 self.sleep(1)402 self.send_click_closeR()403 else:404 self.logger.info("移除分配给用户组的用户功能测试失败,失败原因:%s" % result)405 self.sleep(1)406 self.send_click_submitR()407 self.sleep(1)408 self.driver.switch_to.parent_frame()409 self.sleep(1)...

Full Screen

Full Screen

execution.py

Source:execution.py Github

copy

Full Screen

1# Copyright 2019, Offchain Labs, Inc.2# 3# Licensed under the Apache License, Version 2.0 (the "License");4# you may not use this file except in compliance with the License.5# You may obtain a copy of the License at6#7# http://www.apache.org/licenses/LICENSE-2.08#9# Unless required by applicable law or agreed to in writing, software10# distributed under the License is distributed on an "AS IS" BASIS,11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.12# See the License for the specific language governing permissions and13# limitations under the License.14from ..annotation import noreturn, modifies_stack15from .. import std16from . import call_frame17from . import os18from .. import ast19from .. import value20from .types import local_exec_state21@noreturn22def _get_call_location(vm, dispatch_func):23 # contract_id24 dispatch_func(vm)25 vm.dup0()26 vm.tnewn(0)27 vm.eq()28 vm.ifelse(lambda vm: vm.error())29 # call_location30@noreturn31def _perform_call(vm, call_num):32 # destCodePoint destId message33 os.get_chain_state(vm)34 os.chain_state.set_val("scratch")(vm)35 os.set_chain_state(vm)36 vm.push(ast.AVMLabel("evm_call_{}".format(call_num)))37 vm.swap2()38 vm.swap1()39 # contractID message ret_pc destCodePoint40 # setup call frame41 os.get_call_frame(vm)42 call_frame.spawn(vm)43 os.get_chain_state(vm)44 os.chain_state.set_val("call_frame")(vm)45 os.set_chain_state(vm)46 os.add_message_to_wallet(vm)47 _save_call_frame(vm)48 std.stack_manip.compress(vm)49 std.stack_manip.compress_aux(vm)50 # compressed_stack compressed_aux_stack51 os.get_call_frame(vm)52 call_frame.call_frame.get("parent_frame")(vm)53 call_frame.call_frame.set_val("saved_aux_stack")(vm)54 call_frame.call_frame.set_val("saved_stack")(vm)55 os.get_call_frame(vm)56 call_frame.call_frame.set_val("parent_frame")(vm)57 os.get_chain_state(vm)58 os.chain_state.set_val("call_frame")(vm)59 os.set_chain_state(vm)60 # Enter call frame61 os.get_chain_state(vm)62 os.chain_state.get("scratch")(vm)63 vm.jump()64 vm.set_label(ast.AVMLabel("evm_call_{}".format(call_num)))65 vm.auxpush()66 std.stack_manip.kill(vm)67 os.get_call_frame(vm)68 call_frame.call_frame.get("parent_frame")(vm)69 call_frame.call_frame.get("saved_stack")(vm)70 std.stack_manip.uncompress(vm)71 vm.auxpop()72 std.stack_manip.kill_aux(vm)73 os.get_call_frame(vm)74 call_frame.call_frame.get("parent_frame")(vm)75 call_frame.call_frame.get("saved_aux_stack")(vm)76 std.stack_manip.uncompress_aux(vm)77@noreturn78def setup_initial_call(vm, dispatch_func):79 # contractID message80 vm.set_exception_handler(invalid_tx)81 os.get_chain_state(vm)82 os.chain_state.get("contracts")(vm)83 call_frame.new_fresh(vm)84 os.get_chain_state(vm)85 os.chain_state.set_val("call_frame")(vm)86 os.set_chain_state(vm)87 vm.dup0()88 _get_call_location(vm, dispatch_func)89 _perform_call(vm, "initial")90 vm.clear_exception_handler()91 vm.auxpush()92 os.get_call_frame(vm)93 vm.dup0()94 call_frame.call_frame.get("parent_frame")95 call_frame.merge(vm)96 os.get_chain_state(vm)97 os.chain_state.set_val("call_frame")(vm)98 os.set_chain_state(vm)99 os.get_call_frame(vm)100 call_frame.call_frame.get("contracts")(vm)101 os.get_chain_state(vm)102 os.chain_state.set_val("contracts")(vm)103 os.set_chain_state(vm)104 os.get_call_frame(vm)105 call_frame.call_frame.get("sent_queue")(vm)106 os.send_all_in_sent_queue(vm)107 os.get_call_frame(vm)108 call_frame.call_frame.get("parent_frame")(vm)109 call_frame.call_frame.get("return_data")(vm)110 vm.auxpop()111 os.log_func_result(vm)112# [[gas, dest, value, arg offset, arg length, ret offset, ret length]]113@noreturn114def call(vm, dispatch_func, call_num, contract_id):115 std.tup.make(7)(vm)116 vm.dup0()117 os.is_simple_send(vm)118 vm.ifelse(lambda vm: [119 # call sends no gas, has no arguments, and gets no return120 os.evm_call_to_send(vm),121 os.add_send_to_queue(vm)122 ], lambda vm: [123 vm.dup0(),124 vm.tgetn(1),125 vm.push(1),126 vm.eq(),127 vm.ifelse(lambda vm: [128 os.evm_call_to_send(vm),129 vm.dup0(),130 local_exec_state.get("data")(vm),131 vm.push(0),132 vm.swap1(),133 std.sized_byterange.get(vm),134 vm.push(224),135 vm.swap1(),136 std.bitwise.shift_right(vm),137 vm.dup0(),138 vm.push(0xda795ea3),139 vm.eq(),140 vm.ifelse(lambda vm: [141 vm.pop(),142 send_erc20_interupt(vm)143 ], lambda vm: [144 vm.push(0x8e725ee1),145 vm.eq(),146 vm.ifelse(send_erc721_interupt, lambda vm: vm.error())147 ])148 ], lambda vm: [149 _inner_call(vm, dispatch_func, call_num, contract_id)150 ])151 ])152def _send_interupt(vm):153 def get_dest(vm):154 vm.push(4)155 vm.swap1()156 std.sized_byterange.get(vm)157 def get_token_type(vm):158 vm.push(36)159 vm.swap1()160 std.sized_byterange.get(vm)161 def get_token_val(vm):162 vm.push(68)163 vm.swap1()164 std.sized_byterange.get(vm)165 vm.tgetn(0)166 # data167 vm.dup0()168 get_token_val(vm)169 # val data170 vm.dup1()171 get_token_type(vm)172 # type val data173 vm.swap2()174 get_dest(vm)175 # dest val type176 vm.push(local_exec_state.make())177 vm.cast(local_exec_state.typ)178 local_exec_state.set_val("sender")(vm)179 local_exec_state.set_val("amount")(vm)180 local_exec_state.set_val("type")(vm)181def send_erc20_interupt(vm):182 _send_interupt(vm)183 vm.dup0()184 local_exec_state.get("type")(vm)185 vm.push(256)186 vm.mul()187 vm.swap1()188 local_exec_state.set_val("type")(vm)189 os.add_send_to_queue(vm)190def send_erc721_interupt(vm):191 _send_interupt(vm)192 vm.dup0()193 local_exec_state.get("type")(vm)194 vm.push(256)195 vm.mul()196 vm.push(1)197 vm.add()198 vm.swap1()199 local_exec_state.set_val("type")(vm)200 os.add_send_to_queue(vm)201@modifies_stack([value.IntType(), value.TupleType([value.IntType()]*7)], [value.IntType()])202def _mutable_call_ret(vm):203 # ret_type calltup204 translate_ret_type(vm)205 # return_val calltup206 vm.ifelse(lambda vm: [207 os.get_call_frame(vm),208 vm.dup0(),209 call_frame.call_frame.get("parent_frame")(vm),210 call_frame.merge(vm),211 # parent_frame212 os.get_chain_state(vm),213 os.chain_state.set_val("call_frame")(vm),214 os.set_chain_state(vm),215 vm.push(1),216 ], lambda vm: [217 os.get_call_frame(vm),218 call_frame.call_frame.get("parent_frame")(vm),219 os.get_chain_state(vm),220 os.chain_state.set_val("call_frame")(vm),221 os.set_chain_state(vm),222 vm.push(0)223 ])224 vm.swap1()225 os.copy_return_data(vm)226@modifies_stack([], [])227def _save_call_frame(vm):228 os.get_call_frame(vm)229 call_frame.save_state(vm)230 os.get_chain_state(vm)231 os.chain_state.set_val("call_frame")(vm)232 os.set_chain_state(vm)233# [[gas, dest, value, arg offset, arg length, ret offset, ret length]]234@noreturn235def _inner_call(vm, dispatch_func, call_num, contract_id):236 vm.dup0()237 os.evm_call_to_send(vm)238 # msg239 vm.dup0()240 vm.tgetn(1)241 # contractId msg242 vm.swap1()243 vm.push(contract_id)244 vm.swap1()245 vm.tsetn(1)246 vm.swap1()247 # destID msg248 _save_call_frame(vm)249 vm.dup0()250 _get_call_location(vm, dispatch_func)251 _perform_call(vm, call_num)252 _mutable_call_ret(vm)253# [gas, dest, value, arg offset, arg length, ret offset, ret length]254@noreturn255def callcode(vm, dispatch_func, call_num, contract_id):256 std.tup.make(7)(vm)257 # calltup258 vm.dup0()259 os.evm_call_to_send(vm)260 # msg calltup261 vm.dup0()262 vm.tgetn(1)263 _get_call_location(vm, dispatch_func)264 # destCodePoint msg calltup265 vm.swap1()266 vm.push(contract_id)267 vm.swap1()268 vm.tsetn(1)269 # msg destCodePoint calltup270 vm.push(contract_id)271 vm.swap1()272 vm.swap2()273 # destCodePoint destId message calltup274 _save_call_frame(vm)275 _perform_call(vm, call_num)276 _mutable_call_ret(vm)277# [gas, dest, arg offset, arg length, ret offset, ret length]278@noreturn279def delegatecall(vm, dispatch_func, call_num, contract_id):280 os.message_value(vm)281 # value, gas, dest282 vm.swap2()283 vm.swap1()284 # gas, dest, value285 std.tup.make(7)(vm)286 # calltup287 vm.dup0()288 os.evm_call_to_send(vm)289 # msg calltup290 vm.dup0()291 vm.tgetn(1)292 _get_call_location(vm, dispatch_func)293 # destCodePoint msg calltup294 vm.swap1()295 os.message_caller(vm)296 vm.swap1()297 vm.tsetn(1)298 # msg destCodePoint calltup299 vm.push(contract_id)300 vm.swap1()301 vm.swap2()302 # destCodePoint destId message calltup303 _save_call_frame(vm)304 _perform_call(vm, call_num)305 _mutable_call_ret(vm)306# [[gas, dest, value, arg offset, arg length, ret offset, ret length]]307@noreturn308def staticcall(vm, dispatch_func, call_num, contract_id):309 vm.push(0)310 # value, gas, dest311 vm.swap2()312 vm.swap1()313 # gas, dest, value314 std.tup.make(7)(vm)315 # calltup316 vm.dup0()317 os.evm_call_to_send(vm)318 # msg calltup319 vm.dup0()320 vm.tgetn(1)321 # contractId msg calltup322 vm.swap1()323 vm.push(contract_id)324 vm.swap1()325 vm.tsetn(1) # update the sender to this contract326 vm.swap1()327 # contractId msg calltup328 _save_call_frame(vm)329 # contractId msg calltup330 vm.dup0()331 _get_call_location(vm, dispatch_func)332 _perform_call(vm, "static_{}".format(call_num))333 translate_ret_type(vm)334 # ret calltup335 vm.swap1()336 os.get_call_frame(vm)337 call_frame.call_frame.get("parent_frame")(vm)338 os.get_chain_state(vm)339 os.chain_state.set_val("call_frame")(vm)340 os.set_chain_state(vm)341 # calltup ret342 os.copy_return_data(vm)343@noreturn344def selfdestruct(vm):345 os.get_call_frame(vm)346 call_frame.call_frame.get("sent_queue")(vm)347 # send waiting messages348 os.send_all_in_sent_queue(vm)349 vm.pop() # address to transfer all funds to350 vm.halt()351# [offset, length]352@noreturn353def ret(vm):354 vm.dup1()355 vm.swap1()356 os.get_mem_segment(vm)357 std.tup.make(2)(vm)358 # return_data359 os.get_call_frame(vm)360 vm.dup0()361 call_frame.call_frame.get("parent_frame")(vm)362 # parent_frame current_frame return_data363 vm.swap1()364 vm.swap2()365 # return_data parent_frame current_frame366 vm.swap1()367 call_frame.call_frame.set_val("return_data")(vm)368 # parent_frame current_frame369 vm.swap1()370 call_frame.call_frame.set_val("parent_frame")(vm)371 vm.dup0()372 call_frame.call_frame.get("return_location")(vm)373 vm.swap1()374 os.get_chain_state(vm)375 os.chain_state.set_val("call_frame")(vm)376 os.set_chain_state(vm)377 vm.push(2)378 vm.swap1()379 vm.jump()380@noreturn381def stop(vm):382 os.get_call_frame(vm)383 vm.dup0()384 call_frame.call_frame.get("parent_frame")(vm)385 # parent_frame current_frame386 std.sized_byterange.new(vm)387 vm.swap1()388 call_frame.call_frame.set_val("return_data")(vm)389 vm.swap1()390 call_frame.call_frame.set_val("parent_frame")(vm)391 # call_frame392 vm.dup0()393 call_frame.call_frame.get("return_location")(vm)394 # return_location call_frame395 vm.swap1()396 os.get_chain_state(vm)397 os.chain_state.set_val("call_frame")(vm)398 os.set_chain_state(vm)399 vm.push(3)400 vm.swap1()401 vm.jump()402# [memory offset, memory length]403@noreturn404def revert(vm):405 vm.dup1()406 vm.swap1()407 os.get_mem_segment(vm)408 std.tup.make(2)(vm)409 # return_data410 os.get_call_frame(vm)411 vm.dup0()412 call_frame.call_frame.get("parent_frame")(vm)413 # parent_frame current_frame return_data414 vm.swap1()415 vm.swap2()416 # return_data parent_frame current_frame417 vm.swap1()418 call_frame.call_frame.set_val("return_data")(vm)419 # parent_frame current_frame420 vm.swap1()421 call_frame.call_frame.set_val("parent_frame")(vm)422 vm.dup0()423 call_frame.call_frame.get("return_location")(vm)424 vm.swap1()425 os.get_chain_state(vm)426 os.chain_state.set_val("call_frame")(vm)427 os.set_chain_state(vm)428 vm.push(0)429 vm.swap1()430 vm.jump()431# []432@noreturn433def invalid_tx(vm):434 os.get_call_frame(vm)435 vm.dup0()436 call_frame.call_frame.get("parent_frame")(vm)437 # parent_frame current_frame438 std.sized_byterange.new(vm)439 vm.swap1()440 call_frame.call_frame.set_val("return_data")(vm)441 vm.swap1()442 call_frame.call_frame.set_val("parent_frame")(vm)443 # call_frame444 vm.dup0()445 call_frame.call_frame.get("return_location")(vm)446 # return_location call_frame447 vm.swap1()448 os.get_chain_state(vm)449 os.chain_state.set_val("call_frame")(vm)450 os.set_chain_state(vm)451 vm.push(1)452 vm.swap1()453 vm.jump()454@modifies_stack([value.IntType()], [value.IntType()])455def translate_ret_type(vm):456 vm.push(1)...

Full Screen

Full Screen

chose_variables.py

Source:chose_variables.py Github

copy

Full Screen

1from tkinter import *2from views import simulation_view3from constants import constants456class chose_variables:78 WINDOW_WIDTH = 4009 WINDOW_HEIGHT = 2001011 BUTTON_BG = "dark grey"1213 DEFAULT_MAX_CIRCLES = 30014 DEFAULT_CIRCLE_SIZE = 101516 DEFAULT_MIN_SPEED = 117 DEFAULT_MAX_SPEED = 51819 DEFAULT_CHANCE_OF_CHANGING_DIRECTION = 0.0520 DEFAULT_CHANCE_OF_CHANGING_SPEED = 0.32122 DEFAULT_NUMBER_OF_INFECTED_AT_START = 223 DEFAULT_MAX_DISTANCE_FOR_INFECTION = 1024 DEFAULT_MAX_INFECTION_TIME = 1025 DEFAULT_INFECTION_PROBABILITY = 0.52627 DEFAULT_TIME = 602829 entry = []3031 def __init__(self):3233 root = Tk()34 self.setup_root(root)35 self.setup_views(root)36 root.mainloop()373839 def setup_views(self, root):40 self.setup_main_frame_components(root)414243 def setup_root(self, root):44 root.title("Virus Simulator")45 root.configure(background=constants.FRAME_BG)46 self.center_window(root)474849 def center_window(self, root):50 screen_width = root.winfo_screenwidth()51 screen_height = root.winfo_screenheight()52 x_location = int(screen_width/2 - self.WINDOW_WIDTH/2)53 y_location = int(screen_height/2 - self.WINDOW_HEIGHT/2)54 root.geometry('{}x{}+{}+{}'.format(self.WINDOW_WIDTH, self.WINDOW_HEIGHT, x_location, y_location))555657 def setup_main_frame_components(self, root):58 circle_frame = self.setup_circle_components(root)59 infection_frame = self.setup_infection_components(root)6061 circle_frame.pack(side=LEFT, padx=1, pady=10)62 infection_frame.pack(side=RIGHT, padx=1, pady=10)6364 start_button = Button(root, text="Start",bg=constants.FRAME_BG, command=lambda:self.go_to_simulation(root))65 start_button.pack(side=BOTTOM, padx=1, pady=10)66676869 def setup_circle_components(self, root):70 circle_frame = self.create_frame(root, constants.FRAME_BG)71 self.setup_circle_amount_components(circle_frame)72 self.setup_circle_size_components(circle_frame)73 self.setup_circle_min_speed_components(circle_frame)74 self.setup_circle_max_speed_components(circle_frame)75 self.setup_circle_chance_of_changing_direction_components(circle_frame)76 self.setup_circle_chance_of_changing_speed_components(circle_frame)77 return circle_frame787980 def setup_circle_amount_components(self, circle_frame):81 self.max_circles_entry = StringVar(circle_frame, self.DEFAULT_MAX_CIRCLES)82 self.create_frame_for_components(circle_frame,83 "Number of Objects",84 constants.FRAME_BG,85 self.max_circles_entry,86 5,87 NORMAL)888990 def setup_circle_size_components(self, circle_frame):91 self.circle_size_entry = StringVar(circle_frame, self.DEFAULT_CIRCLE_SIZE)92 self.create_frame_for_components(circle_frame,93 "Size of Objects",94 constants.FRAME_BG,95 self.circle_size_entry,96 5,97 NORMAL)9899100 def setup_circle_min_speed_components(self, parent_frame):101 self.min_speed_entry = StringVar(parent_frame, self.DEFAULT_MIN_SPEED)102 self.create_frame_for_components(parent_frame,103 "Minimum speed",104 constants.FRAME_BG,105 self.min_speed_entry,106 5,107 NORMAL)108109110 def setup_circle_max_speed_components(self, parent_frame):111 self.max_speed_entry = StringVar(parent_frame, self.DEFAULT_MAX_SPEED)112 self.create_frame_for_components(parent_frame,113 "Maximum speed",114 constants.FRAME_BG,115 self.max_speed_entry,116 5,117 NORMAL)118119120 def setup_circle_chance_of_changing_direction_components(self, parent_frame):121 self.chance_of_changing_direction_entry = StringVar(parent_frame, self.DEFAULT_CHANCE_OF_CHANGING_DIRECTION)122 self.create_frame_for_components(parent_frame,123 "Direction change probability",124 constants.FRAME_BG,125 self.chance_of_changing_direction_entry,126 5,127 DISABLED)128129130 def setup_circle_chance_of_changing_speed_components(self, parent_frame):131 self.chance_of_changing_speed_entry = StringVar(parent_frame, self.DEFAULT_CHANCE_OF_CHANGING_SPEED)132 self.create_frame_for_components(parent_frame,133 "Speed change probability",134 constants.FRAME_BG,135 self.chance_of_changing_speed_entry,136 5,137 DISABLED)138139140 def setup_infection_components(self, root):141 infection_frame = self.create_frame(root, constants.FRAME_BG)142 self.setup_number_of_infected(infection_frame)143 self.setup_max_distance_for_infection(infection_frame)144 self.setup_max_infection_time(infection_frame)145 self.setup_infection_probability(infection_frame)146 self.setup_time(infection_frame)147 return infection_frame148149150 def setup_number_of_infected(self, parent_frame):151 self.number_of_infected_at_start_entry = StringVar(parent_frame, self.DEFAULT_NUMBER_OF_INFECTED_AT_START)152 self.create_frame_for_components(parent_frame,153 "Infected object at start",154 constants.FRAME_BG,155 self.number_of_infected_at_start_entry,156 5,157 NORMAL)158159160 def setup_max_distance_for_infection(self, parent_frame):161 self.max_distance_for_infection_entry = StringVar(parent_frame, self.DEFAULT_MAX_DISTANCE_FOR_INFECTION)162 self.create_frame_for_components(parent_frame,163 "Infected max distance",164 constants.FRAME_BG,165 self.max_distance_for_infection_entry,166 5,167 NORMAL)168169170 def setup_max_infection_time(self, parent_frame):171 self.max_infection_time_entry = StringVar(parent_frame, self.DEFAULT_MAX_INFECTION_TIME)172 self.create_frame_for_components(parent_frame,173 "Infection time (s)",174 constants.FRAME_BG,175 self.max_infection_time_entry,176 5,177 NORMAL)178179180 def setup_infection_probability(self, parent_frame):181 self.infection_probability_entry = StringVar(parent_frame, self.DEFAULT_INFECTION_PROBABILITY)182 self.create_frame_for_components(parent_frame,183 "Infection probability",184 constants.FRAME_BG,185 self.infection_probability_entry,186 5,187 NORMAL)188189 def setup_time(self, parent_frame):190 self.time_entry = StringVar(parent_frame, self.DEFAULT_TIME)191 self.create_frame_for_components(parent_frame,192 "Time (s)",193 constants.FRAME_BG,194 self.time_entry,195 5,196 NORMAL)197198199 def create_frame_for_components(self, parent_frame, text, bg, entry_reference, entry_size, state):200 new_frame = self.create_label_and_input_frame(parent_frame, text, bg, entry_reference, entry_size, state)201 new_frame.pack()202203204 def create_label_and_input_frame(self, parent_frame, label_text, bg, entry_reference, entry_width, entry_state):205 new_frame = self.create_frame(parent_frame, bg)206 new_frame.pack()207208 new_label = self.create_label(new_frame, label_text, bg)209 new_label.pack(side=LEFT)210211 entry = self.create_entry_box(new_frame, entry_reference, entry_width, state=entry_state)212 entry.pack(side=LEFT)213214 return new_frame215216217 def create_frame(self, parent_frame, bg):218 return Frame(parent_frame, bg=bg)219220221 def create_label(self, parent_frame, text, bg):222 return Label(parent_frame, text=text, bg=bg)223224225 def create_entry_box(self, parent_frame, entry_reference, entry_width, state):226 return Entry(parent_frame, width=entry_width, textvariable=entry_reference, state=state)227228229 def get_entry(self):230 self.entry.append([constants.MAX_CIRCLES_STRING, self.max_circles_entry.get()])231 self.entry.append([constants.CIRCLE_SIZE_STRING, self.circle_size_entry.get()])232 self.entry.append([constants.MIN_SPEED_STRING, self.min_speed_entry.get()])233 self.entry.append([constants.MAX_SPEED_STRING, self.max_speed_entry.get()])234 self.entry.append([constants.CHANCE_OF_CHANGING_DIRECTION_STRING, self.chance_of_changing_direction_entry.get()])235 self.entry.append([constants.CHANCE_OF_CHANGING_SPEED_STRING, self.chance_of_changing_speed_entry.get()])236 self.entry.append([constants.NUMBER_OF_INFECTED_AT_START_STRING, self.number_of_infected_at_start_entry.get()])237 self.entry.append([constants.MAX_DISTANCE_FOR_INFECTION_STRING, self.max_distance_for_infection_entry.get()])238 self.entry.append([constants.MAX_INFECTION_TIME_STRING, self.max_infection_time_entry.get()])239 self.entry.append([constants.INFECTION_PROBABILITY_STRING, self.infection_probability_entry.get()])240 self.entry.append([constants.TIME_STRING, self.time_entry.get()])241242243 def go_to_simulation(self, root):244 root.destroy()245 self.get_entry() ...

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