MCPcopy
hub / github.com/unclecode/crawl4ai / test_javascript_execution

Function test_javascript_execution

tests/async/test_parameters_and_options.py:33–44  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

31
32@pytest.mark.asyncio
33async def test_javascript_execution():
34 async with AsyncWebCrawler(verbose=True) as crawler:
35 url = "https://www.nbcnews.com/business"
36
37 # Crawl without JS
38 result_without_more = await crawler.arun(url=url, bypass_cache=True)
39
40 js_code = ["const loadMoreButton = Array.from(document.querySelectorAll('button')).find(button => button.textContent.includes('Load More')); loadMoreButton && loadMoreButton.click();"]
41 result_with_more = await crawler.arun(url=url, js=js_code, bypass_cache=True)
42
43 assert result_with_more.success
44 assert len(result_with_more.markdown) > len(result_without_more.markdown)
45
46@pytest.mark.asyncio
47async def test_screenshot():

Callers

nothing calls this directly

Calls 2

AsyncWebCrawlerClass · 0.90
arunMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…