go-rod / rod

A Chrome DevTools Protocol driver for web automation and scraping.
https://go-rod.github.io
MIT License
5.25k stars 345 forks source link

Feat: ScrollScreenshot #1010

Closed zbysir closed 7 months ago

zbysir commented 8 months ago

Add ScrollScreenshot, for https://github.com/go-rod/rod/issues/1008

ysmood commented 8 months ago

Good job! It will be great if you could add some tests.

zbysir commented 8 months ago

Good job! It will be great if you could add some tests.

Review again, please allow me to make some weird mistakes.

zbysir commented 8 months ago

Please fix the lint error in CI, you can check it on your local first go run ./lib/utils/lint.

The test doesn't work on Mac and Windows: https://github.com/go-rod/rod/actions/runs/7751056459/job/21138412821?pr=1010#step:4:25

Yes, I fixed it. Done.

ysmood commented 8 months ago

Please check the CI, if you need help let me know.

zbysir commented 8 months ago

@ysmood Need help:

The test code cannot cover the error branch below

              err = p.WaitStable(opt.WaitPreScroll)
                if err != nil {
                        return nil, fmt.Errorf("waitStable error: %w", err)
                }

I don't know how to fix it, I tried the test code below but it doesn't work

    g.Panic(func() {
        // mock error for WaitStable
        g.mc.stubErr(1, proto.DOMSnapshotCaptureSnapshot{})
        p.MustScrollScreenshotPage()
    })

Do you have any plans? Or is it appropriate for me to use time.Sleep() directly?

zbysir commented 8 months ago

@ysmood Please run CI again and it will almost succeed.

zbysir commented 7 months ago

@ysmood Thank you for your patient help!