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

Feature - GUI - Add statements to manage frame #228

Merged
merged 4 commits into from
Mar 18, 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
42 changes: 42 additions & 0 deletions executors/web/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,48 @@ testcases:

```

Select frame and Select root frame actions help you to navigate into your differents frames.
After the frame selection, you can manipulate web elements presents in a frame.
Two statements:
* SelectFrame: One find parameter to select the frame with CSS selector
* SelectRootFrame: One boolean parameter, must be true to activate the statement
Example:

```yaml
name: TestSuite SelectFrame
testcases:
- name: TestCase SelectFrame
context:
type: web
driver: phantomjs
debug: true
steps:
- action:
navigate:
url: https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_win_open
- action:
selectFrame:
find: iframe[id='iframeResult']
- action:
find: body > button
assertions:
- result.find ShouldEqual 1
- action:
find: a#tryhome
assertions:
- result.find ShouldEqual 0
- action:
selectRootFrame: true
- action:
find: body > button
assertions:
- result.find ShouldEqual 0
- action:
find: a#tryhome
assertions:
- result.find ShouldEqual 1
```

Next Window action allow you to change the current window
Next Window have one boolean parameter, this parameter must be true
Example:
Expand Down
7 changes: 7 additions & 0 deletions executors/web/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ type Action struct {
Find string `yaml:"find,omitempty"`
Navigate *Navigate `yaml:"navigate,omitempty"`
Wait int64 `yaml:"wait,omitempty"`
SelectFrame *SelectFrame `yaml:"selectFrame,omitempty"`
SelectRootFrame bool `yaml:"selectRootFrame,omitempty"`
NextWindow bool `yaml:"nextWindow,omitempty"`
}

Expand All @@ -26,3 +28,8 @@ type Navigate struct {
Url string `yaml:"url,omitempty"`
Reset bool `yaml:"reset,omitempty"`
}

// SelectFrame represents informations needed to select the frame
type SelectFrame struct {
Find string `yaml:"find,omitempty"`
}
16 changes: 16 additions & 0 deletions executors/web/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,22 @@ func (Executor) Run(testCaseContext venom.TestCaseContext, l venom.Logger, step
}
} else if e.Action.Wait != 0 {
time.Sleep(time.Duration(e.Action.Wait) * time.Second)

} else if e.Action.SelectFrame != nil {
s, err := findOne(ctx.Page, e.Action.SelectFrame.Find, r)
if err != nil {
return nil, err
}
if elements, errElements := s.Elements(); errElements == nil {
if errSelectFrame := ctx.Page.Session().Frame(elements[0]); errSelectFrame != nil {
return nil, errSelectFrame
}
} else {
return nil, errElements
}
// Select root frame
} else if ( e.Action.SelectRootFrame ) {
if err := ctx.Page.SwitchToRootFrame(); err != nil {
} else if ( e.Action.NextWindow ) {
if err := ctx.Page.NextWindow(); err != nil {
return nil, err
Expand Down