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

Function server

py/conftest.py:662–703  ·  view source on GitHub ↗
(request)

Source from the content-addressed store, hash-verified

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