Skip to content

Commit

Permalink
[py]: Deprecate opera webdriver & options in prep for removal in `4…
Browse files Browse the repository at this point in the history
  • Loading branch information
symonk authored May 10, 2022
1 parent 1f2be3a commit 6b01d35
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
8 changes: 6 additions & 2 deletions py/selenium/webdriver/opera/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
import warnings

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

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

def __init__(self):
Options.__init__(self)
super().__init__()
self.android_package_name = 'com.opera.browser'
5 changes: 5 additions & 0 deletions py/selenium/webdriver/opera/webdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
import warnings

from selenium.webdriver.chrome.webdriver import WebDriver as ChromiumDriver
from .options import Options

Expand Down Expand Up @@ -42,6 +44,9 @@ def __init__(self, executable_path=None, port=0,
- service_log_path - Where to log information from the driver.
capabilities only, such as "proxy" or "loggingPref".
"""
warnings.warn(f"{self.__class__} is deprecated and will be removed in 4.3; "
f"see: https://www.selenium.dev/documentation/webdriver/getting_started/open_browser/#opera",
DeprecationWarning, stacklevel=2)
executable_path = (executable_path if executable_path else "operadriver")
ChromiumDriver.__init__(self,
executable_path=executable_path,
Expand Down
8 changes: 8 additions & 0 deletions py/test/unit/selenium/webdriver/opera/opera_options_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,11 @@ def test_starts_with_default_capabilities(options):
def test_is_a_baseoptions(options):
from selenium.webdriver.common.options import BaseOptions
assert isinstance(options, BaseOptions)


def test_opera_options_is_deprecated(options):
with pytest.warns(DeprecationWarning) as captured:
Options()
expected = "<class 'selenium.webdriver.opera.options.Options'> is deprecated and will be removed in 4.3; " \
"see: https://www.selenium.dev/documentation/webdriver/getting_started/open_browser/#opera"
assert captured[0].message.args[0] == expected

0 comments on commit 6b01d35

Please sign in to comment.