-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathparser_test.go
More file actions
66 lines (58 loc) · 1.7 KB
/
Copy pathparser_test.go
File metadata and controls
66 lines (58 loc) · 1.7 KB
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
package webdriver
import (
"github.com/stretchr/testify/assert"
"github.com/viant/assertly"
"testing"
)
func TestParser_Parse(t *testing.T) {
var useCases = []struct {
Description string
Command string
Expected *Action
HasError bool
}{
{
Description: "WebDriver call",
Command: "get(http://127.0.0.1:8888/signup/)",
Expected: NewAction("", "", "Get", "http://127.0.0.1:8888/signup/"),
},
{
Description: "WebDriver call empty",
Command: "get",
Expected: NewAction("", "", "Get"),
},
{
Description: "WebDriver call assigments",
Command: "key1 = get(http://127.0.0.1:8888/signup/)",
Expected: NewAction("key1", "", "Get", "http://127.0.0.1:8888/signup/"),
},
{
Description: "WebElement call",
Command: "(#email).clear",
Expected: NewAction("", "#email", "Clear"),
},
{
Description: "xpath selector WebElement call",
Command: "(xpath://SMALL[preceding-sibling::INPUT[@id='dateOfBirth']]).text",
Expected: NewAction("", "//SMALL[preceding-sibling::INPUT[@id='dateOfBirth']]", "Text"),
},
{
Description: "xpath selector WebElement call assigment",
Command: "key1 = (xpath://SMALL[preceding-sibling::INPUT[@id='dateOfBirth']]).text",
Expected: NewAction("key1", "//SMALL[preceding-sibling::INPUT[@id='dateOfBirth']]", "Text"),
},
}
parser := &parser{}
for _, useCase := range useCases {
//fmt.Println(useCase.Command)
action, err := parser.Parse(useCase.Command)
if useCase.HasError {
assert.NotNil(t, err, useCase.Description)
continue
}
if !assert.Nil(t, err, useCase.Description) {
continue
}
assertly.AssertValues(t, useCase.Expected, action, useCase.Description)
}
}