Skip to content

Commit 100c03b

Browse files
committed
add set_timezone_override command
1 parent 72a925a commit 100c03b

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

py/selenium/webdriver/common/bidi/emulation.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,3 +215,38 @@ def set_geolocation_override(
215215
params["userContexts"] = user_contexts
216216

217217
self.conn.execute(command_builder("emulation.setGeolocationOverride", params))
218+
219+
def set_timezone_override(
220+
self,
221+
timezone: Optional[str] = None,
222+
contexts: Optional[list[str]] = None,
223+
user_contexts: Optional[list[str]] = None,
224+
) -> None:
225+
"""Set timezone override for the given contexts or user contexts.
226+
227+
Parameters:
228+
-----------
229+
timezone: Timezone identifier (IANA timezone name or offset string like '+01:00'),
230+
or None to clear the override.
231+
contexts: List of browsing context IDs to apply the override to.
232+
user_contexts: List of user context IDs to apply the override to.
233+
234+
Raises:
235+
------
236+
ValueError: If both contexts and user_contexts are provided, or if neither
237+
contexts nor user_contexts are provided.
238+
"""
239+
if contexts is not None and user_contexts is not None:
240+
raise ValueError("Cannot specify both contexts and user_contexts")
241+
242+
if contexts is None and user_contexts is None:
243+
raise ValueError("Must specify either contexts or user_contexts")
244+
245+
params: dict[str, Any] = {"timezone": timezone}
246+
247+
if contexts is not None:
248+
params["contexts"] = contexts
249+
elif user_contexts is not None:
250+
params["userContexts"] = user_contexts
251+
252+
self.conn.execute(command_builder("emulation.setTimezoneOverride", params))

0 commit comments

Comments
 (0)