forked from sclevine/agouti
-
Notifications
You must be signed in to change notification settings - Fork 0
/
selectable_test.go
164 lines (141 loc) · 7.11 KB
/
selectable_test.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
package agouti_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "github.com/robomotionio/agouti"
"github.com/robomotionio/agouti/api"
"github.com/robomotionio/agouti/internal/mocks"
)
var _ = Describe("Selectable", func() {
var (
bus *mocks.Bus
session *api.Session
page *Page
)
BeforeEach(func() {
bus = &mocks.Bus{}
session = &api.Session{Bus: bus}
page = NewTestPage(session)
bus.SendCall.Result = `[{"ELEMENT": ""}]`
})
Describe("#Find", func() {
It("should apply a single CSS selector and return a selection with the same session", func() {
Expect(page.Find("selector").String()).To(Equal("selection 'CSS: selector [single]'"))
Expect(page.Find("selector").Elements()).To(ContainElement(&api.Element{Session: session}))
})
})
Describe("#FindByXPath", func() {
It("should apply a single XPath selector and return a selection with the same session", func() {
Expect(page.FindByXPath("selector").String()).To(Equal("selection 'XPath: selector [single]'"))
Expect(page.FindByXPath("selector").Elements()).To(ContainElement(&api.Element{Session: session}))
})
})
Describe("#FindByLink", func() {
It("should apply a single link selector and return a selection with the same session", func() {
Expect(page.FindByLink("selector").String()).To(Equal(`selection 'Link: "selector" [single]'`))
Expect(page.FindByLink("selector").Elements()).To(ContainElement(&api.Element{Session: session}))
})
})
Describe("#FindByLabel", func() {
It("should apply a single label selector and return a selection with the same session", func() {
Expect(page.FindByLabel("selector").String()).To(Equal(`selection 'Label: "selector" [single]'`))
Expect(page.FindByLabel("selector").Elements()).To(ContainElement(&api.Element{Session: session}))
})
})
Describe("#FindByButton", func() {
It("should apply a single button text selector and return a selection with the same session", func() {
Expect(page.FindByButton("selector").String()).To(Equal(`selection 'Button: "selector" [single]'`))
Expect(page.FindByButton("selector").Elements()).To(ContainElement(&api.Element{Session: session}))
})
})
Describe("#FindByClass", func() {
It("should apply a single class selector and return a selection with the same session", func() {
Expect(page.FindByClass("selector").String()).To(Equal(`selection 'Class: selector [single]'`))
Expect(page.FindByClass("selector").Elements()).To(ContainElement(&api.Element{Session: session}))
})
})
Describe("#FindByID", func() {
It("should apply a single ID selector and return a selection with the same session", func() {
Expect(page.FindByID("selector").String()).To(Equal(`selection 'ID: selector [single]'`))
Expect(page.FindByID("selector").Elements()).To(ContainElement(&api.Element{Session: session}))
})
})
Describe("#First", func() {
It("should apply a zero-indexed CSS selector and return a selection with the same session", func() {
Expect(page.First("selector").String()).To(Equal("selection 'CSS: selector [0]'"))
Expect(page.First("selector").Elements()).To(ContainElement(&api.Element{Session: session}))
})
})
Describe("#FirstByXPath", func() {
It("should apply a zero-indexed XPath selector and return a selection with the same session", func() {
Expect(page.FirstByXPath("selector").String()).To(Equal("selection 'XPath: selector [0]'"))
Expect(page.FirstByXPath("selector").Elements()).To(ContainElement(&api.Element{Session: session}))
})
})
Describe("#FirstByLink", func() {
It("should apply a zero-indexed link selector and return a selection with the same session", func() {
Expect(page.FirstByLink("selector").String()).To(Equal(`selection 'Link: "selector" [0]'`))
Expect(page.FirstByLink("selector").Elements()).To(ContainElement(&api.Element{Session: session}))
})
})
Describe("#FirstByLabel", func() {
It("should apply a zero-indexed label selector and return a selection with the same session", func() {
Expect(page.FirstByLabel("selector").String()).To(Equal(`selection 'Label: "selector" [0]'`))
Expect(page.FirstByLabel("selector").Elements()).To(ContainElement(&api.Element{Session: session}))
})
})
Describe("#FirstByButton", func() {
It("should apply a zero-indexed button text selector and return a selection with the same session", func() {
Expect(page.FirstByButton("selector").String()).To(Equal(`selection 'Button: "selector" [0]'`))
Expect(page.FirstByButton("selector").Elements()).To(ContainElement(&api.Element{Session: session}))
})
})
Describe("#FirstByClass", func() {
It("should apply a zero-indexed class selector and return a selection with the same session", func() {
Expect(page.FirstByClass("selector").String()).To(Equal(`selection 'Class: selector [0]'`))
Expect(page.FirstByClass("selector").Elements()).To(ContainElement(&api.Element{Session: session}))
})
})
Describe("#All", func() {
It("should apply an un-indexed CSS selector and return a selection with the same session", func() {
Expect(page.All("selector").String()).To(Equal("selection 'CSS: selector'"))
Expect(page.All("selector").Elements()).To(ContainElement(&api.Element{Session: session}))
})
})
Describe("#AllByXPath", func() {
It("should apply an un-indexed XPath selector and return a selection with the same session", func() {
Expect(page.AllByXPath("selector").String()).To(Equal("selection 'XPath: selector'"))
Expect(page.AllByXPath("selector").Elements()).To(ContainElement(&api.Element{Session: session}))
})
})
Describe("#AllByLink", func() {
It("should apply an un-indexed link selector and return a selection with the same session", func() {
Expect(page.AllByLink("selector").String()).To(Equal(`selection 'Link: "selector"'`))
Expect(page.AllByLink("selector").Elements()).To(ContainElement(&api.Element{Session: session}))
})
})
Describe("#AllByLabel", func() {
It("should apply an un-indexed label selector and return a selection with the same session", func() {
Expect(page.AllByLabel("selector").String()).To(Equal(`selection 'Label: "selector"'`))
Expect(page.AllByLabel("selector").Elements()).To(ContainElement(&api.Element{Session: session}))
})
})
Describe("#AllByButton", func() {
It("should apply an un-indexed button text selector and return a selection with the same session", func() {
Expect(page.AllByButton("selector").String()).To(Equal(`selection 'Button: "selector"'`))
Expect(page.AllByButton("selector").Elements()).To(ContainElement(&api.Element{Session: session}))
})
})
Describe("#AllByClass", func() {
It("should apply an un-indexed class selector and return a selection with the same session", func() {
Expect(page.AllByClass("selector").String()).To(Equal(`selection 'Class: selector'`))
Expect(page.AllByClass("selector").Elements()).To(ContainElement(&api.Element{Session: session}))
})
})
Describe("#AllByID", func() {
It("should apply an un-indexed id selector and return a selection with the same session", func() {
Expect(page.AllByID("selector").String()).To(Equal(`selection 'ID: selector'`))
Expect(page.AllByID("selector").Elements()).To(ContainElement(&api.Element{Session: session}))
})
})
})