Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions py/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# under the License.

import os
import platform
import sys
from dataclasses import dataclass
from pathlib import Path

Expand Down Expand Up @@ -182,7 +182,14 @@ def driver_class(self, cls_name):

@property
def exe_platform(self):
return platform.system()
if sys.platform == "win32":
return "Windows"
elif sys.platform == "darwin":
return "Darwin"
elif sys.platform == "linux":
return "Linux"
else:
return sys.platform.title()

@property
def browser_path(self):
Expand Down Expand Up @@ -397,7 +404,7 @@ def server(request):
)

remote_env = os.environ.copy()
if platform.system() == "Linux":
if sys.platform == "linux":
# There are issues with window size/position when running Firefox
# under Wayland, so we use XWayland instead.
remote_env["MOZ_ENABLE_WAYLAND"] = "0"
Expand Down
12 changes: 6 additions & 6 deletions py/selenium/webdriver/common/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
import logging
import os
import subprocess
import sys
from abc import ABC, abstractmethod
from collections.abc import Mapping
from io import IOBase
from platform import system
from subprocess import PIPE
from time import sleep
from typing import IO, Any, Optional, Union, cast
Expand Down Expand Up @@ -205,13 +205,13 @@ def _start_process(self, path: str) -> None:
"""
cmd = [path]
cmd.extend(self.command_line_args())
close_file_descriptors = self.popen_kw.pop("close_fds", system() != "Windows")
close_file_descriptors = self.popen_kw.pop("close_fds", sys.platform != "win32")
try:
start_info = None
if system() == "Windows":
start_info = subprocess.STARTUPINFO() # type: ignore[attr-defined]
start_info.dwFlags = subprocess.CREATE_NEW_CONSOLE | subprocess.STARTF_USESHOWWINDOW # type: ignore[attr-defined]
start_info.wShowWindow = subprocess.SW_HIDE # type: ignore[attr-defined]
if sys.platform == "win32":
start_info = subprocess.STARTUPINFO()
start_info.dwFlags = subprocess.CREATE_NEW_CONSOLE | subprocess.STARTF_USESHOWWINDOW
start_info.wShowWindow = subprocess.SW_HIDE

self.process = subprocess.Popen(
cmd,
Expand Down
4 changes: 2 additions & 2 deletions py/selenium/webdriver/firefox/firefox_binary.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@


import os
import sys
import time
from platform import system
from subprocess import DEVNULL, STDOUT, Popen

from typing_extensions import deprecated
Expand All @@ -45,7 +45,7 @@ def __init__(self, firefox_path=None, log_file=None):
# a while the pipe would fill up and Firefox would freeze.
self._log_file = log_file or DEVNULL
self.command_line = None
self.platform = system().lower()
self.platform = sys.platform
if not self._start_cmd:
self._start_cmd = self._get_firefox_start_cmd()
if not self._start_cmd.strip():
Expand Down
4 changes: 2 additions & 2 deletions py/selenium/webdriver/remote/remote_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
# under the License.

import logging
import platform
import string
import sys
import warnings
from base64 import b64encode
from typing import Optional
Expand Down Expand Up @@ -156,7 +156,7 @@ class RemoteConnection:
_ca_certs = os.getenv("REQUESTS_CA_BUNDLE") if "REQUESTS_CA_BUNDLE" in os.environ else certifi.where()
_client_config: Optional[ClientConfig] = None

system = platform.system().lower()
system = sys.platform
if system == "darwin":
system = "mac"

Expand Down
4 changes: 2 additions & 2 deletions py/test/selenium/webdriver/firefox/firefox_sizing_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# under the License.

import os
import platform
import sys
from unittest.mock import patch

import pytest
Expand All @@ -25,7 +25,7 @@


def is_running_wayland():
return platform.system() == "Linux" and os.getenv("WAYLAND_DISPLAY")
return sys.platform == "linux" and os.getenv("WAYLAND_DISPLAY")


@pytest.mark.skipif(not is_running_wayland(), reason="This test only runs on Linux under Wayland")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
import platform
import sys
from os import path

import pytest
Expand Down Expand Up @@ -91,7 +91,7 @@ def test_add_encoded_extension(options):


def test_get_extensions_from_extension_files(options, mocker):
null = "NUL" if platform.system().lower() == "windows" else "/dev/null"
null = "NUL" if sys.platform == "win32" else "/dev/null"
mocker.patch("selenium.webdriver.chromium.options.open").return_value = open(null)
mocker.patch("base64.b64encode").return_value = b"foo"
options._extension_files = ["foo"]
Expand Down
Loading