Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add statement to manage browser history actions #237

Merged
merged 1 commit into from
May 11, 2020
Merged
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
36 changes: 36 additions & 0 deletions executors/web/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,42 @@ testcases:
ConfirmPopup: true
```

History actions allow you to manipulate browser history actions. The following action are available:
* back
* refresh
* forward

Example:

```yaml
name: TestSuiteNavigationHistory
testcases:
- name: TestCaseNavigationHistory
context:
type: web
driver: chrome
debug: true
steps:
- action:
navigate:
url: https://www.google.com
- action:
fill:
- find: input[name='q']
text: ovh venom github
screenshot: search.png
- action:
click:
find: div[jsname='VlcLAe'] input[name='btnK']
wait: 2
- action:
historyAction: back
- action:
historyAction: refresh
- action:
historyAction: forward
```

## Output

* result.url
Expand Down
31 changes: 16 additions & 15 deletions executors/web/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@ package web

// Action represents what can be done with web executor
type Action struct {
Click *Click `yaml:"click,omitempty"`
Fill []Fill `yaml:"fill,omitempty"`
Find string `yaml:"find,omitempty"`
Navigate *Navigate `yaml:"navigate,omitempty"`
Wait int64 `yaml:"wait,omitempty"`
ConfirmPopup bool `yaml:"confirmPopup,omitempty"`
CancelPopup bool `yaml:"cancelPopup,omitempty"`
Select *Select `yaml:"select,omitempty"`
UploadFile *UploadFile `yaml:"uploadFile,omitempty"`
SelectFrame *SelectFrame `yaml:"selectFrame,omitempty"`
SelectRootFrame bool `yaml:"selectRootFrame,omitempty"`
NextWindow bool `yaml:"nextWindow,omitempty"`
Click *Click `yaml:"click,omitempty"`
Fill []Fill `yaml:"fill,omitempty"`
Find string `yaml:"find,omitempty"`
Navigate *Navigate `yaml:"navigate,omitempty"`
Wait int64 `yaml:"wait,omitempty"`
ConfirmPopup bool `yaml:"confirmPopup,omitempty"`
CancelPopup bool `yaml:"cancelPopup,omitempty"`
Select *Select `yaml:"select,omitempty"`
UploadFile *UploadFile `yaml:"uploadFile,omitempty"`
SelectFrame *SelectFrame `yaml:"selectFrame,omitempty"`
SelectRootFrame bool `yaml:"selectRootFrame,omitempty"`
NextWindow bool `yaml:"nextWindow,omitempty"`
HistoryAction string `yaml:"historyAction,omitempy"`
}

// Fill represents informations needed to fill input/textarea
Expand Down Expand Up @@ -44,12 +45,12 @@ type Select struct {

// UploadFile represents informations needed to upload files
type UploadFile struct {
Find string `yaml:"find,omitempty"`
Find string `yaml:"find,omitempty"`
Files []string `yaml:"files,omitempty"`
Wait int64 `yaml:"wait,omitempty"`
Wait int64 `yaml:"wait,omitempty"`
}

// SelectFrame represents informations needed to select the frame
type SelectFrame struct {
Find string `yaml:"find,omitempty"`
Find string `yaml:"find,omitempty"`
}
17 changes: 17 additions & 0 deletions executors/web/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,23 @@ func (Executor) Run(testCaseContext venom.TestCaseContext, l venom.Logger, step
if err := ctx.Page.NextWindow(); err != nil {
return nil, err
}
} else if e.Action.HistoryAction != "" {
switch strings.ToLower(e.Action.HistoryAction) {
case "back":
if err := ctx.Page.Back(); err != nil {
return nil, err
}
case "refresh":
if err := ctx.Page.Refresh(); err != nil {
return nil, err
}
case "forward":
if err := ctx.Page.Forward(); err != nil {
return nil, err
}
default:
return nil, fmt.Errorf("History action '%s' is invalid", e.Action.HistoryAction)
}
}

// take a screenshot
Expand Down