-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathexpected_test.go
55 lines (43 loc) · 1.11 KB
/
expected_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
package marionette_client
import (
"errors"
"testing"
"time"
)
type fakeFinder struct {
ReturnError bool
}
func (f fakeFinder) FindElement(by By, value string) (*WebElement, error) {
if f.ReturnError {
return nil, errors.New("ReturnError set.")
}
return new(WebElement), nil
}
func (f fakeFinder) FindElements(by By, value string) ([]*WebElement, error) {
if f.ReturnError {
return nil, errors.New("ReturnError set.")
}
var e []*WebElement
return e, nil
}
func TestExpected(t *testing.T) {
t.Run("ElementIsPresentFalseTest", ElementIsPresentFalseTest)
}
func ElementIsPresentFalseTest(t *testing.T) {
fake := new(fakeFinder)
fake.ReturnError = true
fun := ElementIsPresent(By(Id), "")
r, _, _ := fun(fake)
if r {
t.Fatalf("%v", "Result should be false")
}
}
// required test in sequential main client test: client_test.go
func NotPresentTest(t *testing.T) {
timeout := time.Duration(5) * time.Second
condition := ElementIsNotPresent(By(Id), "non-existing-element")
ok, _, _ := Wait(client).For(timeout).Until(condition)
if !ok {
t.Fatal("Element Was Found in ElementIsNotPresent test.")
}
}