-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
Description
Description
related to: #16601 and w3c/webdriver-bidi#1039
see: https://w3c.github.io/webdriver-bidi/#command-browsingContext-setViewport
The BiDi spec allows you to reset the viewport size and device pixel ratio by sending "viewport": null or "devicePixelRatio": null. Currently, there is no way to do this in Python.
To handle this case, we should update the set_viewport method in py/selenium/webdriver/common/bidi/browsing_context.py
If the method is called with no viewport argument, the behavior should remain the same (don't set the viewport key). However, if it is called with viewport explicitly set to None (i.e. set_viewport(viewport=None) we should set the dictionary entry to params["viewport"] = None, so when it gets serialized, it sends "viewport": null in the JSON payload.
If the method is called with no device_pixel_ratio argument, the behavior should remain the same (don't set the viewport key). However, if it is called with device pixel ratio explicitly set to None (i.e. set_viewport(device_pixel_ratio=None) we should set the dictionary entry to params["devicePixelRatio"] = None, so when it gets serialized, it sends "devicePixelRatio": null in the JSON payload.
Note: make sure to document this behavior in the docstring and add tests.
Reproducible Code
set_viewport(viewport=None, device_pixel_ratio=None)