Skip to content

Commit 5fd073d

Browse files
[py] add warning if people set w3c to false as it may break their tests
1 parent 24a9c50 commit 5fd073d

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

py/selenium/webdriver/chromium/options.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import base64
1919
import os
20+
import warnings
2021
from typing import List, NoReturn, Union
2122

2223
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
@@ -129,6 +130,8 @@ def add_experimental_option(self, name: str, value: Union[str, int, dict, List[s
129130
name: The experimental option name.
130131
value: The option value.
131132
"""
133+
if name.lower() == "w3c" and (value == "false" or value == False):
134+
warnings.warn(UserWarning("Manipulating `w3c` setting can have unintended consequences."))
132135
self._experimental_options[name] = value
133136

134137
@property

py/test/unit/selenium/webdriver/chrome/chrome_options_tests.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,3 +161,8 @@ def test_enables_chrome_mobile(options):
161161
options.enable_mobile()
162162
result_caps = options.to_capabilities()
163163
assert result_caps["goog:chromeOptions"]["androidPackage"] == "com.android.chrome"
164+
165+
166+
def test_set_w3c_false(options):
167+
with pytest.warns(UserWarning):
168+
options.add_experimental_option("w3c", False)

0 commit comments

Comments
 (0)