Skip to content

Commit cefda11

Browse files
authored
Merge pull request #309 from bollwyvl/gh-308-fix-geckodriver
add env var for firefox, fallback to known locations or which
2 parents 6a16adf + 3265eba commit cefda11

File tree

7 files changed

+345
-9
lines changed

7 files changed

+345
-9
lines changed

CONTRIBUTING.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,19 @@ python scripts/combine.py
279279
and change `create_console('browser')` to `create_console('floating')` in `VirtualEditor`
280280
constructor (please feel free to add a config option for this).
281281

282+
- If you see:
283+
284+
> `SessionNotCreatedException: Message: Unable to find a matching set of capabilities`
285+
286+
`geckodriver >=0.27.0` requires an _actual_ Firefox executable. Several places
287+
will be checked (including where `conda-forge` installs, as in CI): to test
288+
a Firefox _not_ on your `PATH`, set the following enviroment variable:
289+
290+
```bash
291+
export FIREFOX_BINARY=/path/to/firefox # ... unix
292+
set FIREFOX_BINARY=C:\path\to\firefox.exe # ... windows
293+
```
294+
282295
### Formatting
283296

284297
Minimal code style is enforced with `pytest-flake8` during unit testing. If installed,

atest/Keywords.robot

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,22 @@ Wait For Splash
8484

8585
Open JupyterLab
8686
Set Environment Variable MOZ_HEADLESS ${HEADLESS}
87-
${firefox} = Which firefox
87+
${firefox} = Get Firefox Binary
8888
${geckodriver} = Which geckodriver
89-
Create WebDriver Firefox executable_path=${geckodriver} firefox_binary=${firefox} service_log_path=${OUTPUT DIR}${/}geckodriver.log
89+
${service args} = Create List --log debug
90+
Create WebDriver Firefox
91+
... executable_path=${geckodriver}
92+
... firefox_binary=${firefox}
93+
... service_log_path=${OUTPUT DIR}${/}geckodriver.log
94+
... service_args=${service args}
9095
Wait Until Keyword Succeeds 3x 5s Wait For Splash
9196

97+
Get Firefox Binary
98+
[Documentation] Get Firefox path from the environment... or hope for the best
99+
${from which} = Which firefox
100+
${firefox} = Set Variable If "%{FIREFOX_BINARY}" %{FIREFOX_BINARY} ${from which}
101+
[Return] ${firefox}
102+
92103
Close JupyterLab
93104
Close All Browsers
94105

py_src/jupyter_lsp/tests/conftest.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
import shutil
44
from typing import Text
55

6-
# local imports
7-
from jupyter_lsp import LanguageServerManager
8-
from jupyter_lsp.handlers import LanguageServersHandler, LanguageServerWebSocketHandler
96
from notebook.notebookapp import NotebookApp
107
from pytest import fixture
118
from tornado.queues import Queue
129

10+
# local imports
11+
from jupyter_lsp import LanguageServerManager
12+
from jupyter_lsp.handlers import LanguageServersHandler, LanguageServerWebSocketHandler
13+
1314
# these should always be available in a test environment ()
1415
KNOWN_SERVERS = [
1516
"bash-language-server",

py_src/jupyter_lsp/tests/test_bad_spec.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import pytest
22
import traitlets
3+
34
from jupyter_lsp.session import LanguageServerSession
45

56

py_src/jupyter_lsp/tests/test_listener.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33

44
import pytest
55
import traitlets
6-
from jupyter_lsp import lsp_message_listener
76
from tornado.queues import Queue
87

8+
from jupyter_lsp import lsp_message_listener
9+
910

1011
@pytest.mark.parametrize("bad_string", ["not-a-function", "jupyter_lsp.__version__"])
1112
@pytest.mark.asyncio

scripts/atest.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import shutil
77
import sys
88
import time
9+
from os.path import join
910
from pathlib import Path
1011

1112
import robot
@@ -45,6 +46,24 @@ def get_stem(attempt, extra_args):
4546
def atest(attempt, extra_args):
4647
""" perform a single attempt of the acceptance tests
4748
"""
49+
50+
if "FIREFOX_BINARY" not in os.environ:
51+
os.environ["FIREFOX_BINARY"] = shutil.which("firefox")
52+
53+
prefix = os.environ.get("CONDA_PREFIX")
54+
55+
if prefix:
56+
app_dir = join(prefix, "bin", "FirefoxApp")
57+
os.environ["FIREFOX_BINARY"] = {
58+
"Windows": join(prefix, "Library", "bin", "firefox.exe"),
59+
"Linux": join(app_dir, "firefox"),
60+
"Darwin": join(app_dir, "Contents", "MacOS", "firefox"),
61+
}[OS]
62+
63+
print("Will use firefox at", os.environ["FIREFOX_BINARY"])
64+
65+
assert os.path.exists(os.environ["FIREFOX_BINARY"])
66+
4867
extra_args += OS_PY_ARGS.get((OS, PY), [])
4968

5069
stem = get_stem(attempt, extra_args)

0 commit comments

Comments
 (0)