-
Notifications
You must be signed in to change notification settings - Fork 540
fix: Remove tmp folder for PlaywrightCrawler in non-headless mode #1046
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
743856c
fix remove tmp folders for playwright context
Mantisus 933c836
add tests for perssist browser
Mantisus e56a2ca
fix test
Mantisus e64563d
add asyncio sleep 0
Mantisus 0bdf4ab
test for flaky test
Mantisus 479dd4c
update
Mantisus d3a311d
restore ignore_errors
Mantisus File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| from __future__ import annotations | ||
|
|
||
| from pathlib import Path | ||
| from typing import TYPE_CHECKING | ||
|
|
||
| import pytest | ||
| from playwright.async_api import async_playwright | ||
|
|
||
| from crawlee.browsers._playwright_browser import PlaywrightPersistentBrowser | ||
|
|
||
| if TYPE_CHECKING: | ||
| from collections.abc import AsyncGenerator | ||
|
|
||
| from playwright.async_api import Playwright | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| async def playwright() -> AsyncGenerator[Playwright, None]: | ||
| async with async_playwright() as playwright: | ||
| yield playwright | ||
|
|
||
|
|
||
| async def test_init(playwright: Playwright) -> None: | ||
| browser_type = playwright.chromium | ||
| persist_browser = PlaywrightPersistentBrowser(browser_type, user_data_dir=None, browser_launch_options={}) | ||
| assert persist_browser._browser_type == browser_type | ||
| assert persist_browser.browser_type == browser_type | ||
| assert persist_browser._browser_launch_options == {} | ||
| assert persist_browser._temp_dir is None | ||
| assert persist_browser._user_data_dir is None | ||
| assert persist_browser._is_connected is True | ||
| assert persist_browser.is_connected() is True | ||
|
|
||
|
|
||
| async def test_delete_temp_folder_with_close_browser(playwright: Playwright) -> None: | ||
| persist_browser = PlaywrightPersistentBrowser( | ||
| playwright.chromium, user_data_dir=None, browser_launch_options={'headless': True} | ||
| ) | ||
| await persist_browser.new_context() | ||
| assert isinstance(persist_browser._temp_dir, Path) | ||
| current_temp_dir = persist_browser._temp_dir | ||
| assert current_temp_dir.exists() | ||
| await persist_browser.close() | ||
| assert not current_temp_dir.exists() |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.