#chromedp explicit waits help

40 messages · Page 1 of 1 (latest)

safe bough
#

have you tried anything

safe bough
#

yeah

safe bough
#

well i want you to try writing it with chromedp

#

you gotta try

#

we cant write it for ya

#

show me your work

safe bough
#

im confused, don't you kind of already do that with the context withTimeouts?

sterile eagleBOT
#

      func WaitVisible(sel interface{}, opts ...QueryOption) QueryAction
    ```
WaitVisible is an element query action that waits until the element matching the selector is visible.
safe bough
#

if you call it with chromedp.Run with a properly timing out ctx i believe so yes

#

but why are you calling chromedp.Sleep

#

by the time the sleep finishes the ctx will always be cancelled

#

what was the reasoning for it to be added

#

we're almost there

#

but we take steps

#

do you understand why we dont want to sleep?

#

kind of

#

you dont want to actually sleep

#

when you are sleeping, there's nothing ever happening

#

even when you are waiting, you are monitoring for something

#

if you sleep for 10 seconds

#

and set a timeout for 10 seconds

#

after you wake up, the timeout will always trigger

#

no matter what

#

does that make sense?

#

so what you want to do is

#

in the same chromedp run

#

with the context with a correct timeout

#

you do the wait for visible

#

and then you do the click right after

#

you can pass multiple arguments to chromedp.run

#

chromedp.Run(ctx, chromedp.WaitVisible(...), chromedp.Click(...)

#

you can chain all of them together

#

no

#

wait visible doesnt care about the timeout

#

the wait visible only waits until its visible

#

as the name says

#

yea

#

sure

#

correct