Closed kamira closed 4 years ago
I am try screenshot after page loaded, but after full loaded I can't screenshot.
OS: Windows 10 1809 IDE: PyCharm 2019.3 PyVersion: 3.8.2
code:
async def test(): browser = await launch page = await browser.newPage() await page.setViewport(viewport={'width': 1280, 'height': 800}) await page.setJavaScriptEnabled(enabled=True) await page.setUserAgent( 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) ' 'AppleWebKit/537.36 (KHTML, like Gecko) ' 'Chrome/58.0.3029.110 ' 'Safari/537.36 ' 'Edge/16.16299') print('new page') await page.goto(full_url, {"waitUtil": 'networkidle0', "timeout": 0}) await asyncio.sleep(5) print('await start') await Promise.race([ asyncio.create_task(page.waitForNavigation({"waitUtil": 'networkidle0', "timeout": 0})), asyncio.create_task(asyncio.sleep(10)) ]) print('await done') print(f'screenshot start') buffer = await page.screenshot() print(f'screenshot end') await page.close() print(buffer)
output:
new page await start await done screenshot start
I solve it by self. I upgrade the chrome version and then it solved.
I am try screenshot after page loaded, but after full loaded I can't screenshot.
OS: Windows 10 1809 IDE: PyCharm 2019.3 PyVersion: 3.8.2
code:
output: