forked from robdimsdale/garagepi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
page_matchers.go
57 lines (50 loc) · 2.14 KB
/
page_matchers.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
package matchers
import (
"github.com/onsi/gomega/types"
"github.com/sclevine/agouti/matchers/internal"
)
// HaveTitle passes when the expected title is equivalent to the
// title of the provided page.
func HaveTitle(title string) types.GomegaMatcher {
return &internal.ValueMatcher{Method: "Title", Property: "title", Expected: title}
}
// HaveURL passes when the expected URL is equivalent to the
// current URL of the provided page.
func HaveURL(url string) types.GomegaMatcher {
return &internal.ValueMatcher{Method: "URL", Property: "URL", Expected: url}
}
// HavePopupText passes when the expected text is equivalent to the
// text contents of an open alert, confirm, or prompt popup.
func HavePopupText(text string) types.GomegaMatcher {
return &internal.ValueMatcher{Method: "PopupText", Property: "popup text", Expected: text}
}
// HaveWindowCount passes when the expected window count is equivalent
// to the number of open windows.
func HaveWindowCount(count int) types.GomegaMatcher {
return &internal.ValueMatcher{Method: "WindowCount", Property: "window count", Expected: count}
}
// HaveLoggedError passes when all of the expected log messages are logged as
// errors in the browser console. If no message is provided, this matcher will
// pass if any error message has been logged. When negated, this matcher will
// only fail if all of the provided messages are logged.
func HaveLoggedError(messages ...string) types.GomegaMatcher {
return &internal.LogMatcher{
ExpectedMessages: messages,
Levels: []string{"WARNING", "SEVERE"},
Name: "error",
Type: "browser",
}
}
// HaveLoggedInfo passes when all of the expected log messages are logged in
// the browser console. If no messages are provided, this matcher will pass if
// any message has been logged. When negated, this matcher will only fail if
// all of the provided messages are logged. Error logs are not considered in
// any of these cases.
func HaveLoggedInfo(messages ...string) types.GomegaMatcher {
return &internal.LogMatcher{
ExpectedMessages: messages,
Levels: []string{"INFO"},
Name: "info",
Type: "browser",
}
}