@seleniumhq/code-export-csharp-nunit 4.0.12 → 4.1.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__test__/src/__snapshots__/command.spec.js.snap +53 -29
- package/__test__/src/__snapshots__/index.spec.js.snap +62 -34
- package/__test__/src/command.spec.js +66 -59
- package/__test__/src/index.spec.js +40 -64
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/jest.config.js +14 -0
- package/package.json +7 -3
- package/src/index.ts +5 -2
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://
|
|
1
|
+
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
|
|
2
2
|
|
|
3
3
|
exports[`command code emitter should emit 'assert selected label' command 1`] = `
|
|
4
4
|
"{
|
|
@@ -20,6 +20,10 @@ exports[`command code emitter should emit 'verify selected label' command 1`] =
|
|
|
20
20
|
}"
|
|
21
21
|
`;
|
|
22
22
|
|
|
23
|
+
exports[`command code emitter should emit \`accept alert\` command 1`] = `"driver.SwitchTo().Alert().Accept();"`;
|
|
24
|
+
|
|
25
|
+
exports[`command code emitter should emit \`accept confirmation\` command 1`] = `"driver.SwitchTo().Alert().Accept();"`;
|
|
26
|
+
|
|
23
27
|
exports[`command code emitter should emit \`add selection\` command 1`] = `
|
|
24
28
|
"{
|
|
25
29
|
var dropdown = driver.FindElement(By.CssSelector(\\"select\\"));
|
|
@@ -27,7 +31,13 @@ exports[`command code emitter should emit \`add selection\` command 1`] = `
|
|
|
27
31
|
}"
|
|
28
32
|
`;
|
|
29
33
|
|
|
30
|
-
exports[`command code emitter should emit \`answer
|
|
34
|
+
exports[`command code emitter should emit \`answer prompt\` command 1`] = `
|
|
35
|
+
"{
|
|
36
|
+
var Alert = driver.SwitchTo().Alert();
|
|
37
|
+
Alert.SendKeys(\\"an answer\\");
|
|
38
|
+
Alert.Accept();
|
|
39
|
+
}"
|
|
40
|
+
`;
|
|
31
41
|
|
|
32
42
|
exports[`command code emitter should emit \`assert alert\` command 1`] = `"Assert.That(driver.SwitchTo().Alert().Text, Is.EqualTo(\\"an alert\\"));"`;
|
|
33
43
|
|
|
@@ -94,7 +104,7 @@ exports[`command code emitter should emit \`assert value\` command 1`] = `
|
|
|
94
104
|
}"
|
|
95
105
|
`;
|
|
96
106
|
|
|
97
|
-
exports[`command code emitter should emit \`assert\` command 1`] = `"Assert.That(vars[\\"varrrName\\"]
|
|
107
|
+
exports[`command code emitter should emit \`assert\` command 1`] = `"Assert.That(Convert.ToString(vars[\\"varrrName\\"]), Is.EqualTo(\\"blah\\"));"`;
|
|
98
108
|
|
|
99
109
|
exports[`command code emitter should emit \`check\` command 1`] = `
|
|
100
110
|
"{
|
|
@@ -105,19 +115,20 @@ exports[`command code emitter should emit \`check\` command 1`] = `
|
|
|
105
115
|
}"
|
|
106
116
|
`;
|
|
107
117
|
|
|
108
|
-
exports[`command code emitter should emit \`choose cancel on visible prompt\` command 1`] = `undefined`;
|
|
109
|
-
|
|
110
|
-
exports[`command code emitter should emit \`choose ok on visible confirmation\` command 1`] = `undefined`;
|
|
111
|
-
|
|
112
118
|
exports[`command code emitter should emit \`click at\` command 1`] = `"driver.FindElement(By.LinkText(\\"button\\")).Click();"`;
|
|
113
119
|
|
|
114
120
|
exports[`command code emitter should emit \`click\` command 1`] = `"driver.FindElement(By.LinkText(\\"button\\")).Click();"`;
|
|
115
121
|
|
|
116
122
|
exports[`command code emitter should emit \`close\` command 1`] = `"driver.Close();"`;
|
|
117
123
|
|
|
124
|
+
exports[`command code emitter should emit \`dismiss confirmation\` command 1`] = `"driver.SwitchTo().Alert().Dismiss();"`;
|
|
125
|
+
|
|
126
|
+
exports[`command code emitter should emit \`dismiss prompt\` command 1`] = `"driver.SwitchTo().Alert().Dismiss();"`;
|
|
127
|
+
|
|
118
128
|
exports[`command code emitter should emit \`do\` command 1`] = `
|
|
119
129
|
Object {
|
|
120
|
-
"body": "
|
|
130
|
+
"body": "var loop1 = 0;
|
|
131
|
+
do {",
|
|
121
132
|
"endingLevel": 1,
|
|
122
133
|
}
|
|
123
134
|
`;
|
|
@@ -149,7 +160,7 @@ exports[`command code emitter should emit \`drag and drop to object\` command 1`
|
|
|
149
160
|
|
|
150
161
|
exports[`command code emitter should emit \`echo\` command 1`] = `"Console.WriteLine(\\"blah\\");"`;
|
|
151
162
|
|
|
152
|
-
exports[`command code emitter should emit \`echo\` command with variables 1`] = `"Console.WriteLine(vars[\\"blah\\"]
|
|
163
|
+
exports[`command code emitter should emit \`echo\` command with variables 1`] = `"Console.WriteLine(Convert.ToString(vars[\\"blah\\"]));"`;
|
|
153
164
|
|
|
154
165
|
exports[`command code emitter should emit \`edit content\` command 1`] = `
|
|
155
166
|
"{
|
|
@@ -179,7 +190,7 @@ Object {
|
|
|
179
190
|
}
|
|
180
191
|
`;
|
|
181
192
|
|
|
182
|
-
exports[`command code emitter should emit \`execute async script\` command 1`] = `"vars[\\"myVar\\"] = js.
|
|
193
|
+
exports[`command code emitter should emit \`execute async script\` command 1`] = `"vars[\\"myVar\\"] = js.ExecuteAsyncScript(\\"var callback = arguments[arguments.length - 1];javascript.then(callback).catch(callback);\\");"`;
|
|
183
194
|
|
|
184
195
|
exports[`command code emitter should emit \`execute script\` command 1`] = `"vars[\\"myVar\\"] = js.ExecuteScript(\\"javascript\\");"`;
|
|
185
196
|
|
|
@@ -275,15 +286,20 @@ exports[`command code emitter should emit \`remove selection\` command 1`] = `
|
|
|
275
286
|
}"
|
|
276
287
|
`;
|
|
277
288
|
|
|
278
|
-
exports[`command code emitter should emit \`repeatIf\` command 1`] = `
|
|
289
|
+
exports[`command code emitter should emit \`repeatIf\` command 1`] = `
|
|
290
|
+
" if (++loop1 > 1000) throw new Exception(\\"Max retry limit exceeded\\");
|
|
291
|
+
} while ((Boolean) js.ExecuteScript(\\"return (true)\\"));"
|
|
292
|
+
`;
|
|
279
293
|
|
|
280
294
|
exports[`command code emitter should emit \`run script\` command 1`] = `"js.ExecuteScript(\\"alert('test');alert('Im annoying');\\");"`;
|
|
281
295
|
|
|
282
|
-
exports[`command code emitter should emit \`run\` command 1`] = `"
|
|
296
|
+
exports[`command code emitter should emit \`run\` command 1`] = `"run_sometestcase();"`;
|
|
297
|
+
|
|
298
|
+
exports[`command code emitter should emit \`run\` command for a test with a capitalized name 1`] = `"run_SomeTestCase();"`;
|
|
283
299
|
|
|
284
300
|
exports[`command code emitter should emit \`select frame\` to select the top frame 1`] = `"driver.SwitchTo().DefaultContent();"`;
|
|
285
301
|
|
|
286
|
-
exports[`command code emitter should emit \`select window\` to select a window by handle 1`] = `"driver.SwitchTo().Window(vars[\\"window\\"]
|
|
302
|
+
exports[`command code emitter should emit \`select window\` to select a window by handle 1`] = `"driver.SwitchTo().Window(Convert.ToString(vars[\\"window\\"]));"`;
|
|
287
303
|
|
|
288
304
|
exports[`command code emitter should emit \`select window\` to select a window by implicit index 1`] = `
|
|
289
305
|
"{
|
|
@@ -312,7 +328,7 @@ exports[`command code emitter should emit \`send keys\` command 1`] = `"driver.F
|
|
|
312
328
|
|
|
313
329
|
exports[`command code emitter should emit \`send keys\` command with a key press 1`] = `"driver.FindElement(By.Id(\\"input\\")).SendKeys(\\"SuperSecretPassword!\\" + Keys.Enter);"`;
|
|
314
330
|
|
|
315
|
-
exports[`command code emitter should emit \`send keys\` command with a variable input 1`] = `"driver.FindElement(By.Id(\\"input\\")).SendKeys(vars[\\"blah\\"]
|
|
331
|
+
exports[`command code emitter should emit \`send keys\` command with a variable input 1`] = `"driver.FindElement(By.Id(\\"input\\")).SendKeys(Convert.ToString(vars[\\"blah\\"]));"`;
|
|
316
332
|
|
|
317
333
|
exports[`command code emitter should emit \`set speed\` 1`] = `"Console.WriteLine(\\"\`set speed\` is a no-op in code export, use \`pause\` instead\\");"`;
|
|
318
334
|
|
|
@@ -326,7 +342,9 @@ exports[`command code emitter should emit \`store attribute\` command 1`] = `
|
|
|
326
342
|
}"
|
|
327
343
|
`;
|
|
328
344
|
|
|
329
|
-
exports[`command code emitter should emit \`store
|
|
345
|
+
exports[`command code emitter should emit \`store element count\` command 1`] = `"vars[\\"myVar\\"] = driver.FindElements(By.XPath(\\"button\\")).Count;"`;
|
|
346
|
+
|
|
347
|
+
exports[`command code emitter should emit \`store json\` command 1`] = `"vars[\\"myVar\\"] = System.Text.Json.JsonSerializer.Deserialize<List<object>>(\\"[{\\\\\\"a\\\\\\":0}]\\");"`;
|
|
330
348
|
|
|
331
349
|
exports[`command code emitter should emit \`store text\` command 1`] = `"vars[\\"myVar\\"] = driver.FindElement(By.Id(\\"someElement\\")).Text;"`;
|
|
332
350
|
|
|
@@ -336,16 +354,22 @@ exports[`command code emitter should emit \`store value\` command 1`] = `"vars[\
|
|
|
336
354
|
|
|
337
355
|
exports[`command code emitter should emit \`store window handle\` command 1`] = `"vars[\\"windowName\\"] = driver.CurrentWindowHandle;"`;
|
|
338
356
|
|
|
339
|
-
exports[`command code emitter should emit \`store xpath count\` command 1`] = `"vars[\\"myVar\\"] = driver.FindElements(By.XPath(\\"button\\")).Count;"`;
|
|
340
|
-
|
|
341
357
|
exports[`command code emitter should emit \`store\` command 1`] = `"vars[\\"myVar\\"] = \\"some value\\";"`;
|
|
342
358
|
|
|
343
|
-
exports[`command code emitter should emit \`submit\` command 1`] = `"throw new System.Exception(\\"\`submit\` is not a supported command in Selenium WebDriver. Please re-record the step in the IDE.\\");"`;
|
|
344
|
-
|
|
345
359
|
exports[`command code emitter should emit \`times\` command 1`] = `
|
|
346
360
|
Object {
|
|
347
|
-
"body": "var
|
|
348
|
-
for(
|
|
361
|
+
"body": "var times1 = 5;
|
|
362
|
+
for (var loop1 = 0; loop1 < times1; loop1++) {
|
|
363
|
+
if (loop1 >= 1000) throw new Exception(\\"Max retry limit exceeded\\");",
|
|
364
|
+
"endingLevel": 1,
|
|
365
|
+
}
|
|
366
|
+
`;
|
|
367
|
+
|
|
368
|
+
exports[`command code emitter should emit \`times\` command with a variable count 1`] = `
|
|
369
|
+
Object {
|
|
370
|
+
"body": "var times1 = (int)Math.Floor(Convert.ToDouble(Convert.ToString(vars[\\"count\\"]), System.Globalization.CultureInfo.InvariantCulture));
|
|
371
|
+
for (var loop1 = 0; loop1 < times1; loop1++) {
|
|
372
|
+
if (loop1 >= 1000) throw new Exception(\\"Max retry limit exceeded\\");",
|
|
349
373
|
"endingLevel": 1,
|
|
350
374
|
}
|
|
351
375
|
`;
|
|
@@ -420,7 +444,7 @@ exports[`command code emitter should emit \`verify value\` command 1`] = `
|
|
|
420
444
|
}"
|
|
421
445
|
`;
|
|
422
446
|
|
|
423
|
-
exports[`command code emitter should emit \`verify\` command 1`] = `"Assert.That(vars[\\"varrrName\\"]
|
|
447
|
+
exports[`command code emitter should emit \`verify\` command 1`] = `"Assert.That(Convert.ToString(vars[\\"varrrName\\"]), Is.EqualTo(\\"blah\\"));"`;
|
|
424
448
|
|
|
425
449
|
exports[`command code emitter should emit \`waitForElementEditable\` command 1`] = `
|
|
426
450
|
"{
|
|
@@ -473,21 +497,21 @@ exports[`command code emitter should emit \`waitForText\` command 1`] = `
|
|
|
473
497
|
|
|
474
498
|
exports[`command code emitter should emit \`while\` command 1`] = `
|
|
475
499
|
Object {
|
|
476
|
-
"body": "
|
|
500
|
+
"body": "var loop1 = 0;
|
|
501
|
+
while ((Boolean) js.ExecuteScript(\\"return (true)\\")) {
|
|
502
|
+
if (++loop1 > 1000) throw new Exception(\\"Max retry limit exceeded\\");",
|
|
477
503
|
"endingLevel": 1,
|
|
478
504
|
}
|
|
479
505
|
`;
|
|
480
506
|
|
|
507
|
+
exports[`command code emitter should emit a comment for \`run\` with a test name from a variable 1`] = `"// Cannot export run with a test name from a variable: Convert.ToString(vars[\\"testName\\"])"`;
|
|
508
|
+
|
|
481
509
|
exports[`command code emitter should emit new window handling, if command opens a new window 1`] = `
|
|
482
510
|
"vars[\\"WindowHandles\\"] = driver.WindowHandles;
|
|
483
511
|
driver.FindElement(By.CssSelector(\\"button\\")).Click();
|
|
484
512
|
vars[\\"newWin\\"] = waitForWindow(2000);"
|
|
485
513
|
`;
|
|
486
514
|
|
|
487
|
-
exports[`command code emitter should
|
|
488
|
-
|
|
489
|
-
exports[`command code emitter should skip playback supported commands, that are not supported in webdriver 2`] = `""`;
|
|
490
|
-
|
|
491
|
-
exports[`command code emitter should skip playback supported commands, that are not supported in webdriver 3`] = `""`;
|
|
515
|
+
exports[`command code emitter should escape the variable name of \`store json\` 1`] = `"vars[\\"x\\\\\\"); System.exit(1); //\\"] = System.Text.Json.JsonSerializer.Deserialize<object>(\\"{\\\\\\"a\\\\\\":0}\\");"`;
|
|
492
516
|
|
|
493
|
-
exports[`command code emitter should
|
|
517
|
+
exports[`command code emitter should store a json array as a list 1`] = `"vars[\\"list\\"] = System.Text.Json.JsonSerializer.Deserialize<List<object>>(\\"[1, 2]\\");"`;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://
|
|
1
|
+
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
|
|
2
2
|
|
|
3
3
|
exports[`Code Export C# NUnit should export a suite 1`] = `
|
|
4
4
|
"// Generated by Selenium IDE
|
|
@@ -14,11 +14,13 @@ using OpenQA.Selenium.Remote;
|
|
|
14
14
|
using OpenQA.Selenium.Support.UI;
|
|
15
15
|
using OpenQA.Selenium.Interactions;
|
|
16
16
|
using NUnit.Framework;
|
|
17
|
+
|
|
17
18
|
[TestFixture]
|
|
18
19
|
public class LoginTest {
|
|
19
20
|
private IWebDriver driver;
|
|
20
21
|
public IDictionary<string, object> vars {get; private set;}
|
|
21
22
|
private IJavaScriptExecutor js;
|
|
23
|
+
|
|
22
24
|
[SetUp]
|
|
23
25
|
public void SetUp() {
|
|
24
26
|
driver = new ChromeDriver();
|
|
@@ -36,7 +38,7 @@ public class LoginTest {
|
|
|
36
38
|
driver.FindElement(By.Id(\\"username\\")).SendKeys(\\"tomsmith\\");
|
|
37
39
|
driver.FindElement(By.Id(\\"password\\")).SendKeys(\\"SuperSecretPassword!\\");
|
|
38
40
|
driver.FindElement(By.CssSelector(\\"#login button\\")).Click();
|
|
39
|
-
Assert.That(driver.FindElement(By.CssSelector(\\".flash.success\\")).Text, Is.EqualTo(\\"You logged into a secure area
|
|
41
|
+
Assert.That(driver.FindElement(By.CssSelector(\\".flash.success\\")).Text, Is.EqualTo(\\"You logged into a secure area!\\\\\\\\n×\\"));
|
|
40
42
|
}
|
|
41
43
|
[Test]
|
|
42
44
|
public void invalidcredentials() {
|
|
@@ -45,7 +47,7 @@ public class LoginTest {
|
|
|
45
47
|
driver.FindElement(By.Id(\\"username\\")).SendKeys(\\"blah\\");
|
|
46
48
|
driver.FindElement(By.Id(\\"password\\")).SendKeys(\\"blah\\");
|
|
47
49
|
driver.FindElement(By.CssSelector(\\"#login button\\")).Click();
|
|
48
|
-
Assert.That(driver.FindElement(By.Id(\\"flash\\")).Text, Is.EqualTo(\\"Your username is invalid
|
|
50
|
+
Assert.That(driver.FindElement(By.Id(\\"flash\\")).Text, Is.EqualTo(\\"Your username is invalid!\\\\\\\\n×\\"));
|
|
49
51
|
}
|
|
50
52
|
}
|
|
51
53
|
"
|
|
@@ -65,11 +67,13 @@ using OpenQA.Selenium.Remote;
|
|
|
65
67
|
using OpenQA.Selenium.Support.UI;
|
|
66
68
|
using OpenQA.Selenium.Interactions;
|
|
67
69
|
using NUnit.Framework;
|
|
70
|
+
|
|
68
71
|
[TestFixture]
|
|
69
72
|
public class ControlflowTest {
|
|
70
73
|
private IWebDriver driver;
|
|
71
74
|
public IDictionary<string, object> vars {get; private set;}
|
|
72
75
|
private IJavaScriptExecutor js;
|
|
76
|
+
|
|
73
77
|
[SetUp]
|
|
74
78
|
public void SetUp() {
|
|
75
79
|
driver = new ChromeDriver();
|
|
@@ -90,7 +94,7 @@ public class ControlflowTest {
|
|
|
90
94
|
} else {
|
|
91
95
|
vars[\\"output\\"] = js.ExecuteScript(\\"return 'c'\\");
|
|
92
96
|
}
|
|
93
|
-
Assert.That(vars[\\"output\\"]
|
|
97
|
+
Assert.That(Convert.ToString(vars[\\"output\\"]), Is.EqualTo(\\"a\\"));
|
|
94
98
|
}
|
|
95
99
|
[Test]
|
|
96
100
|
public void controlflowelseif() {
|
|
@@ -102,7 +106,7 @@ public class ControlflowTest {
|
|
|
102
106
|
} else {
|
|
103
107
|
vars[\\"output\\"] = js.ExecuteScript(\\"return 'c'\\");
|
|
104
108
|
}
|
|
105
|
-
Assert.That(vars[\\"output\\"]
|
|
109
|
+
Assert.That(Convert.ToString(vars[\\"output\\"]), Is.EqualTo(\\"b\\"));
|
|
106
110
|
}
|
|
107
111
|
[Test]
|
|
108
112
|
public void controlflowelse() {
|
|
@@ -114,32 +118,37 @@ public class ControlflowTest {
|
|
|
114
118
|
} else {
|
|
115
119
|
vars[\\"output\\"] = js.ExecuteScript(\\"return 'c'\\");
|
|
116
120
|
}
|
|
117
|
-
Assert.That(vars[\\"output\\"]
|
|
121
|
+
Assert.That(Convert.ToString(vars[\\"output\\"]), Is.EqualTo(\\"c\\"));
|
|
118
122
|
}
|
|
119
123
|
[Test]
|
|
120
124
|
public void controlflowdo() {
|
|
121
125
|
vars[\\"check\\"] = js.ExecuteScript(\\"return 1\\");
|
|
126
|
+
var loop1 = 0;
|
|
122
127
|
do {
|
|
123
128
|
vars[\\"check\\"] = js.ExecuteScript(\\"return arguments[0] + 1\\", vars[\\"check\\"]);
|
|
129
|
+
if (++loop1 > 1000) throw new Exception(\\"Max retry limit exceeded\\");
|
|
124
130
|
} while ((Boolean) js.ExecuteScript(\\"return (arguments[0] < 3)\\", vars[\\"check\\"]));
|
|
125
|
-
Assert.That(vars[\\"check\\"]
|
|
131
|
+
Assert.That(Convert.ToString(vars[\\"check\\"]), Is.EqualTo(\\"3\\"));
|
|
126
132
|
}
|
|
127
133
|
[Test]
|
|
128
134
|
public void controlflowtimes() {
|
|
129
135
|
vars[\\"check\\"] = js.ExecuteScript(\\"return 1\\");
|
|
130
|
-
var
|
|
131
|
-
for(
|
|
136
|
+
var times1 = 2;
|
|
137
|
+
for (var loop1 = 0; loop1 < times1; loop1++) {
|
|
138
|
+
if (loop1 >= 1000) throw new Exception(\\"Max retry limit exceeded\\");
|
|
132
139
|
vars[\\"check\\"] = js.ExecuteScript(\\"return arguments[0] + 1\\", vars[\\"check\\"]);
|
|
133
140
|
}
|
|
134
|
-
Assert.That(vars[\\"check\\"]
|
|
141
|
+
Assert.That(Convert.ToString(vars[\\"check\\"]), Is.EqualTo(\\"3\\"));
|
|
135
142
|
}
|
|
136
143
|
[Test]
|
|
137
144
|
public void controlflowwhile() {
|
|
138
145
|
vars[\\"check\\"] = js.ExecuteScript(\\"return 1\\");
|
|
146
|
+
var loop1 = 0;
|
|
139
147
|
while ((Boolean) js.ExecuteScript(\\"return (arguments[0] < 3)\\", vars[\\"check\\"])) {
|
|
148
|
+
if (++loop1 > 1000) throw new Exception(\\"Max retry limit exceeded\\");
|
|
140
149
|
vars[\\"check\\"] = js.ExecuteScript(\\"return arguments[0] + 1\\", vars[\\"check\\"]);
|
|
141
150
|
}
|
|
142
|
-
Assert.That(vars[\\"check\\"]
|
|
151
|
+
Assert.That(Convert.ToString(vars[\\"check\\"]), Is.EqualTo(\\"3\\"));
|
|
143
152
|
}
|
|
144
153
|
}
|
|
145
154
|
"
|
|
@@ -159,11 +168,13 @@ using OpenQA.Selenium.Remote;
|
|
|
159
168
|
using OpenQA.Selenium.Support.UI;
|
|
160
169
|
using OpenQA.Selenium.Interactions;
|
|
161
170
|
using NUnit.Framework;
|
|
171
|
+
|
|
162
172
|
[TestFixture]
|
|
163
173
|
public class ReusedmethodsTest {
|
|
164
174
|
private IWebDriver driver;
|
|
165
175
|
public IDictionary<string, object> vars {get; private set;}
|
|
166
176
|
private IJavaScriptExecutor js;
|
|
177
|
+
|
|
167
178
|
[SetUp]
|
|
168
179
|
public void SetUp() {
|
|
169
180
|
driver = new ChromeDriver();
|
|
@@ -174,36 +185,37 @@ public class ReusedmethodsTest {
|
|
|
174
185
|
protected void TearDown() {
|
|
175
186
|
driver.Quit();
|
|
176
187
|
}
|
|
177
|
-
public void
|
|
188
|
+
public void run_login() {
|
|
178
189
|
driver.Navigate().GoToUrl(\\"https://the-internet.herokuapp.com/\\");
|
|
179
190
|
driver.FindElement(By.LinkText(\\"Form Authentication\\")).Click();
|
|
180
|
-
driver.FindElement(By.Id(\\"username\\")).SendKeys(vars[\\"username\\"]
|
|
181
|
-
driver.FindElement(By.Id(\\"password\\")).SendKeys(vars[\\"password\\"]
|
|
191
|
+
driver.FindElement(By.Id(\\"username\\")).SendKeys(Convert.ToString(vars[\\"username\\"]));
|
|
192
|
+
driver.FindElement(By.Id(\\"password\\")).SendKeys(Convert.ToString(vars[\\"password\\"]));
|
|
182
193
|
if ((Boolean) js.ExecuteScript(\\"return (true)\\")) {
|
|
183
194
|
driver.FindElement(By.CssSelector(\\".fa\\")).Click();
|
|
184
195
|
}
|
|
185
196
|
}
|
|
186
|
-
public void
|
|
197
|
+
public void run_tinymethod() {
|
|
187
198
|
vars[\\"value\\"] = \\"field\\";
|
|
188
199
|
}
|
|
200
|
+
|
|
189
201
|
[Test]
|
|
190
202
|
public void invalidcredentials() {
|
|
191
203
|
vars[\\"username\\"] = \\"blah\\";
|
|
192
204
|
vars[\\"password\\"] = \\"blah\\";
|
|
193
|
-
|
|
205
|
+
run_login();
|
|
194
206
|
}
|
|
195
207
|
[Test]
|
|
196
208
|
public void validcredentials() {
|
|
197
209
|
vars[\\"username\\"] = \\"tomsmith\\";
|
|
198
210
|
vars[\\"password\\"] = \\"SuperSecretPassword!\\";
|
|
199
|
-
|
|
211
|
+
run_login();
|
|
200
212
|
}
|
|
201
213
|
[Test]
|
|
202
214
|
public void twomethods() {
|
|
203
215
|
vars[\\"username\\"] = \\"blah\\";
|
|
204
216
|
vars[\\"password\\"] = \\"blah\\";
|
|
205
|
-
|
|
206
|
-
|
|
217
|
+
run_login();
|
|
218
|
+
run_tinymethod();
|
|
207
219
|
}
|
|
208
220
|
}
|
|
209
221
|
"
|
|
@@ -223,11 +235,13 @@ using OpenQA.Selenium.Remote;
|
|
|
223
235
|
using OpenQA.Selenium.Support.UI;
|
|
224
236
|
using OpenQA.Selenium.Interactions;
|
|
225
237
|
using NUnit.Framework;
|
|
238
|
+
|
|
226
239
|
[TestFixture]
|
|
227
240
|
public class DefaultSuiteTest {
|
|
228
241
|
private IWebDriver driver;
|
|
229
242
|
public IDictionary<string, object> vars {get; private set;}
|
|
230
243
|
private IJavaScriptExecutor js;
|
|
244
|
+
|
|
231
245
|
[SetUp]
|
|
232
246
|
public void SetUp() {
|
|
233
247
|
driver = new ChromeDriver();
|
|
@@ -252,17 +266,18 @@ public class DefaultSuiteTest {
|
|
|
252
266
|
return whNow.First().ToString();
|
|
253
267
|
}
|
|
254
268
|
}
|
|
255
|
-
public void
|
|
269
|
+
public void run_selectwindow() {
|
|
256
270
|
driver.Navigate().GoToUrl(\\"http://the-internet.herokuapp.com/windows\\");
|
|
257
271
|
vars[\\"WindowHandles\\"] = driver.WindowHandles;
|
|
258
272
|
driver.FindElement(By.LinkText(\\"Click Here\\")).Click();
|
|
259
273
|
vars[\\"win9425\\"] = waitForWindow(2000);
|
|
260
|
-
driver.SwitchTo().Window(vars[\\"win9425\\"]
|
|
274
|
+
driver.SwitchTo().Window(Convert.ToString(vars[\\"win9425\\"]));
|
|
261
275
|
Assert.That(driver.Title, Is.EqualTo(\\"New Window\\"));
|
|
262
276
|
}
|
|
277
|
+
|
|
263
278
|
[Test]
|
|
264
279
|
public void reuse() {
|
|
265
|
-
|
|
280
|
+
run_selectwindow();
|
|
266
281
|
}
|
|
267
282
|
}
|
|
268
283
|
"
|
|
@@ -282,11 +297,13 @@ using OpenQA.Selenium.Remote;
|
|
|
282
297
|
using OpenQA.Selenium.Support.UI;
|
|
283
298
|
using OpenQA.Selenium.Interactions;
|
|
284
299
|
using NUnit.Framework;
|
|
300
|
+
|
|
285
301
|
[TestFixture]
|
|
286
302
|
public class DefaultSuiteTest {
|
|
287
303
|
private IWebDriver driver;
|
|
288
304
|
public IDictionary<string, object> vars {get; private set;}
|
|
289
305
|
private IJavaScriptExecutor js;
|
|
306
|
+
|
|
290
307
|
[SetUp]
|
|
291
308
|
public void SetUp() {
|
|
292
309
|
driver = new ChromeDriver();
|
|
@@ -311,17 +328,18 @@ public class DefaultSuiteTest {
|
|
|
311
328
|
return whNow.First().ToString();
|
|
312
329
|
}
|
|
313
330
|
}
|
|
314
|
-
public void
|
|
331
|
+
public void run_selectwindow() {
|
|
315
332
|
driver.Navigate().GoToUrl(\\"http://the-internet.herokuapp.com/windows\\");
|
|
316
333
|
vars[\\"WindowHandles\\"] = driver.WindowHandles;
|
|
317
334
|
driver.FindElement(By.LinkText(\\"Click Here\\")).Click();
|
|
318
335
|
vars[\\"win9425\\"] = waitForWindow(2000);
|
|
319
|
-
driver.SwitchTo().Window(vars[\\"win9425\\"]
|
|
336
|
+
driver.SwitchTo().Window(Convert.ToString(vars[\\"win9425\\"]));
|
|
320
337
|
Assert.That(driver.Title, Is.EqualTo(\\"New Window\\"));
|
|
321
338
|
}
|
|
339
|
+
|
|
322
340
|
[Test]
|
|
323
341
|
public void reuse() {
|
|
324
|
-
|
|
342
|
+
run_selectwindow();
|
|
325
343
|
}
|
|
326
344
|
[Test]
|
|
327
345
|
public void selectwindow() {
|
|
@@ -329,7 +347,7 @@ public class DefaultSuiteTest {
|
|
|
329
347
|
vars[\\"WindowHandles\\"] = driver.WindowHandles;
|
|
330
348
|
driver.FindElement(By.LinkText(\\"Click Here\\")).Click();
|
|
331
349
|
vars[\\"win9425\\"] = waitForWindow(2000);
|
|
332
|
-
driver.SwitchTo().Window(vars[\\"win9425\\"]
|
|
350
|
+
driver.SwitchTo().Window(Convert.ToString(vars[\\"win9425\\"]));
|
|
333
351
|
Assert.That(driver.Title, Is.EqualTo(\\"New Window\\"));
|
|
334
352
|
}
|
|
335
353
|
}
|
|
@@ -350,11 +368,13 @@ using OpenQA.Selenium.Remote;
|
|
|
350
368
|
using OpenQA.Selenium.Support.UI;
|
|
351
369
|
using OpenQA.Selenium.Interactions;
|
|
352
370
|
using NUnit.Framework;
|
|
371
|
+
|
|
353
372
|
[TestFixture]
|
|
354
373
|
public class LoginTest {
|
|
355
374
|
private IWebDriver driver;
|
|
356
375
|
public IDictionary<string, object> vars {get; private set;}
|
|
357
376
|
private IJavaScriptExecutor js;
|
|
377
|
+
|
|
358
378
|
[SetUp]
|
|
359
379
|
public void SetUp() {
|
|
360
380
|
driver = new ChromeDriver();
|
|
@@ -372,7 +392,7 @@ public class LoginTest {
|
|
|
372
392
|
driver.FindElement(By.Id(\\"username\\")).SendKeys(\\"tomsmith\\");
|
|
373
393
|
driver.FindElement(By.Id(\\"password\\")).SendKeys(\\"SuperSecretPassword!\\");
|
|
374
394
|
driver.FindElement(By.CssSelector(\\"#login button\\")).Click();
|
|
375
|
-
Assert.That(driver.FindElement(By.CssSelector(\\".flash.success\\")).Text, Is.EqualTo(\\"You logged into a secure area
|
|
395
|
+
Assert.That(driver.FindElement(By.CssSelector(\\".flash.success\\")).Text, Is.EqualTo(\\"You logged into a secure area!\\\\\\\\n×\\"));
|
|
376
396
|
}
|
|
377
397
|
}
|
|
378
398
|
"
|
|
@@ -392,11 +412,13 @@ using OpenQA.Selenium.Remote;
|
|
|
392
412
|
using OpenQA.Selenium.Support.UI;
|
|
393
413
|
using OpenQA.Selenium.Interactions;
|
|
394
414
|
using NUnit.Framework;
|
|
415
|
+
|
|
395
416
|
[TestFixture]
|
|
396
417
|
public class ValidcredentialsTest {
|
|
397
418
|
private IWebDriver driver;
|
|
398
419
|
public IDictionary<string, object> vars {get; private set;}
|
|
399
420
|
private IJavaScriptExecutor js;
|
|
421
|
+
|
|
400
422
|
[SetUp]
|
|
401
423
|
public void SetUp() {
|
|
402
424
|
driver = new ChromeDriver();
|
|
@@ -407,20 +429,21 @@ public class ValidcredentialsTest {
|
|
|
407
429
|
protected void TearDown() {
|
|
408
430
|
driver.Quit();
|
|
409
431
|
}
|
|
410
|
-
public void
|
|
432
|
+
public void run_login() {
|
|
411
433
|
driver.Navigate().GoToUrl(\\"https://the-internet.herokuapp.com/\\");
|
|
412
434
|
driver.FindElement(By.LinkText(\\"Form Authentication\\")).Click();
|
|
413
|
-
driver.FindElement(By.Id(\\"username\\")).SendKeys(vars[\\"username\\"]
|
|
414
|
-
driver.FindElement(By.Id(\\"password\\")).SendKeys(vars[\\"password\\"]
|
|
435
|
+
driver.FindElement(By.Id(\\"username\\")).SendKeys(Convert.ToString(vars[\\"username\\"]));
|
|
436
|
+
driver.FindElement(By.Id(\\"password\\")).SendKeys(Convert.ToString(vars[\\"password\\"]));
|
|
415
437
|
if ((Boolean) js.ExecuteScript(\\"return (true)\\")) {
|
|
416
438
|
driver.FindElement(By.CssSelector(\\".fa\\")).Click();
|
|
417
439
|
}
|
|
418
440
|
}
|
|
441
|
+
|
|
419
442
|
[Test]
|
|
420
443
|
public void validcredentials() {
|
|
421
444
|
vars[\\"username\\"] = \\"tomsmith\\";
|
|
422
445
|
vars[\\"password\\"] = \\"SuperSecretPassword!\\";
|
|
423
|
-
|
|
446
|
+
run_login();
|
|
424
447
|
}
|
|
425
448
|
}
|
|
426
449
|
"
|
|
@@ -440,11 +463,13 @@ using OpenQA.Selenium.Remote;
|
|
|
440
463
|
using OpenQA.Selenium.Support.UI;
|
|
441
464
|
using OpenQA.Selenium.Interactions;
|
|
442
465
|
using NUnit.Framework;
|
|
466
|
+
|
|
443
467
|
[TestFixture]
|
|
444
468
|
public class SelectwindowTest {
|
|
445
469
|
private IWebDriver driver;
|
|
446
470
|
public IDictionary<string, object> vars {get; private set;}
|
|
447
471
|
private IJavaScriptExecutor js;
|
|
472
|
+
|
|
448
473
|
[SetUp]
|
|
449
474
|
public void SetUp() {
|
|
450
475
|
driver = new ChromeDriver();
|
|
@@ -469,6 +494,7 @@ public class SelectwindowTest {
|
|
|
469
494
|
return whNow.First().ToString();
|
|
470
495
|
}
|
|
471
496
|
}
|
|
497
|
+
|
|
472
498
|
[Test]
|
|
473
499
|
public void selectwindow() {
|
|
474
500
|
driver.Navigate().GoToUrl(\\"http://the-internet.herokuapp.com/\\");
|
|
@@ -478,9 +504,9 @@ public class SelectwindowTest {
|
|
|
478
504
|
driver.FindElement(By.LinkText(\\"Click Here\\")).Click();
|
|
479
505
|
vars[\\"win9625\\"] = waitForWindow(2000);
|
|
480
506
|
vars[\\"root\\"] = driver.CurrentWindowHandle;
|
|
481
|
-
driver.SwitchTo().Window(vars[\\"win9625\\"]
|
|
507
|
+
driver.SwitchTo().Window(Convert.ToString(vars[\\"win9625\\"]));
|
|
482
508
|
Assert.That(driver.Title, Is.EqualTo(\\"New Window\\"));
|
|
483
|
-
driver.SwitchTo().Window(vars[\\"root\\"]
|
|
509
|
+
driver.SwitchTo().Window(Convert.ToString(vars[\\"root\\"]));
|
|
484
510
|
Assert.That(driver.Title, Is.EqualTo(\\"The Internet\\"));
|
|
485
511
|
}
|
|
486
512
|
}
|
|
@@ -501,11 +527,13 @@ using OpenQA.Selenium.Remote;
|
|
|
501
527
|
using OpenQA.Selenium.Support.UI;
|
|
502
528
|
using OpenQA.Selenium.Interactions;
|
|
503
529
|
using NUnit.Framework;
|
|
530
|
+
|
|
504
531
|
[TestFixture]
|
|
505
532
|
public class LoginTest {
|
|
506
533
|
private IWebDriver driver;
|
|
507
534
|
public IDictionary<string, object> vars {get; private set;}
|
|
508
535
|
private IJavaScriptExecutor js;
|
|
536
|
+
|
|
509
537
|
[SetUp]
|
|
510
538
|
public void SetUp() {
|
|
511
539
|
driver = new RemoteWebDriver(new Uri(\\"http://localhost:4444/wd/hub\\"), new FirefoxOptions().ToCapabilities());
|
|
@@ -523,7 +551,7 @@ public class LoginTest {
|
|
|
523
551
|
driver.FindElement(By.Id(\\"username\\")).SendKeys(\\"tomsmith\\");
|
|
524
552
|
driver.FindElement(By.Id(\\"password\\")).SendKeys(\\"SuperSecretPassword!\\");
|
|
525
553
|
driver.FindElement(By.CssSelector(\\"#login button\\")).Click();
|
|
526
|
-
Assert.That(driver.FindElement(By.CssSelector(\\".flash.success\\")).Text, Is.EqualTo(\\"You logged into a secure area
|
|
554
|
+
Assert.That(driver.FindElement(By.CssSelector(\\".flash.success\\")).Text, Is.EqualTo(\\"You logged into a secure area!\\\\\\\\n×\\"));
|
|
527
555
|
}
|
|
528
556
|
}
|
|
529
557
|
"
|