MCPcopy
hub / github.com/ScrapeGraphAI/Scrapegraph-ai / test_ascrape_playwright_scroll

Function test_ascrape_playwright_scroll

tests/test_chromium.py:117–142  ·  view source on GitHub ↗

Test the ascrape_playwright_scroll method with various configurations.

(mock_playwright)

Source from the content-addressed store, hash-verified

115
116@pytest.mark.asyncio
117async def test_ascrape_playwright_scroll(mock_playwright):
118 """Test the ascrape_playwright_scroll method with various configurations."""
119 mock_pw, mock_browser, mock_context, mock_page = mock_playwright
120
121 url = "http://example.com"
122 loader = ChromiumLoader([url], backend="playwright")
123
124 # Test with default parameters
125 mock_page.evaluate.side_effect = [1000, 2000, 2000] # Simulate scrolling
126 await loader.ascrape_playwright_scroll(url)
127
128 assert mock_page.goto.call_count == 1
129 assert mock_page.wait_for_load_state.call_count == 1
130 assert mock_page.mouse.wheel.call_count > 0
131 assert mock_page.content.call_count == 1
132
133 # Test with custom parameters
134 mock_page.evaluate.side_effect = [1000, 2000, 3000, 4000, 4000]
135 await loader.ascrape_playwright_scroll(
136 url, timeout=10, scroll=10000, sleep=1, scroll_to_bottom=True
137 )
138
139 assert mock_page.goto.call_count == 2
140 assert mock_page.wait_for_load_state.call_count == 2
141 assert mock_page.mouse.wheel.call_count > 0
142 assert mock_page.content.call_count == 2
143
144
145@pytest.mark.asyncio

Callers

nothing calls this directly

Calls 2

ChromiumLoaderClass · 0.90

Tested by

no test coverage detected