Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion browser/browser.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
19 changes: 17 additions & 2 deletions browser/form.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down