Skip to content

Commit

Permalink
add doc for timeout
Browse files Browse the repository at this point in the history
resolve #73
  • Loading branch information
ysmood committed Sep 10, 2020
1 parent a2e2a01 commit 2821d5d
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,28 @@ func Example_basic() {
// after 0.5 seconds, the element is still not rendered
}

// Usage of timeout context
func Example_timeout() {
page := rod.New().MustConnect().MustPage("https://github.com")

page.
// Set a 5-second timeout for all chained actions
Timeout(5 * time.Second).

// The total time for MustWaitLoad and MustElement must be less than 5 seconds
MustWaitLoad().
MustElement("title").

// Actions after CancelTimeout won't be affected by the 5-second timeout
CancelTimeout().

// Set a 10-second timeout for all chained actions
Timeout(10 * time.Second).

// Panics if it takes more than 10 seconds
MustText()
}

// Example_search shows how to use Search to get element inside nested iframes or shadow DOMs.
// It works the same as https://developers.google.com/web/tools/chrome-devtools/dom#search
func Example_search() {
Expand Down

0 comments on commit 2821d5d

Please sign in to comment.