Skip to content

Commit a51ddee

Browse files
committed
[py] allow using enable_bidi property on options class
enable_bidi is a boolean property that defaults to False and can be set to True by user web_socket_url is a string property that defaults to None and is set by the remote response
1 parent 89dfe2d commit a51ddee

File tree

2 files changed

+76
-1
lines changed

2 files changed

+76
-1
lines changed

py/selenium/webdriver/common/options.py

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,23 @@ def __init__(self, name):
4444
self.name = name
4545

4646
def __get__(self, obj, cls):
47+
if self.name == "enableBidi":
48+
# whether BiDi is or will be enabled
49+
value = obj._caps.get("webSocketUrl")
50+
return value is True or isinstance(value, str)
51+
if self.name == "webSocketUrl":
52+
# Return socket url or None if not created yet
53+
value = obj._caps.get(self.name)
54+
return None if not isinstance(value, str) else value
4755
if self.name in ("acceptInsecureCerts", "strictFileInteractability", "setWindowRect", "se:downloadsEnabled"):
4856
return obj._caps.get(self.name, False)
4957
return obj._caps.get(self.name)
5058

5159
def __set__(self, obj, value):
52-
obj.set_capability(self.name, value)
60+
if self.name == "enableBidi":
61+
obj.set_capability("webSocketUrl", value)
62+
else:
63+
obj.set_capability(self.name, value)
5364

5465

5566
class _PageLoadStrategyDescriptor:
@@ -249,6 +260,50 @@ class BaseOptions(metaclass=ABCMeta):
249260
- `None`
250261
"""
251262

263+
enable_bidi = _BaseOptionsDescriptor("enableBidi")
264+
"""Gets and Set whether the session has WebDriverBiDi enabled.
265+
266+
Usage
267+
-----
268+
- Get
269+
- `self.enable_bidi`
270+
- Set
271+
- `self.enable_bidi` = `value`
272+
273+
Parameters
274+
----------
275+
`value`: `bool`
276+
277+
Returns
278+
-------
279+
- Get
280+
- `bool`
281+
- Set
282+
- `None`
283+
"""
284+
285+
web_socket_url = _BaseOptionsDescriptor("webSocketUrl")
286+
"""Gets and Set whether the session accepts insecure certificates.
287+
288+
Usage
289+
-----
290+
- Get
291+
- `self.web_socket_url`
292+
- Set
293+
- `self.web_socket_url` = `value`
294+
295+
Parameters
296+
----------
297+
`value`: `str`
298+
299+
Returns
300+
-------
301+
- Get
302+
- `str` or `None`
303+
- Set
304+
- `None`
305+
"""
306+
252307
page_load_strategy = _PageLoadStrategyDescriptor("pageLoadStrategy")
253308
""":Gets and Sets page load strategy, the default is "normal".
254309

py/test/unit/selenium/webdriver/common/common_options_tests.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,23 @@ def test_add_proxy():
7575

7676
assert options.proxy == proxy
7777
assert caps.get("proxy") == proxy.to_capabilities()
78+
79+
80+
def test_default_bidi():
81+
options = ArgOptions()
82+
assert options.enable_bidi is False
83+
assert options.web_socket_url is None
84+
85+
86+
def test_enable_bidi():
87+
options = ArgOptions()
88+
options.enable_bidi = True
89+
assert options.enable_bidi is True
90+
assert options.web_socket_url is None
91+
92+
93+
def test_set_socket_url():
94+
options = ArgOptions()
95+
options.web_socket_url = 'socket_url'
96+
assert options.enable_bidi is True
97+
assert options.web_socket_url is 'socket_url'

0 commit comments

Comments
 (0)