MCPcopy Index your code
hub / github.com/microsoft/playwright-python / register

Method register

playwright/_impl/_selectors.py:33–57  ·  view source on GitHub ↗
(
        self,
        name: str,
        script: str = None,
        path: Union[str, Path] = None,
        contentScript: bool = None,
    )

Source from the content-addressed store, hash-verified

31 self._test_id_attribute_name: Optional[str] = None
32
33 async def register(
34 self,
35 name: str,
36 script: str = None,
37 path: Union[str, Path] = None,
38 contentScript: bool = None,
39 ) -> None:
40 if any(engine for engine in self._selector_engines if engine["name"] == name):
41 raise Error(
42 f'Selectors.register: "{name}" selector engine has been already registered'
43 )
44 if not script and not path:
45 raise Error("Either source or path should be specified")
46 if path:
47 script = (await async_readfile(path)).decode()
48 engine: Dict[str, Any] = dict(name=name, source=script)
49 if contentScript:
50 engine["contentScript"] = contentScript
51 for context in self._contexts_for_selectors:
52 await context._channel.send(
53 "registerSelectorEngine",
54 None,
55 {"selectorEngine": engine},
56 )
57 self._selector_engines.append(engine)
58
59 def set_test_id_attribute(self, attributeName: str) -> None:
60 set_test_id_attribute_name(attributeName)

Calls 4

ErrorClass · 0.90
async_readfileFunction · 0.90
appendMethod · 0.80
sendMethod · 0.45