GithubHelp home page GithubHelp logo

Comments (9)

alufrew avatar alufrew commented on July 1, 2024 1

from rod.

alufrew avatar alufrew commented on July 1, 2024 1

I see you already closed issue. Sorry that you had to do it yourself. Was away for a while. Won't happen next time.

from rod.

ysmood avatar ysmood commented on July 1, 2024

The wait is only for the next request. If you have another request you have to create another wait:

package main

import (
	"fmt"
	"time"

	"github.com/ysmood/rod"
	"github.com/ysmood/rod/lib/launcher"
)

func main() {
	url := launcher.New().
		Headless(false).
		Launch()

	b := rod.New().ControlURL(url).Connect().Timeout(30 * time.Second)
	defer b.Close()

	page := b.Page("https://google.com")
	w := page.WaitRequestIdle()

	page.Navigate("https://wikipedia.org")
	fmt.Println(time.Now())
	w()
	fmt.Println(time.Now())

	w := page.WaitRequestIdle()  // look at this line!

	page.Navigate("https://gmail.com")
	fmt.Println(time.Now())
	w()
	fmt.Println(time.Now())
}

from rod.

ysmood avatar ysmood commented on July 1, 2024

If you want more options, you can use WaitRequestIdleE other than the high-level version WaitRequestIdle

from rod.

ysmood avatar ysmood commented on July 1, 2024

BTW, for page load events it's better to use page.WaitLoad(), WaitRequestIdle is designed for ajax requests when you click some button on the page.

from rod.

ysmood avatar ysmood commented on July 1, 2024

Usually, you don't need to use WaitRequestIdle or WaitLoad at all, you can directly use the selector page.Element, it will automatically retry until it finds the element.

from rod.

alufrew avatar alufrew commented on July 1, 2024

Oh. Thanks. I misunderstood how it should work.

I really need WaitRequestIdle. In my case all elements can be already on page but background requests are still running. If I f.e. click on element before requests stop sometimes I receive unexpected behaviour. So after clicking on some element I want to wait while requests are finished before clicking next.

May I propose to slightly change doc string for WaitRequestIdle to empathize that function returned will only be used for one next request?

from rod.

ysmood avatar ysmood commented on July 1, 2024

Agree, if you can make a PR to fix the doc, I'll be more than happy to merge!

from rod.

ysmood avatar ysmood commented on July 1, 2024

Never mind. Looking forward to your idea and contribution πŸ˜ƒ

from rod.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.