Skip to content

Commit

Permalink
fix: enhance executable not found check (#572)
Browse files Browse the repository at this point in the history
  • Loading branch information
mxschmitt authored Mar 18, 2021
1 parent ba70605 commit e54b3a8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
4 changes: 2 additions & 2 deletions playwright/_impl/_browser_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ async def launch(
try:
return from_channel(await self._channel.send("launch", params))
except Exception as e:
if f"{self.name}-" in str(e):
if "because executable doesn't exist" in str(e):
raise not_installed_error(f'"{self.name}" browser was not found.')
raise e

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

Expand Down
2 changes: 1 addition & 1 deletion playwright/_impl/_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def is_safe_close_error(error: Exception) -> bool:


def not_installed_error(message: str) -> Exception:
return Exception(
return Error(
f"""
================================================================================
{message}
Expand Down
9 changes: 9 additions & 0 deletions tests/async/test_launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,12 @@ async def test_browser_close_should_be_callable_twice(browser_type, launch_argum
browser.close(),
)
await browser.close()


async def test_browser_launch_non_existing_executable_path_shows_install_msg(
browser_type,
tmpdir,
):
with pytest.raises(Error) as exc_info:
await browser_type.launch(executable_path=tmpdir.join("executable"))
assert "python -m playwright install" in exc_info.value.message

0 comments on commit e54b3a8

Please sign in to comment.