diff --git a/browser/browser.go b/browser/browser.go index 0632bdd..91d49e5 100644 --- a/browser/browser.go +++ b/browser/browser.go @@ -532,7 +532,6 @@ func (bow *Browser) SetHeadersJar(h http.Header) { bow.headers = h } -// SetTransport sets the http library transport mechanism for each request. // SetTimeout sets the timeout for requests. func (bow *Browser) SetTimeout(t time.Duration) { if bow.client == nil { diff --git a/browser/form.go b/browser/form.go index 87f10e6..ad8e23f 100644 --- a/browser/form.go +++ b/browser/form.go @@ -15,6 +15,10 @@ import ( type Submittable interface { Method() string Action() string + + // SetAction will change the forms Action to the provided url + SetAction(url string) error + Input(name, value string) error Set(name, value string) error @@ -113,6 +117,17 @@ func (f *Form) Action() string { return f.action } +// SetAction sets the form action URL. +// The provided URL may be relitive or absolute +func (f *Form) SetAction(url string) error { + action, err := f.bow.ResolveStringUrl(url) + if err != nil { + return err + } + f.action = action + return nil +} + // Input sets the value of a form field. // it returns an ElementNotFound error if the field does not exist func (f *Form) Input(name, value string) error { @@ -333,8 +348,8 @@ func (f *Form) send(buttonName, buttonValue string) error { if !ok { method = "GET" } - action, ok := f.selection.Attr("action") - if !ok { + action := f.action + if action == "" { action = f.bow.Url().String() } aurl, err := url.Parse(action)