pydoll icon indicating copy to clipboard operation
pydoll copied to clipboard

[Feature Request]: Waits for the rendering to complete while getting the screenshot

Open Fish-LP opened this issue 8 months ago • 1 comments

Checklist before requesting

  • [x] I have searched for similar feature requests and didn't find a duplicate.
  • [x] I have checked the documentation to confirm this feature doesn't already exist.

Problem Statement

Image file rendering errors (such as holes and strange lines) occur, which are the same as obtaining the function of screenshot base64 and saving the screenshot image. This problem usually occurs on machines with weak performance, and I don't think it is a bug.

Proposed Solution

You don't need a new method, you need to modify the function to get screenshots.

Alternatives Considered

Consider using the command to generate the screenshot file and then read it asynchronously. This error will not occur when using the command to generate it.

Additional Context

This problem is almost impossible on a machine with good performance.

import asyncio
from pydoll.browser.chrome import Chrome
from pydoll.browser.options import Options

async def main():
    options = Options()
    options.add_argument("--headless")  # 启用无头模式
    options.add_argument("--disable-gpu")  # 禁用GPU加速
    options.add_argument("--no-sandbox")  # 禁用沙盒模式
    #options.add_argument("--disable-dev-shm-usage")  # 禁用共享内存
    options.add_argument("--window-size=1920x1080")  # 设置窗口大小
    options.binary_location = '/usr/bin/chromium'  # 设置Chromium的路径

    async with Chrome(options=options) as browser:
        await browser.start()
        page = await browser.get_page()
        await page.go_to('https://example.com')

        # 增加等待时间
        await asyncio.sleep(6)

        # 获取截图
        p = await page.get_screenshot_base64()
        print(p)

asyncio.run(main())

I find it much better to wait a few seconds.

Image

Image

Importance

Nice to have

Contribution

None

Fish-LP avatar Apr 05 '25 18:04 Fish-LP

I used translation software, so it might look a little strange.

Fish-LP avatar Apr 05 '25 18:04 Fish-LP

Hi @Fish-LP, I don't think this is necessary, it's a really edge case. You can add a sleep to handle this. Thank's for your contribution

thalissonvs avatar Jun 08 '25 03:06 thalissonvs

I'm very sorry. This error should not be caused by the project but by a device I/O error

Fish-LP avatar Aug 24 '25 14:08 Fish-LP