Skip to content

Commit e54b3a8

Browse files
authored
fix: enhance executable not found check (microsoft#572)
1 parent ba70605 commit e54b3a8

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

playwright/_impl/_browser_type.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ async def launch(
6969
try:
7070
return from_channel(await self._channel.send("launch", params))
7171
except Exception as e:
72-
if f"{self.name}-" in str(e):
72+
if "because executable doesn't exist" in str(e):
7373
raise not_installed_error(f'"{self.name}" browser was not found.')
7474
raise e
7575

@@ -124,7 +124,7 @@ async def launch_persistent_context(
124124
context._options = params
125125
return context
126126
except Exception as e:
127-
if f"{self.name}-" in str(e):
127+
if "because executable doesn't exist" in str(e):
128128
raise not_installed_error(f'"{self.name}" browser was not found.')
129129
raise e
130130

playwright/_impl/_helper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ def is_safe_close_error(error: Exception) -> bool:
203203

204204

205205
def not_installed_error(message: str) -> Exception:
206-
return Exception(
206+
return Error(
207207
f"""
208208
================================================================================
209209
{message}

tests/async/test_launcher.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,3 +117,12 @@ async def test_browser_close_should_be_callable_twice(browser_type, launch_argum
117117
browser.close(),
118118
)
119119
await browser.close()
120+
121+
122+
async def test_browser_launch_non_existing_executable_path_shows_install_msg(
123+
browser_type,
124+
tmpdir,
125+
):
126+
with pytest.raises(Error) as exc_info:
127+
await browser_type.launch(executable_path=tmpdir.join("executable"))
128+
assert "python -m playwright install" in exc_info.value.message

0 commit comments

Comments
 (0)