MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / server

Function server

py/conftest.py:660–701  ·  view source on GitHub ↗
(request)

Source from the content-addressed store, hash-verified

658
659@pytest.fixture(autouse=True, scope="session")
660def server(request):
661 is_remote = request.config.getoption("remote")
662 if not is_remote:
663 yield None
664 return
665
666 remote_env = os.environ.copy()
667 if sys.platform == "linux":
668 # There are issues with window size/position when running Firefox
669 # under Wayland, so we use XWayland instead.
670 remote_env["MOZ_ENABLE_WAYLAND"] = "0"
671
672 server = Server(env=remote_env, startup_timeout=60, args=_pinned_grid_args(request.config) or None)
673
674 repo_root = Path(__file__).parent.parent # py/conftest.py -> py/ -> selenium/
675 jar_path = "java/src/org/openqa/selenium/grid/selenium_server_deploy.jar"
676
677 if Path(jar_path).exists():
678 # Found in runfiles (bazel test) - relative to cwd
679 server.path = jar_path
680 elif (repo_root / "bazel-bin" / jar_path).exists():
681 # Found in bazel-bin relative to repo root (pytest from anywhere)
682 server.path = str(repo_root / "bazel-bin" / jar_path)
683
684 java_location_env = os.environ.get("SE_BAZEL_JAVA_LOCATION")
685 if Runfiles is not None and java_location_env:
686 # Find bazel's Java
687 r = Runfiles.Create()
688 java_location_txt = r.Rlocation("_main/" + java_location_env)
689 try:
690 rel_path = Path(java_location_txt).read_text().strip().removeprefix("external/")
691 java_path = r.Rlocation(rel_path)
692 if sys.platform == "win32" and java_path and os.path.exists(java_path):
693 java_path = os.path.realpath(java_path)
694 server.java_path = java_path
695 except Exception:
696 pass
697
698 server.port = free_port()
699 server.start()
700 yield server
701 server.stop()
702
703
704@pytest.fixture(autouse=True, scope="session")

Callers 1

startMethod · 0.50

Calls 10

startMethod · 0.95
stopMethod · 0.95
ServerClass · 0.90
free_portFunction · 0.90
_pinned_grid_argsFunction · 0.85
PathClass · 0.85
existsMethod · 0.80
getMethod · 0.65
copyMethod · 0.45
CreateMethod · 0.45

Tested by

no test coverage detected