MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / PinnedScript

Class PinnedScript

py/selenium/webdriver/remote/script.py:159–198  ·  view source on GitHub ↗

Identifier of a pinned script, as returned by ``driver.script.pin()``. Subclasses ``str`` so existing code that treats the return value of ``pin()`` as a plain script ID string keeps working. Pass it to ``driver.script.execute()`` to run code with the pinned source in scope, and to

Source from the content-addressed store, hash-verified

157
158
159class PinnedScript(str):
160 """Identifier of a pinned script, as returned by ``driver.script.pin()``.
161
162 Subclasses ``str`` so existing code that treats the return value of
163 ``pin()`` as a plain script ID string keeps working. Pass it to
164 ``driver.script.execute()`` to run code with the pinned source in scope,
165 and to ``driver.script.unpin()`` to remove it.
166 """
167
168 _source: str | None
169 _realm: str | None
170
171 def __new__(cls, script_id: str, source: str | None = None, realm: str | None = None):
172 instance = super().__new__(cls, script_id)
173 instance._source = source
174 instance._realm = realm
175 return instance
176
177 @property
178 def id(self) -> str:
179 """The unique identifier of the pinned script."""
180 return str(self)
181
182 @property
183 def source(self) -> str | None:
184 """The JavaScript source the script was pinned with."""
185 return self._source
186
187 @property
188 def realm(self) -> str | None:
189 """Deprecated: an implementation detail that is never populated by ``pin()``."""
190 warnings.warn(
191 "PinnedScript.realm is deprecated and will be removed; it is an implementation detail",
192 DeprecationWarning,
193 stacklevel=2,
194 )
195 return self._realm
196
197 def __repr__(self) -> str:
198 return f"PinnedScript(id={str.__repr__(self)})"
199
200
201def serialize_argument(value: Any) -> Any:

Calls

no outgoing calls