1
0
mirror of https://github.com/MontFerret/ferret.git synced 2025-06-17 00:07:55 +02:00

Added support to open blank page

This commit is contained in:
Tim Voronov
2018-10-04 21:37:28 -04:00
parent 71ee1f3dfe
commit c650d28b29
7 changed files with 55 additions and 27 deletions

View File

@ -21,6 +21,8 @@ import (
"time"
)
const BlankPageUrl = "about:blank"
type HtmlDocument struct {
sync.Mutex
logger *zerolog.Logger
@ -78,10 +80,12 @@ func LoadHtmlDocument(
return nil, err
}
err = waitForLoadEvent(ctx, client)
if url != BlankPageUrl {
err = waitForLoadEvent(ctx, client)
if err != nil {
return nil, err
if err != nil {
return nil, err
}
}
root, innerHtml, err := getRootElement(client)
@ -637,6 +641,10 @@ func (doc *HtmlDocument) WaitForNavigation(timeout values.Int) error {
}
func (doc *HtmlDocument) Navigate(url values.String) error {
if url == "" {
url = BlankPageUrl
}
ctx := context.Background()
repl, err := doc.client.Page.Navigate(ctx, page.NewNavigateArgs(url.String()))
@ -648,5 +656,5 @@ func (doc *HtmlDocument) Navigate(url values.String) error {
return errors.New(*repl.ErrorText)
}
return waitForLoadEvent(ctx, doc.client)
return doc.WaitForNavigation(5000)
}