Debian Codegraph @

test/selenium/webdriver/safari/launcher_tests.py

raw symbols SCIP
1 # Licensed to the Software Freedom Conservancy (SFC) under one
2 # or more contributor license agreements. See the NOTICE file
3 # distributed with this work for additional information
4 # regarding copyright ownership. The SFC licenses this file
5 # to you under the Apache License, Version 2.0 (the
6 # "License"); you may not use this file except in compliance
7 # with the License. You may obtain a copy of the License at
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing,
12 # software distributed under the License is distributed on an
13 # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 # KIND, either express or implied. See the License for the
15 # specific language governing permissions and limitations
16 # under the License.
17
18 import os
19
20 import pytest
21
22 from selenium.common.exceptions import NoSuchDriverException
23 from selenium.webdriver.safari.service import Service
24
25
26 def test_launch(driver):
27 assert driver.capabilities["browserName"] == "Safari"
28
29
30 def test_launch_with_invalid_executable_path_raises_exception(driver_class):
31 path = "/this/path/should/never/exist"
32 assert not os.path.exists(path)
33 service = Service(executable_path=path)
34 with pytest.raises(NoSuchDriverException):
35 driver_class(service=service)
36
37
38 @pytest.mark.skipif(
39 not os.path.exists("/Applications/Safari Technology Preview.app/Contents/MacOS/safaridriver"),
40 reason="Preview not installed",
41 )
42 class TestTechnologyPreview:
43 @pytest.fixture
44 def driver_kwargs(self):
45 path = "/Applications/Safari Technology Preview.app/Contents/MacOS/safaridriver"
46 assert os.path.exists(
47 path
48 ), "Safari Technology Preview required! Download it from https://developer.apple.com/safari/technology-preview/"
49 return {"executable_path": path}
50
51 def test_launch(self, driver):
52 assert driver.capabilities["browserName"] == "safari"
53
54
55 def test_launch_safari_with_legacy_flag(mocker, driver_class):
56 import subprocess
57
58 mocker.patch("subprocess.Popen")
59 try:
60 driver_class(service_args=["--legacy"])
61 except Exception:
62 pass
63 args, kwargs = subprocess.Popen.call_args
64 assert "--legacy" in args[0]
65
66
67 def test_launch_safari_without_legacy_flag(mocker, driver_class):
68 import subprocess
69
70 mocker.patch("subprocess.Popen")
71 try:
72 driver_class()
73 except Exception:
74 pass
75 args, kwargs = subprocess.Popen.call_args
76 assert "--legacy" not in args[0]