-
Notifications
You must be signed in to change notification settings - Fork 4
/
title.go
57 lines (47 loc) · 1.45 KB
/
title.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 conditions is providing some conditions for WebDriver.Wait() function
// from the "github.com/tebeka/selenium" package.
package conditions
import (
"strings"
"github.com/tebeka/selenium"
)
// TitleIs returns a condition that checks if the title matches the expectedTitle.
func TitleIs(expectedTitle string) selenium.Condition {
return func(wd selenium.WebDriver) (bool, error) {
title, err := wd.Title()
if err != nil {
return false, err
}
return title == expectedTitle, nil
}
}
// TitleIsNot returns a condition that checks if the title doesn't match the expectedTitle.
func TitleIsNot(expectedTitle string) selenium.Condition {
return func(wd selenium.WebDriver) (bool, error) {
title, err := wd.Title()
if err != nil {
return false, err
}
return title != expectedTitle, nil
}
}
// TitleContains returns a condition that checks if the title includes the substring.
func TitleContains(substring string) selenium.Condition {
return func(wd selenium.WebDriver) (bool, error) {
title, err := wd.Title()
if err != nil {
return false, err
}
return strings.Contains(title, substring), nil
}
}
// TitleNotContains returns a condition that checks if the title doesn't include the substring.
func TitleNotContains(substring string) selenium.Condition {
return func(wd selenium.WebDriver) (bool, error) {
title, err := wd.Title()
if err != nil {
return false, err
}
return !strings.Contains(title, substring), nil
}
}