-
Notifications
You must be signed in to change notification settings - Fork 115
/
Program.cs
164 lines (141 loc) · 5.38 KB
/
Program.cs
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
using System;
using System.Collections.Generic;
using System.Net;
using canopy;
using canopy.csharp.loadTest;
using _ = canopy.csharp.canopy;
namespace csharptests
{
class Program
{
static void Main(string[] args)
{
configuration.elementTimeout = 3.0;
configuration.compareTimeout = 3.0;
configuration.pageTimeout = 3.0;
configuration.reporter = new reporters.LiveHtmlReporter(types.BrowserStartMode.Chrome, configuration.chromeDir);
var testpage = "http://lefthandedgoat.github.io/canopy/testpages/";
jsonValidatorTests.All();
_.start(types.BrowserStartMode.Chrome);
_.context("context1");
_.once(() => Console.WriteLine("once"));
_.before(() => Console.WriteLine("before"));
_.after(() => Console.WriteLine("after"));
_.lastly(() => Console.WriteLine("lastly"));
_.skip("intentionally skipped shows blue in LiveHtmlReport", () =>
{
_.url("http://www.skipped.com");
});
_.test("Apostrophes don't break anything", () =>
{
_.url(testpage);
_.count("I've got an apostrophe", 1);
});
_.test("#firstName should have John (using == infix operator)", () =>
{
_.url(testpage);
_.eq("#firstName", "John");
});
_.test("#lastName should have Doe via read IWebElements", () =>
{
_.url(testpage);
var e = _.element("#lastname");
var value = _.read(e);
_.equality(value, "Doe");
});
_.test("clearing #firstName sets text to new empty string", () =>
{
_.url(testpage);
_.clear("#firstName");
_.eq("#firstName", "");
});
_.test("clearing #firstName sets text to new empty string via IWebElement", () =>
{
_.url(testpage);
_.clear(_.element("#firstName"));
_.eq("#firstName", "");
});
_.test("writing to #lastName sets text to Smith", () =>
{
_.url(testpage);
_.clear("#lastName");
_.write("#lastName", "Smith");
_.eq("#lastName", "Smith");
});
_.test("writing to #lastName (as element) sets text to John", () =>
{
_.url(testpage);
var lastname = _.element("#lastname");
_.clear(lastname);
_.write(lastname, "John");
_.eq("#lastname", "John");
});
_.test("Value 1 listed in #value_list", () =>
{
_.url(testpage);
_.starEq("#value_list td", "Value 1");
});
_.test("clicking #button sets #button_clicked to button clicked", () =>
{
_.url(testpage);
_.eq("#button_clicked", "button not clicked");
_.click("#button");
_.eq("#button_clicked", "button clicked");
});
_.test("clicking #radio1 selects it", () =>
{
_.url(testpage);
_.click("#radio1");
_.selected("#radio1");
});
_.test("clicking #radio1 selects it", () =>
{
_.url(testpage);
_.check("#checkbox");
_.uncheck("#checkbox");
_.deselected("#checkbox");
});
_.test("clicking #radio1 selects it", () =>
{
_.url("https://api.jquery.com/contextmenu/");
var iframe = _.element("iframe");
_.browser.SwitchTo().Frame(iframe);
_.notDisplayed(".contextmenu");
_.rightClick("div:first");
_.displayed(".contextmenu");
});
_.skip("load test example", () =>
{
var job = new job(
warmup: true,
baseline: true,
acceptableRatioPercent: 200,
minutes: 1,
load: 1,
tasks: new List<task>
{
new task(
description: "task1",
action: () =>
{
using (var client = new System.Net.Http.HttpClient()) {client.GetStringAsync("http://www.turtletest.com/chris");}
Console.WriteLine("task1");
},
frequency: 6),
new task(
description: "task2",
action: () =>
{
using (var client = new WebClient()) { client.DownloadString("http://www.turtletest.com/chris");}
Console.WriteLine("task2");
},
frequency: 6)
});
canopy.csharp.loadTest.runner.run(job);
});
_.run();
Console.ReadKey();
_.quit();
}
}
}