1
0
mirror of https://github.com/MontFerret/ferret.git synced 2024-12-14 11:23:02 +02:00

add GetResponse into HTMLPage interface

This commit is contained in:
Владимир Фетисов 2019-09-30 21:07:11 +03:00
parent 73c9a01af5
commit 43fb43eb8b
2 changed files with 12 additions and 0 deletions

View File

@ -3,6 +3,8 @@ package common
import (
"context"
"github.com/pkg/errors"
"github.com/MontFerret/ferret/pkg/drivers"
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
@ -20,6 +22,14 @@ func GetInPage(ctx context.Context, page drivers.HTMLPage, path []core.Value) (c
segment := segment.(values.String)
switch segment {
case "response":
resp, err := page.GetResponse(ctx)
if err != nil {
return nil, errors.Wrap(err, "get response")
}
return resp.GetIn(ctx, path[1:])
case "mainFrame", "document":
return GetInDocument(ctx, page.GetMainFrame(), path[1:])
case "frames":

View File

@ -201,6 +201,8 @@ type (
NavigateBack(ctx context.Context, skip values.Int) (values.Boolean, error)
NavigateForward(ctx context.Context, skip values.Int) (values.Boolean, error)
GetResponse(ctx context.Context) (*HTTPResponse, error)
}
)