Best Python code snippet using playwright-python
__init__.py
Source:__init__.py  
...76    YANG Description: Enclosing container 77    """78    return self.__selectors79      80  def _set_selectors(self, v, load=False):81    """82    Setter method for selectors, mapped from YANG variable /system/logging/console/selectors (container)83    If this variable is read-only (config: false) in the84    source YANG file, then _set_selectors is considered as a private85    method. Backends looking to populate this variable should86    do so via calling thisObj._set_selectors() directly.87    YANG Description: Enclosing container 88    """89    if hasattr(v, "_utype"):90      v = v._utype(v)91    try:92      t = YANGDynClass(v,base=selectors.selectors, is_container='container', yang_name="selectors", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/system', defining_module='openconfig-system', yang_type='container', is_config=True)93    except (TypeError, ValueError):94      raise ValueError({95          'error-string': """selectors must be of a type compatible with container""",96          'defined-type': "container",97          'generated-type': """YANGDynClass(base=selectors.selectors, is_container='container', yang_name="selectors", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/system', defining_module='openconfig-system', yang_type='container', is_config=True)""",98        })99    self.__selectors = t100    if hasattr(self, '_set'):101      self._set()102  def _unset_selectors(self):103    self.__selectors = YANGDynClass(base=selectors.selectors, is_container='container', yang_name="selectors", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/system', defining_module='openconfig-system', yang_type='container', is_config=True)104  selectors = __builtin__.property(_get_selectors, _set_selectors)105  _pyangbind_elements = OrderedDict([('selectors', selectors), ])106from . import selectors107class console(PybindBase):108  """109  This class was auto-generated by the PythonClass plugin for PYANG110  from YANG module openconfig-system - based on the path /system/logging/console. Each member element of111  the container is represented as a class variable - with a specific112  YANG type.113  YANG Description: Top-level container for data related to console-based114logging115  """116  __slots__ = ('_path_helper', '_extmethods', '__selectors',)117  _yang_name = 'console'118  _pybind_generated_by = 'container'119  def __init__(self, *args, **kwargs):120    helper = kwargs.pop("path_helper", None)121    if helper is False:122      self._path_helper = False123    elif helper is not None and isinstance(helper, xpathhelper.YANGPathHelper):124      self._path_helper = helper125    elif hasattr(self, "_parent"):126      helper = getattr(self._parent, "_path_helper", False)127      self._path_helper = helper128    else:129      self._path_helper = False130    self._extmethods = False131    self.__selectors = YANGDynClass(base=selectors.selectors, is_container='container', yang_name="selectors", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/system', defining_module='openconfig-system', yang_type='container', is_config=True)132    load = kwargs.pop("load", None)133    if args:134      if len(args) > 1:135        raise TypeError("cannot create a YANG container with >1 argument")136      all_attr = True137      for e in self._pyangbind_elements:138        if not hasattr(args[0], e):139          all_attr = False140          break141      if not all_attr:142        raise ValueError("Supplied object did not have the correct attributes")143      for e in self._pyangbind_elements:144        nobj = getattr(args[0], e)145        if nobj._changed() is False:146          continue147        setmethod = getattr(self, "_set_%s" % e)148        if load is None:149          setmethod(getattr(args[0], e))150        else:151          setmethod(getattr(args[0], e), load=load)152  def _path(self):153    if hasattr(self, "_parent"):154      return self._parent._path()+[self._yang_name]155    else:156      return ['system', 'logging', 'console']157  def _get_selectors(self):158    """159    Getter method for selectors, mapped from YANG variable /system/logging/console/selectors (container)160    YANG Description: Enclosing container 161    """162    return self.__selectors163      164  def _set_selectors(self, v, load=False):165    """166    Setter method for selectors, mapped from YANG variable /system/logging/console/selectors (container)167    If this variable is read-only (config: false) in the168    source YANG file, then _set_selectors is considered as a private169    method. Backends looking to populate this variable should170    do so via calling thisObj._set_selectors() directly.171    YANG Description: Enclosing container 172    """173    if hasattr(v, "_utype"):174      v = v._utype(v)175    try:176      t = YANGDynClass(v,base=selectors.selectors, is_container='container', yang_name="selectors", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/system', defining_module='openconfig-system', yang_type='container', is_config=True)177    except (TypeError, ValueError):178      raise ValueError({179          'error-string': """selectors must be of a type compatible with container""",180          'defined-type': "container",181          'generated-type': """YANGDynClass(base=selectors.selectors, is_container='container', yang_name="selectors", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/system', defining_module='openconfig-system', yang_type='container', is_config=True)""",182        })183    self.__selectors = t184    if hasattr(self, '_set'):185      self._set()186  def _unset_selectors(self):187    self.__selectors = YANGDynClass(base=selectors.selectors, is_container='container', yang_name="selectors", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/system', defining_module='openconfig-system', yang_type='container', is_config=True)188  selectors = __builtin__.property(_get_selectors, _set_selectors)189  _pyangbind_elements = OrderedDict([('selectors', selectors), ])190from . import selectors191class console(PybindBase):192  """193  This class was auto-generated by the PythonClass plugin for PYANG194  from YANG module openconfig-system - based on the path /system/logging/console. Each member element of195  the container is represented as a class variable - with a specific196  YANG type.197  YANG Description: Top-level container for data related to console-based198logging199  """200  __slots__ = ('_path_helper', '_extmethods', '__selectors',)201  _yang_name = 'console'202  _pybind_generated_by = 'container'203  def __init__(self, *args, **kwargs):204    helper = kwargs.pop("path_helper", None)205    if helper is False:206      self._path_helper = False207    elif helper is not None and isinstance(helper, xpathhelper.YANGPathHelper):208      self._path_helper = helper209    elif hasattr(self, "_parent"):210      helper = getattr(self._parent, "_path_helper", False)211      self._path_helper = helper212    else:213      self._path_helper = False214    self._extmethods = False215    self.__selectors = YANGDynClass(base=selectors.selectors, is_container='container', yang_name="selectors", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/system', defining_module='openconfig-system', yang_type='container', is_config=True)216    load = kwargs.pop("load", None)217    if args:218      if len(args) > 1:219        raise TypeError("cannot create a YANG container with >1 argument")220      all_attr = True221      for e in self._pyangbind_elements:222        if not hasattr(args[0], e):223          all_attr = False224          break225      if not all_attr:226        raise ValueError("Supplied object did not have the correct attributes")227      for e in self._pyangbind_elements:228        nobj = getattr(args[0], e)229        if nobj._changed() is False:230          continue231        setmethod = getattr(self, "_set_%s" % e)232        if load is None:233          setmethod(getattr(args[0], e))234        else:235          setmethod(getattr(args[0], e), load=load)236  def _path(self):237    if hasattr(self, "_parent"):238      return self._parent._path()+[self._yang_name]239    else:240      return ['system', 'logging', 'console']241  def _get_selectors(self):242    """243    Getter method for selectors, mapped from YANG variable /system/logging/console/selectors (container)244    YANG Description: Enclosing container 245    """246    return self.__selectors247      248  def _set_selectors(self, v, load=False):249    """250    Setter method for selectors, mapped from YANG variable /system/logging/console/selectors (container)251    If this variable is read-only (config: false) in the252    source YANG file, then _set_selectors is considered as a private253    method. Backends looking to populate this variable should254    do so via calling thisObj._set_selectors() directly.255    YANG Description: Enclosing container 256    """257    if hasattr(v, "_utype"):258      v = v._utype(v)259    try:260      t = YANGDynClass(v,base=selectors.selectors, is_container='container', yang_name="selectors", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/system', defining_module='openconfig-system', yang_type='container', is_config=True)261    except (TypeError, ValueError):262      raise ValueError({263          'error-string': """selectors must be of a type compatible with container""",264          'defined-type': "container",265          'generated-type': """YANGDynClass(base=selectors.selectors, is_container='container', yang_name="selectors", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/system', defining_module='openconfig-system', yang_type='container', is_config=True)""",266        })267    self.__selectors = t268    if hasattr(self, '_set'):..._browser_type.py
Source:_browser_type.py  
...191            playwright_future.cancel()192        if not timeout_future.done():193            timeout_future.cancel()194        playwright: "Playwright" = next(iter(done)).result()195        playwright._set_selectors(self._playwright.selectors)196        self._connection._child_ws_connections.append(connection)197        pre_launched_browser = playwright._initializer.get("preLaunchedBrowser")198        assert pre_launched_browser199        browser = cast(Browser, from_channel(pre_launched_browser))200        browser._should_close_connection_on_close = True201        browser._local_utils = self._playwright._utils202        def handle_transport_close() -> None:203            for context in browser.contexts:204                for page in context.pages:205                    page._on_close()206                context._on_close()207            browser._on_close()208            connection.cleanup()209        transport.once("close", handle_transport_close)...dialogs.py
Source:dialogs.py  
...55                                            QtGui.QDialogButtonBox.Cancel)56        button_box.accepted.connect(self._on_accept)57        button_box.rejected.connect(self._on_reject)58        self.vb_layout_main.addWidget(button_box)59    def _set_selectors(self, index):60        self.flux_col_selector.clear()61        self.disp_col_selector.clear()62        data = self.hdulist[index].data63        if data is not None:64            col_names = data.names65        else:66            col_names = ""67        self.flux_col_selector.addItems(col_names)68        self.disp_col_selector.addItems(col_names)69    def _on_accept(self):70        self.ext = int(self.ext_selector.currentIndex())71        if isinstance(self.hdulist[self.ext], FITS_table):72            flux_ind = self.flux_col_selector.currentIndex()73            disp_ind = self.disp_col_selector.currentIndex()..._playwright.py
Source:_playwright.py  
...54            return self.firefox55        elif value == "webkit":56            return self.webkit57        raise ValueError("Invalid browser " + value)58    def _set_selectors(self, selectors: SelectorsOwner) -> None:59        selectors_owner = from_channel(self._initializer["selectors"])60        self.selectors._remove_channel(selectors_owner)61        self.selectors = selectors62        self.selectors._add_channel(selectors_owner)63    def stop(self) -> None:64        pass65def parse_device_descriptor(dict: Dict) -> Dict:66    return {67        "user_agent": dict["userAgent"],68        "viewport": dict["viewport"],69        "device_scale_factor": dict["deviceScaleFactor"],70        "is_mobile": dict["isMobile"],71        "has_touch": dict["hasTouch"],72    }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.
Get 100 minutes of automation test minutes FREE!!
