Skip to content

Commit 6b01d35

Browse files
authored
[py]: Deprecate opera webdriver & options in prep for removal in 4.3 (#10625)
1 parent 1f2be3a commit 6b01d35

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

‎py/selenium/webdriver/opera/options.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
# KIND, either express or implied. See the License for the
1515
# specific language governing permissions and limitations
1616
# under the License.
17+
import warnings
1718

1819
from selenium.webdriver.chrome.options import Options as ChromeOptions
1920
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
@@ -23,7 +24,10 @@ class Options(ChromeOptions):
2324
KEY = "operaOptions"
2425

2526
def __init__(self):
26-
ChromeOptions.__init__(self)
27+
warnings.warn(f"{self.__class__} is deprecated and will be removed in 4.3; "
28+
f"see: https://www.selenium.dev/documentation/webdriver/getting_started/open_browser/#opera",
29+
DeprecationWarning, stacklevel=2)
30+
super().__init__()
2731
self._android_package_name = ''
2832
self._android_device_socket = ''
2933
self._android_command_line_file = ''
@@ -105,5 +109,5 @@ def default_capabilities(self):
105109
class AndroidOptions(Options):
106110

107111
def __init__(self):
108-
Options.__init__(self)
112+
super().__init__()
109113
self.android_package_name = 'com.opera.browser'

‎py/selenium/webdriver/opera/webdriver.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
# KIND, either express or implied. See the License for the
1515
# specific language governing permissions and limitations
1616
# under the License.
17+
import warnings
18+
1719
from selenium.webdriver.chrome.webdriver import WebDriver as ChromiumDriver
1820
from .options import Options
1921

@@ -42,6 +44,9 @@ def __init__(self, executable_path=None, port=0,
4244
- service_log_path - Where to log information from the driver.
4345
capabilities only, such as "proxy" or "loggingPref".
4446
"""
47+
warnings.warn(f"{self.__class__} is deprecated and will be removed in 4.3; "
48+
f"see: https://www.selenium.dev/documentation/webdriver/getting_started/open_browser/#opera",
49+
DeprecationWarning, stacklevel=2)
4550
executable_path = (executable_path if executable_path else "operadriver")
4651
ChromiumDriver.__init__(self,
4752
executable_path=executable_path,

‎py/test/unit/selenium/webdriver/opera/opera_options_tests.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,11 @@ def test_starts_with_default_capabilities(options):
8787
def test_is_a_baseoptions(options):
8888
from selenium.webdriver.common.options import BaseOptions
8989
assert isinstance(options, BaseOptions)
90+
91+
92+
def test_opera_options_is_deprecated(options):
93+
with pytest.warns(DeprecationWarning) as captured:
94+
Options()
95+
expected = "<class 'selenium.webdriver.opera.options.Options'> is deprecated and will be removed in 4.3; " \
96+
"see: https://www.selenium.dev/documentation/webdriver/getting_started/open_browser/#opera"
97+
assert captured[0].message.args[0] == expected

0 commit comments

Comments
 (0)