()
| 31 | |
| 32 | @pytest.mark.asyncio |
| 33 | async 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 |
| 47 | async def test_screenshot(): |
nothing calls this directly
no test coverage detected
searching dependent graphs…