go-rod / rod

A Chrome DevTools Protocol driver for web automation and scraping.

Home Page:https://go-rod.github.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to cancel the timeout for Elements (not just one)?

st3rv04ka opened this issue · comments

Rod Version: v0.113.0

The code to demonstrate your question

blocks, err = page.Timeout(5 * time.Second).ElementsX(step.PostBlocks)
for _, block := range blocks {
    linkEl, err := block.CancelTimeout().Timeout(2 * time.Second).ElementX(step.LinkPost)
}

What you got

2023/12/01 19:15:32 context cancelled

What you expect to see

I want to recreate a context for each block.

ctx, cancel := context.WithTimeout(yourCtx, d)
newBlock := block.Context(ctx)