chromedp – cannot get current window title

61 views
Skip to first unread message

Andreas

unread,
Oct 22, 2019, 3:33:49 PM10/22/19
to golang-nuts
Chromedp is used for browser automation. 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?

```
...
var title string

err := chromedp.Run(taskCtx,
...
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:

Andreas

unread,
Oct 22, 2019, 3:41:35 PM10/22/19
to golang-nuts
I run it in normal browser mode (no headless) so the page was opened. Even if I try to get some element text there is empty value too, for example selector like this one:
//div[@id="gbar"]/a[contains(@class, "gb1")]

Reply all
Reply to author
Forward
0 new messages