0

I try to get windows title on gmail inbox page after it was opened. For some reason the title is empty. What am I doing wrong? Chromedp is used for browser automation.

...
var title string

err := chromedp.Run(taskCtx,
    chromedp.Navigate(`https://mail.google.com/mail/u/0/h/`),
    ...
    chromedp.WaitVisible(`body`), // gmail inbox page was opened in browser
    chromedp.Title(&title),
)
if err != nil {
    if err.Error() == "context deadline exceeded" {
        log.Println(err) // this line executed
    } else {
        log.Fatal(err)
    }
}

log.Printf("success.\ntitle: %s\n", title) // title is empty!

The output in console:

2019/10/22 08:01:49 context deadline exceeded

2019/10/22 08:01:49 success.

title:

Community
  • 1
  • 1
rozerro
  • 5,787
  • 9
  • 46
  • 94

1 Answers1

1

The Title function is probably not executed due to the error printed in the output. You should fix this before focusing on the title

Flvff
  • 11
  • 3
  • Probably it is but what is the reason for that? While program executes in browser all things done as expected. – sam smith Oct 22 '19 at 11:04
  • Maybe chromedp timeout while while waiting for the body to be visible ? If so, the Title action won't be executed, but it doesn't prevent chrome to continue loading the page – Flvff Oct 22 '19 at 13:14