Path: blob/trunk/py/test/selenium/webdriver/safari/launcher_tests.py
1865 views
# Licensed to the Software Freedom Conservancy (SFC) under one1# or more contributor license agreements. See the NOTICE file2# distributed with this work for additional information3# regarding copyright ownership. The SFC licenses this file4# to you under the Apache License, Version 2.0 (the5# "License"); you may not use this file except in compliance6# with the License. You may obtain a copy of the License at7#8# http://www.apache.org/licenses/LICENSE-2.09#10# Unless required by applicable law or agreed to in writing,11# software distributed under the License is distributed on an12# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY13# KIND, either express or implied. See the License for the14# specific language governing permissions and limitations15# under the License.1617import os1819import pytest2021from selenium.common.exceptions import NoSuchDriverException22from selenium.webdriver.safari.service import Service232425def test_launch(driver):26assert driver.capabilities["browserName"] == "Safari"272829def test_launch_with_invalid_executable_path_raises_exception(driver_class):30path = "/this/path/should/never/exist"31assert not os.path.exists(path)32service = Service(executable_path=path)33with pytest.raises(NoSuchDriverException):34driver_class(service=service)353637@pytest.mark.skipif(38not os.path.exists("/Applications/Safari Technology Preview.app/Contents/MacOS/safaridriver"),39reason="Preview not installed",40)41class TestTechnologyPreview:42@pytest.fixture43def driver_kwargs(self):44path = "/Applications/Safari Technology Preview.app/Contents/MacOS/safaridriver"45assert os.path.exists(path), (46"Safari Technology Preview required! Download it from https://developer.apple.com/safari/technology-preview/"47)48return {"executable_path": path}4950def test_launch(self, driver):51assert driver.capabilities["browserName"] == "safari"525354@pytest.mark.skip(reason="Need to be updated")55def test_launch_safari_with_legacy_flag(mocker, driver_class):56import subprocess5758mocker.patch("subprocess.Popen")59try:60driver_class(service_args=["--legacy"])61except Exception:62pass63args, kwargs = subprocess.Popen.call_args64assert "--legacy" in args[0]656667def test_launch_safari_without_legacy_flag(mocker, driver_class):68import subprocess6970mocker.patch("subprocess.Popen")71try:72driver_class()73except Exception:74pass75args, kwargs = subprocess.Popen.call_args76assert "--legacy" not in args[0]777879