-
Notifications
You must be signed in to change notification settings - Fork 0
/
actions.go
67 lines (57 loc) · 1.29 KB
/
actions.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package GOpom
import (
"fmt"
"time"
)
func (b *BrowserSteps) iNavigateTo(site string) error {
u, err := b.GetURL(site)
if err != nil {
return err
}
return b.GetWebDriver().Get(u.String())
}
func (b *BrowserSteps) iWriteTo(text, selector, by string) error {
// Click the element
element, err := b.GetWebDriver().FindElement(by, selector)
if err != nil {
return err
}
err = element.Clear()
if err != nil {
return err
}
return element.SendKeys(text)
}
func (b *BrowserSteps) iClick() error {
// Submit the element
element, err := b.GetWebDriver().FindElement("name", "btnK")
if err != nil {
return err
}
return element.Click()
}
func (b *BrowserSteps) iSubmit(selector, by string) error {
// Submit the element
element, err := b.GetWebDriver().FindElement(by, selector)
if err != nil {
return err
}
return element.Submit()
}
func (b *BrowserSteps) iShouldSeePageTitleAs(expectedTitle string) error {
title, err := b.GetWebDriver().Title()
if err != nil {
return err
}
if expectedTitle != title {
return fmt.Errorf("Title does not match. Expected '%s', Found '%s'",
expectedTitle, title)
}
return nil
}
func iWaitFor(amount int, unit string) error {
u := time.Second
fmt.Printf("Waiting for %d %s", amount, unit)
time.Sleep(u * time.Duration(amount))
return nil
}