Documentation ¶
Index ¶
- func CheckStep(ctx context.Context, b *Browser, step *Step, debug *log.Logger) error
- type BasicAuth
- type Browser
- func (b *Browser) Click(ctx context.Context, linkSelector string) (*Response, error)
- func (b *Browser) Dump(l *log.Logger)
- func (b *Browser) Open(ctx context.Context, method, uri string, opts *RequestOptions) (*Response, error)
- func (b *Browser) SubmitForm(ctx context.Context, formSelector string, moreValues map[string]string) (*Response, error)
- type RequestOptions
- type Response
- type Step
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Browser ¶
type Browser struct {
// contains filtered or unexported fields
}
Browser pretends (badly) to emulate a browser, to the extent that it keeps cookies across requests. It maintains state with the last browsed page, so that one can find elements in it using jquery-like CSS selector syntax, and click links or submit forms.
func NewBrowser ¶
NewBrowser creates a new Browser with the given tls configuration. Its debugging output will be sent to the specified Logger.
func (*Browser) Click ¶
Click on a link, identified by a CSS selector. The resulting element should have an 'href' attribute, and we'll navigate to that.
type Response ¶
type Response struct { URL *url.URL StatusCode int Header http.Header Body string Doc *goquery.Document }
Response is an abridged version of the http.Response.
type Step ¶
type Step struct { Name string `json:"name"` Type string `json:"type"` URL string `json:"url"` Method string `json:"method"` Headers map[string]string `json:"headers"` FormValues map[string]string `json:"form_values"` BasicAuth *BasicAuth `json:"basic_auth"` Selector string `json:"selector"` ExpectedURL jsontypes.Regexp `json:"expected_url"` ExpectedData jsontypes.Regexp `json:"expected_data"` }
A Step in a script, a series of HTTP transactions whose results we can verify somehow (right now just by needle-in-haystack string matching).