Comments (9)
from rod.
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.
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.
If you want more options, you can use WaitRequestIdleE
other than the high-level version WaitRequestIdle
from rod.
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.
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.
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.
Agree, if you can make a PR to fix the doc, I'll be more than happy to merge!
from rod.
Never mind. Looking forward to your idea and contribution π
from rod.
Related Issues (20)
- Why doesn't it remember the window size now? HOT 11
- Bug Select Frame Element HOT 2
- Bug element's pointer-events is none HOT 4
- Download in headless mode is failing, but works fine otherwise HOT 6
- Dear go-rod production team, I would like to ask you a question about remote connections and using proxies. HOT 3
- Is there a way to get css rules associated with an element ? HOT 2
- Add a JS script to browser HOT 3
- Missing Request Body When Loading "https://www.booking.com" Using go-rod HOT 2
- [bug] Page.EachEvent call is not reusable for the second time HOT 2
- but cannot check the element nodes on go-rod. HOT 5
- I have a print button on UI, on clicking that the print dialog box doesn't open in browser launched from rod. HOT 6
- Is there any way to wait for a certain element in the page: HOT 5
- Any way to launch multiple browsers with different users each? HOT 1
- Exporting the full page as PDF (single page) HOT 1
- Ignoring the error "element's pointer-events is none" HOT 2
- θΏη¨ε―ε¨θ’«ζε ζ ζ³ιεΊ ε―Όθ΄ιζ» HOT 3
- Upload file on Managed Launcher? HOT 2
- Does rod support separate sessions or incognito mode? HOT 2
- if err == nil εηι»θΎδΈδΌζ§θ‘ HOT 1
- Google Login not working when browser is started with Rod HOT 11
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rod.