I have a function that uses chromedp to check if there is a acknowledge modal that pops up sometimes. If it pops up the function works but if the context deadline is extended it will still say that the deadline exceeded. Oddly, if the deadline is reduced in other Runs it works.
func check(page string) {
opts := append(chromedp.DefaultExecAllocatorOptions[:],
chromedp.UserAgent("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.106 Safari/537.36"),
chromedp.Flag("enable-automation", false),
chromedp.Flag("headless", false),
)
ctx, cancel := chromedp.NewExecAllocator(context.Background(), opts...)
defer cancel()
ctx, cancel = chromedp.NewContext(ctx)
defer cancel()
ctx, cancel = context.WithTimeout(ctx, 10*time.Second)
defer cancel()
err := chromedp.Run(ctx,
chromedp.Navigate(page),
chromedp.WaitReady("body", chromedp.ByQuery),
chromedp.Click(`#ackBtn`, chromedp.ByID),
)
if err != nil {
fmt.Println("Didn't find Ack")
//return
}
ctx, cancel = context.WithTimeout(ctx, 30*time.Second)
defer cancel()
err2 := chromedp.Run(ctx,
chromedp.Click(`#options > div:nth-child(1) > div.c-card__column2 > a.c-card__btn.btn-new.btn-color-blue.btn-size-xxlarge.btn-width-auto.btn-max-width`, chromedp.ByID),
)
if err2 != nil {
fmt.Println("exited on error", err)
}
}