@seleniumhq/code-export-python-pytest 4.0.13 → 4.1.0-beta.2
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 +52 -31
- package/__test__/src/__snapshots__/index.spec.js.snap +40 -10
- package/__test__/src/__snapshots__/location.spec.js.snap +1 -1
- package/__test__/src/command.spec.js +103 -59
- package/__test__/src/index.spec.js +134 -59
- package/__test__/src/selection.spec.js +9 -6
- package/dist/command.d.ts.map +1 -1
- package/dist/command.js +54 -41
- package/dist/command.js.map +1 -1
- package/dist/hook.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/location.js +1 -2
- package/dist/location.js.map +1 -1
- package/dist/selection.js +1 -5
- package/dist/selection.js.map +1 -1
- package/jest.config.js +14 -0
- package/package.json +4 -3
- package/src/command.ts +92 -47
- package/src/hook.ts +1 -1
- package/src/index.ts +3 -0
- package/src/selection.ts +0 -3
- 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
|
"element = self.driver.find_element(By.ID, \\"test\\")
|
|
@@ -14,12 +14,16 @@ selected_text = element.find_element(By.XPATH, locator).text
|
|
|
14
14
|
assert selected_text == \\"test\\""
|
|
15
15
|
`;
|
|
16
16
|
|
|
17
|
+
exports[`command code emitter should emit \`accept alert\` command 1`] = `"self.driver.switch_to.alert.accept()"`;
|
|
18
|
+
|
|
19
|
+
exports[`command code emitter should emit \`accept confirmation\` command 1`] = `"self.driver.switch_to.alert.accept()"`;
|
|
20
|
+
|
|
17
21
|
exports[`command code emitter should emit \`add selection\` command 1`] = `
|
|
18
22
|
"dropdown = self.driver.find_element(By.CSS_SELECTOR, \\"select\\")
|
|
19
23
|
dropdown.find_element(By.XPATH, \\"//option[. = 'A label']\\").click()"
|
|
20
24
|
`;
|
|
21
25
|
|
|
22
|
-
exports[`command code emitter should emit \`answer
|
|
26
|
+
exports[`command code emitter should emit \`answer prompt\` command 1`] = `
|
|
23
27
|
"alert = self.driver.switch_to.alert
|
|
24
28
|
alert.send_keys(\\"an answer\\")
|
|
25
29
|
alert.accept()"
|
|
@@ -74,6 +78,8 @@ exports[`command code emitter should emit \`assert text\` command 1`] = `"assert
|
|
|
74
78
|
|
|
75
79
|
exports[`command code emitter should emit \`assert title\` command 1`] = `"assert self.driver.title == \\"example title\\""`;
|
|
76
80
|
|
|
81
|
+
exports[`command code emitter should emit \`assert title\` command with an empty title 1`] = `"assert self.driver.title == \\"\\""`;
|
|
82
|
+
|
|
77
83
|
exports[`command code emitter should emit \`assert value\` command 1`] = `
|
|
78
84
|
"value = self.driver.find_element(By.ID, \\"select\\").get_attribute(\\"value\\")
|
|
79
85
|
assert value == \\"test\\""
|
|
@@ -86,19 +92,20 @@ exports[`command code emitter should emit \`check\` command 1`] = `
|
|
|
86
92
|
if element.is_selected() != True: element.click()"
|
|
87
93
|
`;
|
|
88
94
|
|
|
89
|
-
exports[`command code emitter should emit \`choose cancel on visible prompt\` command 1`] = `"self.driver.switch_to.alert.dismiss()"`;
|
|
90
|
-
|
|
91
|
-
exports[`command code emitter should emit \`choose ok on visible confirmation\` command 1`] = `"self.driver.switch_to.alert.accept()"`;
|
|
92
|
-
|
|
93
95
|
exports[`command code emitter should emit \`click at\` command 1`] = `"self.driver.find_element(By.LINK_TEXT, \\"button\\").click()"`;
|
|
94
96
|
|
|
95
97
|
exports[`command code emitter should emit \`click\` command 1`] = `"self.driver.find_element(By.LINK_TEXT, \\"button\\").click()"`;
|
|
96
98
|
|
|
97
99
|
exports[`command code emitter should emit \`close\` command 1`] = `"self.driver.close()"`;
|
|
98
100
|
|
|
101
|
+
exports[`command code emitter should emit \`dismiss confirmation\` command 1`] = `"self.driver.switch_to.alert.dismiss()"`;
|
|
102
|
+
|
|
103
|
+
exports[`command code emitter should emit \`dismiss prompt\` command 1`] = `"self.driver.switch_to.alert.dismiss()"`;
|
|
104
|
+
|
|
99
105
|
exports[`command code emitter should emit \`do\` command 1`] = `
|
|
100
106
|
Object {
|
|
101
|
-
"body": "
|
|
107
|
+
"body": "loop1 = 0
|
|
108
|
+
condition = True
|
|
102
109
|
while condition:",
|
|
103
110
|
"endingLevel": 1,
|
|
104
111
|
}
|
|
@@ -125,7 +132,7 @@ actions.drag_and_drop(dragged, dropped).perform()"
|
|
|
125
132
|
|
|
126
133
|
exports[`command code emitter should emit \`echo\` command 1`] = `"print(\\"blah\\")"`;
|
|
127
134
|
|
|
128
|
-
exports[`command code emitter should emit \`echo\` command with variables 1`] = `"print(\\"blah =
|
|
135
|
+
exports[`command code emitter should emit \`echo\` command with variables 1`] = `"print(\\"blah = \\" + str(self.vars[\\"blah\\"]))"`;
|
|
129
136
|
|
|
130
137
|
exports[`command code emitter should emit \`edit content\` command 1`] = `
|
|
131
138
|
"element = self.driver.find_element(By.ID, \\"contentEditable\\")
|
|
@@ -193,16 +200,10 @@ actions = ActionChains(self.driver)
|
|
|
193
200
|
actions.move_to_element(element).perform()"
|
|
194
201
|
`;
|
|
195
202
|
|
|
196
|
-
exports[`command code emitter should emit \`mouse move\` event 1`] = `
|
|
197
|
-
"element = self.driver.find_element(By.ID, \\"button\\")
|
|
198
|
-
actions = ActionChains(self.driver)
|
|
199
|
-
actions.move_to_element(element).perform()"
|
|
200
|
-
`;
|
|
201
|
-
|
|
202
203
|
exports[`command code emitter should emit \`mouse out\` event 1`] = `
|
|
203
204
|
"element = self.driver.find_element(By.CSS_SELECTOR, \\"body\\")
|
|
204
205
|
actions = ActionChains(self.driver)
|
|
205
|
-
actions.move_to_element(element
|
|
206
|
+
actions.move_to_element(element).perform()"
|
|
206
207
|
`;
|
|
207
208
|
|
|
208
209
|
exports[`command code emitter should emit \`mouse over\` event 1`] = `
|
|
@@ -232,12 +233,18 @@ exports[`command code emitter should emit \`remove selection\` command 1`] = `
|
|
|
232
233
|
dropdown.find_element(By.XPATH, \\"//option[. = 'A label']\\").click()"
|
|
233
234
|
`;
|
|
234
235
|
|
|
235
|
-
exports[`command code emitter should emit \`repeatIf\` command 1`] = `
|
|
236
|
+
exports[`command code emitter should emit \`repeatIf\` command 1`] = `
|
|
237
|
+
"loop1 += 1
|
|
238
|
+
if loop1 > 1000: raise Exception(\\"Max retry limit exceeded\\")
|
|
239
|
+
condition = self.driver.execute_script(\\"return (true)\\")"
|
|
240
|
+
`;
|
|
236
241
|
|
|
237
242
|
exports[`command code emitter should emit \`run script\` command 1`] = `"self.driver.execute_script(\\"alert('test');alert('Im annoying');\\")"`;
|
|
238
243
|
|
|
239
244
|
exports[`command code emitter should emit \`run\` command 1`] = `"self.sometestcase()"`;
|
|
240
245
|
|
|
246
|
+
exports[`command code emitter should emit \`run\` command for a test with a capitalized name 1`] = `"self.someTestCase()"`;
|
|
247
|
+
|
|
241
248
|
exports[`command code emitter should emit \`select frame\` to select the top frame 1`] = `"self.driver.switch_to.default_content()"`;
|
|
242
249
|
|
|
243
250
|
exports[`command code emitter should emit \`select window\` to select a window by handle 1`] = `"self.driver.switch_to.window(self.vars[\\"window\\"])"`;
|
|
@@ -257,7 +264,7 @@ exports[`command code emitter should emit \`send keys\` command 1`] = `"self.dri
|
|
|
257
264
|
|
|
258
265
|
exports[`command code emitter should emit \`send keys\` command with a key press 1`] = `"self.driver.find_element(By.ID, \\"input\\").send_keys(\\"SuperSecretPassword!\\", Keys.ENTER)"`;
|
|
259
266
|
|
|
260
|
-
exports[`command code emitter should emit \`send keys\` command with a variable input 1`] = `"self.driver.find_element(By.ID, \\"input\\").send_keys(self.vars[\\"blah\\"])"`;
|
|
267
|
+
exports[`command code emitter should emit \`send keys\` command with a variable input 1`] = `"self.driver.find_element(By.ID, \\"input\\").send_keys(str(self.vars[\\"blah\\"]))"`;
|
|
261
268
|
|
|
262
269
|
exports[`command code emitter should emit \`set speed\` 1`] = `"print(\\"\`set speed\` is a no-op in code export, use \`pause\` instead\\")"`;
|
|
263
270
|
|
|
@@ -268,6 +275,8 @@ exports[`command code emitter should emit \`store attribute\` command 1`] = `
|
|
|
268
275
|
self.vars[\\"myVar\\"] = attribute"
|
|
269
276
|
`;
|
|
270
277
|
|
|
278
|
+
exports[`command code emitter should emit \`store element count\` command 1`] = `"self.vars[\\"myVar\\"] = len(self.driver.find_elements(By.XPATH, \\"button\\"))"`;
|
|
279
|
+
|
|
271
280
|
exports[`command code emitter should emit \`store json\` command 1`] = `"self.vars[\\"myVar\\"] = json.loads('[{\\"a\\":0}]')"`;
|
|
272
281
|
|
|
273
282
|
exports[`command code emitter should emit \`store text\` command 1`] = `"self.vars[\\"myVar\\"] = self.driver.find_element(By.ID, \\"someElement\\").text"`;
|
|
@@ -278,15 +287,20 @@ exports[`command code emitter should emit \`store value\` command 1`] = `"self.v
|
|
|
278
287
|
|
|
279
288
|
exports[`command code emitter should emit \`store window handle\` command 1`] = `"self.vars[\\"windowName\\"] = self.driver.current_window_handle"`;
|
|
280
289
|
|
|
281
|
-
exports[`command code emitter should emit \`store xpath count\` command 1`] = `"self.vars[\\"myVar\\"] = len(self.driver.find_elements(By.XPATH, \\"button\\"))"`;
|
|
282
|
-
|
|
283
290
|
exports[`command code emitter should emit \`store\` command 1`] = `"self.vars[\\"myVar\\"] = \\"some value\\""`;
|
|
284
291
|
|
|
285
|
-
exports[`command code emitter should emit \`submit\` command 1`] = `"raise Exception(\\"'submit' is not a supported command in Selenium WebDriver. Please re-record the step in the IDE.\\")"`;
|
|
286
|
-
|
|
287
292
|
exports[`command code emitter should emit \`times\` command 1`] = `
|
|
288
293
|
Object {
|
|
289
|
-
"body": "for
|
|
294
|
+
"body": "for loop1 in range(0, 5):
|
|
295
|
+
if loop1 >= 1000: raise Exception(\\"Max retry limit exceeded\\")",
|
|
296
|
+
"endingLevel": 1,
|
|
297
|
+
}
|
|
298
|
+
`;
|
|
299
|
+
|
|
300
|
+
exports[`command code emitter should emit \`times\` command with a variable count 1`] = `
|
|
301
|
+
Object {
|
|
302
|
+
"body": "for loop1 in range(0, int(float(self.vars[\\"count\\"]) // 1)):
|
|
303
|
+
if loop1 >= 1000: raise Exception(\\"Max retry limit exceeded\\")",
|
|
290
304
|
"endingLevel": 1,
|
|
291
305
|
}
|
|
292
306
|
`;
|
|
@@ -364,21 +378,28 @@ exports[`command code emitter should emit \`waitForText\` command 1`] = `"WebDri
|
|
|
364
378
|
|
|
365
379
|
exports[`command code emitter should emit \`while\` command 1`] = `
|
|
366
380
|
Object {
|
|
367
|
-
"body": "
|
|
381
|
+
"body": "loop1 = 0
|
|
382
|
+
while self.driver.execute_script(\\"return (true)\\"):
|
|
383
|
+
loop1 += 1
|
|
384
|
+
if loop1 > 1000: raise Exception(\\"Max retry limit exceeded\\")",
|
|
385
|
+
"endingLevel": 1,
|
|
386
|
+
}
|
|
387
|
+
`;
|
|
388
|
+
|
|
389
|
+
exports[`command code emitter should emit \`while\` command with a loop limit 1`] = `
|
|
390
|
+
Object {
|
|
391
|
+
"body": "loop1 = 0
|
|
392
|
+
while self.driver.execute_script(\\"return (true)\\"):
|
|
393
|
+
loop1 += 1
|
|
394
|
+
if loop1 > 5: raise Exception(\\"Max retry limit exceeded\\")",
|
|
368
395
|
"endingLevel": 1,
|
|
369
396
|
}
|
|
370
397
|
`;
|
|
371
398
|
|
|
399
|
+
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: self.vars[\\"testName\\"]"`;
|
|
400
|
+
|
|
372
401
|
exports[`command code emitter should emit new window handling, if command opens a new window 1`] = `
|
|
373
402
|
"self.vars[\\"window_handles\\"] = self.driver.window_handles
|
|
374
403
|
self.driver.find_element(By.CSS_SELECTOR, \\"button\\").click()
|
|
375
404
|
self.vars[\\"newWin\\"] = self.wait_for_window(2000)"
|
|
376
405
|
`;
|
|
377
|
-
|
|
378
|
-
exports[`command code emitter should skip playback supported commands, that are not supported in webdriver 1`] = `undefined`;
|
|
379
|
-
|
|
380
|
-
exports[`command code emitter should skip playback supported commands, that are not supported in webdriver 2`] = `undefined`;
|
|
381
|
-
|
|
382
|
-
exports[`command code emitter should skip playback supported commands, that are not supported in webdriver 3`] = `undefined`;
|
|
383
|
-
|
|
384
|
-
exports[`command code emitter should skip playback supported commands, that are not supported in webdriver 4`] = `undefined`;
|
|
@@ -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 Python pytest should export a suite 1`] = `
|
|
4
4
|
"# Generated by Selenium IDE
|
|
@@ -13,7 +13,9 @@ from selenium.webdriver.support.wait import WebDriverWait
|
|
|
13
13
|
from selenium.webdriver.common.keys import Keys
|
|
14
14
|
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
|
|
15
15
|
|
|
16
|
+
|
|
16
17
|
class TestLogin():
|
|
18
|
+
|
|
17
19
|
def setup_method(self, method):
|
|
18
20
|
self.driver = webdriver.Chrome()
|
|
19
21
|
self.vars = {}
|
|
@@ -27,7 +29,7 @@ class TestLogin():
|
|
|
27
29
|
self.driver.find_element(By.ID, \\"username\\").send_keys(\\"tomsmith\\")
|
|
28
30
|
self.driver.find_element(By.ID, \\"password\\").send_keys(\\"SuperSecretPassword!\\")
|
|
29
31
|
self.driver.find_element(By.CSS_SELECTOR, \\"#login button\\").click()
|
|
30
|
-
assert self.driver.find_element(By.CSS_SELECTOR, \\".flash.success\\").text == \\"You logged into a secure area
|
|
32
|
+
assert self.driver.find_element(By.CSS_SELECTOR, \\".flash.success\\").text == \\"You logged into a secure area!\\\\\\\\n×\\"
|
|
31
33
|
|
|
32
34
|
def test_invalidcredentials(self):
|
|
33
35
|
self.driver.get(\\"http://the-internet.herokuapp.com/login\\")
|
|
@@ -35,7 +37,7 @@ class TestLogin():
|
|
|
35
37
|
self.driver.find_element(By.ID, \\"username\\").send_keys(\\"blah\\")
|
|
36
38
|
self.driver.find_element(By.ID, \\"password\\").send_keys(\\"blah\\")
|
|
37
39
|
self.driver.find_element(By.CSS_SELECTOR, \\"#login button\\").click()
|
|
38
|
-
assert self.driver.find_element(By.ID, \\"flash\\").text == \\"Your username is invalid
|
|
40
|
+
assert self.driver.find_element(By.ID, \\"flash\\").text == \\"Your username is invalid!\\\\\\\\n×\\"
|
|
39
41
|
|
|
40
42
|
"
|
|
41
43
|
`;
|
|
@@ -53,7 +55,9 @@ from selenium.webdriver.support.wait import WebDriverWait
|
|
|
53
55
|
from selenium.webdriver.common.keys import Keys
|
|
54
56
|
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
|
|
55
57
|
|
|
58
|
+
|
|
56
59
|
class TestControlflow():
|
|
60
|
+
|
|
57
61
|
def setup_method(self, method):
|
|
58
62
|
self.driver = webdriver.Chrome()
|
|
59
63
|
self.vars = {}
|
|
@@ -93,21 +97,28 @@ class TestControlflow():
|
|
|
93
97
|
|
|
94
98
|
def test_controlflowdo(self):
|
|
95
99
|
self.vars[\\"check\\"] = self.driver.execute_script(\\"return 1\\")
|
|
100
|
+
loop1 = 0
|
|
96
101
|
condition = True
|
|
97
102
|
while condition:
|
|
98
103
|
self.vars[\\"check\\"] = self.driver.execute_script(\\"return arguments[0] + 1\\", self.vars[\\"check\\"])
|
|
104
|
+
loop1 += 1
|
|
105
|
+
if loop1 > 1000: raise Exception(\\"Max retry limit exceeded\\")
|
|
99
106
|
condition = self.driver.execute_script(\\"return (arguments[0] < 3)\\", self.vars[\\"check\\"])
|
|
100
107
|
assert(self.vars[\\"check\\"] == 3)
|
|
101
108
|
|
|
102
109
|
def test_controlflowtimes(self):
|
|
103
110
|
self.vars[\\"check\\"] = self.driver.execute_script(\\"return 1\\")
|
|
104
|
-
for
|
|
111
|
+
for loop1 in range(0, 2):
|
|
112
|
+
if loop1 >= 1000: raise Exception(\\"Max retry limit exceeded\\")
|
|
105
113
|
self.vars[\\"check\\"] = self.driver.execute_script(\\"return arguments[0] + 1\\", self.vars[\\"check\\"])
|
|
106
114
|
assert(self.vars[\\"check\\"] == 3)
|
|
107
115
|
|
|
108
116
|
def test_controlflowwhile(self):
|
|
109
117
|
self.vars[\\"check\\"] = self.driver.execute_script(\\"return 1\\")
|
|
118
|
+
loop1 = 0
|
|
110
119
|
while self.driver.execute_script(\\"return (arguments[0] < 3)\\", self.vars[\\"check\\"]):
|
|
120
|
+
loop1 += 1
|
|
121
|
+
if loop1 > 1000: raise Exception(\\"Max retry limit exceeded\\")
|
|
111
122
|
self.vars[\\"check\\"] = self.driver.execute_script(\\"return arguments[0] + 1\\", self.vars[\\"check\\"])
|
|
112
123
|
assert(self.vars[\\"check\\"] == 3)
|
|
113
124
|
|
|
@@ -127,7 +138,9 @@ from selenium.webdriver.support.wait import WebDriverWait
|
|
|
127
138
|
from selenium.webdriver.common.keys import Keys
|
|
128
139
|
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
|
|
129
140
|
|
|
141
|
+
|
|
130
142
|
class TestReusedmethods():
|
|
143
|
+
|
|
131
144
|
def setup_method(self, method):
|
|
132
145
|
self.driver = webdriver.Chrome()
|
|
133
146
|
self.vars = {}
|
|
@@ -138,14 +151,15 @@ class TestReusedmethods():
|
|
|
138
151
|
def login(self):
|
|
139
152
|
self.driver.get(\\"https://the-internet.herokuapp.com/\\")
|
|
140
153
|
self.driver.find_element(By.LINK_TEXT, \\"Form Authentication\\").click()
|
|
141
|
-
self.driver.find_element(By.ID, \\"username\\").send_keys(self.vars[\\"username\\"])
|
|
142
|
-
self.driver.find_element(By.ID, \\"password\\").send_keys(self.vars[\\"password\\"])
|
|
154
|
+
self.driver.find_element(By.ID, \\"username\\").send_keys(str(self.vars[\\"username\\"]))
|
|
155
|
+
self.driver.find_element(By.ID, \\"password\\").send_keys(str(self.vars[\\"password\\"]))
|
|
143
156
|
if self.driver.execute_script(\\"return (true)\\"):
|
|
144
157
|
self.driver.find_element(By.CSS_SELECTOR, \\".fa\\").click()
|
|
145
158
|
|
|
146
159
|
def tinymethod(self):
|
|
147
160
|
self.vars[\\"value\\"] = \\"field\\"
|
|
148
161
|
|
|
162
|
+
|
|
149
163
|
def test_invalidcredentials(self):
|
|
150
164
|
self.vars[\\"username\\"] = \\"blah\\"
|
|
151
165
|
self.vars[\\"password\\"] = \\"blah\\"
|
|
@@ -178,7 +192,9 @@ from selenium.webdriver.support.wait import WebDriverWait
|
|
|
178
192
|
from selenium.webdriver.common.keys import Keys
|
|
179
193
|
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
|
|
180
194
|
|
|
195
|
+
|
|
181
196
|
class TestDefaultSuite():
|
|
197
|
+
|
|
182
198
|
def setup_method(self, method):
|
|
183
199
|
self.driver = webdriver.Chrome()
|
|
184
200
|
self.vars = {}
|
|
@@ -201,6 +217,7 @@ class TestDefaultSuite():
|
|
|
201
217
|
self.driver.switch_to.window(self.vars[\\"win9425\\"])
|
|
202
218
|
assert self.driver.title == \\"New Window\\"
|
|
203
219
|
|
|
220
|
+
|
|
204
221
|
def test_reuse(self):
|
|
205
222
|
self.selectwindow()
|
|
206
223
|
|
|
@@ -220,7 +237,9 @@ from selenium.webdriver.support.wait import WebDriverWait
|
|
|
220
237
|
from selenium.webdriver.common.keys import Keys
|
|
221
238
|
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
|
|
222
239
|
|
|
240
|
+
|
|
223
241
|
class TestDefaultSuite():
|
|
242
|
+
|
|
224
243
|
def setup_method(self, method):
|
|
225
244
|
self.driver = webdriver.Chrome()
|
|
226
245
|
self.vars = {}
|
|
@@ -243,6 +262,7 @@ class TestDefaultSuite():
|
|
|
243
262
|
self.driver.switch_to.window(self.vars[\\"win9425\\"])
|
|
244
263
|
assert self.driver.title == \\"New Window\\"
|
|
245
264
|
|
|
265
|
+
|
|
246
266
|
def test_reuse(self):
|
|
247
267
|
self.selectwindow()
|
|
248
268
|
|
|
@@ -270,7 +290,9 @@ from selenium.webdriver.support.wait import WebDriverWait
|
|
|
270
290
|
from selenium.webdriver.common.keys import Keys
|
|
271
291
|
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
|
|
272
292
|
|
|
293
|
+
|
|
273
294
|
class TestLogin():
|
|
295
|
+
|
|
274
296
|
def setup_method(self, method):
|
|
275
297
|
self.driver = webdriver.Chrome()
|
|
276
298
|
self.vars = {}
|
|
@@ -284,7 +306,7 @@ class TestLogin():
|
|
|
284
306
|
self.driver.find_element(By.ID, \\"username\\").send_keys(\\"tomsmith\\")
|
|
285
307
|
self.driver.find_element(By.ID, \\"password\\").send_keys(\\"SuperSecretPassword!\\")
|
|
286
308
|
self.driver.find_element(By.CSS_SELECTOR, \\"#login button\\").click()
|
|
287
|
-
assert self.driver.find_element(By.CSS_SELECTOR, \\".flash.success\\").text == \\"You logged into a secure area
|
|
309
|
+
assert self.driver.find_element(By.CSS_SELECTOR, \\".flash.success\\").text == \\"You logged into a secure area!\\\\\\\\n×\\"
|
|
288
310
|
|
|
289
311
|
"
|
|
290
312
|
`;
|
|
@@ -302,7 +324,9 @@ from selenium.webdriver.support.wait import WebDriverWait
|
|
|
302
324
|
from selenium.webdriver.common.keys import Keys
|
|
303
325
|
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
|
|
304
326
|
|
|
327
|
+
|
|
305
328
|
class TestValidcredentials():
|
|
329
|
+
|
|
306
330
|
def setup_method(self, method):
|
|
307
331
|
self.driver = webdriver.Chrome()
|
|
308
332
|
self.vars = {}
|
|
@@ -313,11 +337,12 @@ class TestValidcredentials():
|
|
|
313
337
|
def login(self):
|
|
314
338
|
self.driver.get(\\"https://the-internet.herokuapp.com/\\")
|
|
315
339
|
self.driver.find_element(By.LINK_TEXT, \\"Form Authentication\\").click()
|
|
316
|
-
self.driver.find_element(By.ID, \\"username\\").send_keys(self.vars[\\"username\\"])
|
|
317
|
-
self.driver.find_element(By.ID, \\"password\\").send_keys(self.vars[\\"password\\"])
|
|
340
|
+
self.driver.find_element(By.ID, \\"username\\").send_keys(str(self.vars[\\"username\\"]))
|
|
341
|
+
self.driver.find_element(By.ID, \\"password\\").send_keys(str(self.vars[\\"password\\"]))
|
|
318
342
|
if self.driver.execute_script(\\"return (true)\\"):
|
|
319
343
|
self.driver.find_element(By.CSS_SELECTOR, \\".fa\\").click()
|
|
320
344
|
|
|
345
|
+
|
|
321
346
|
def test_validcredentials(self):
|
|
322
347
|
self.vars[\\"username\\"] = \\"tomsmith\\"
|
|
323
348
|
self.vars[\\"password\\"] = \\"SuperSecretPassword!\\"
|
|
@@ -339,7 +364,9 @@ from selenium.webdriver.support.wait import WebDriverWait
|
|
|
339
364
|
from selenium.webdriver.common.keys import Keys
|
|
340
365
|
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
|
|
341
366
|
|
|
367
|
+
|
|
342
368
|
class TestSelectwindow():
|
|
369
|
+
|
|
343
370
|
def setup_method(self, method):
|
|
344
371
|
self.driver = webdriver.Chrome()
|
|
345
372
|
self.vars = {}
|
|
@@ -354,6 +381,7 @@ class TestSelectwindow():
|
|
|
354
381
|
if len(wh_now) > len(wh_then):
|
|
355
382
|
return set(wh_now).difference(set(wh_then)).pop()
|
|
356
383
|
|
|
384
|
+
|
|
357
385
|
def test_selectwindow(self):
|
|
358
386
|
self.driver.get(\\"http://the-internet.herokuapp.com/\\")
|
|
359
387
|
self.driver.set_window_size(1260, 1027)
|
|
@@ -383,7 +411,9 @@ from selenium.webdriver.support.wait import WebDriverWait
|
|
|
383
411
|
from selenium.webdriver.common.keys import Keys
|
|
384
412
|
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
|
|
385
413
|
|
|
414
|
+
|
|
386
415
|
class TestLogin():
|
|
416
|
+
|
|
387
417
|
def setup_method(self, method):
|
|
388
418
|
self.driver = webdriver.Remote(command_executor='http://localhost:4444/wd/hub', desired_capabilities=DesiredCapabilities.FIREFOX)
|
|
389
419
|
self.vars = {}
|
|
@@ -397,7 +427,7 @@ class TestLogin():
|
|
|
397
427
|
self.driver.find_element(By.ID, \\"username\\").send_keys(\\"tomsmith\\")
|
|
398
428
|
self.driver.find_element(By.ID, \\"password\\").send_keys(\\"SuperSecretPassword!\\")
|
|
399
429
|
self.driver.find_element(By.CSS_SELECTOR, \\"#login button\\").click()
|
|
400
|
-
assert self.driver.find_element(By.CSS_SELECTOR, \\".flash.success\\").text == \\"You logged into a secure area
|
|
430
|
+
assert self.driver.find_element(By.CSS_SELECTOR, \\".flash.success\\").text == \\"You logged into a secure area!\\\\\\\\n×\\"
|
|
401
431
|
|
|
402
432
|
"
|
|
403
433
|
`;
|
|
@@ -16,12 +16,10 @@
|
|
|
16
16
|
// under the License.
|
|
17
17
|
|
|
18
18
|
import Command from '../../src/command'
|
|
19
|
-
import {
|
|
20
|
-
|
|
21
|
-
ControlFlowCommandNames,
|
|
22
|
-
} from '../../../selenium-ide/src/neo/models/Command'
|
|
19
|
+
import { Commands } from '@seleniumhq/side-model'
|
|
20
|
+
import { ControlFlowCommandNames } from '@seleniumhq/side-runtime/dist/playback-tree/commands'
|
|
23
21
|
import { opts } from '../../src/index'
|
|
24
|
-
import { codeExport as exporter } from '
|
|
22
|
+
import { codeExport as exporter } from 'side-code-export'
|
|
25
23
|
|
|
26
24
|
const commandPrefixPadding = opts.commandPrefixPadding
|
|
27
25
|
|
|
@@ -34,22 +32,48 @@ async function prettify(command, { fullPayload } = {}) {
|
|
|
34
32
|
}
|
|
35
33
|
|
|
36
34
|
describe('command code emitter', () => {
|
|
37
|
-
it('should
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
|
|
35
|
+
it('should have an emitter for every command', () => {
|
|
36
|
+
const missing = Object.keys(Commands).filter(
|
|
37
|
+
(command) => !Command.emitters[command]
|
|
38
|
+
)
|
|
39
|
+
expect(missing).toEqual([])
|
|
40
|
+
})
|
|
41
|
+
it('should leave a comment for a command with no emitter', async () => {
|
|
42
|
+
// e.g., a command added by a plugin
|
|
43
|
+
Commands.customCommand = {
|
|
44
|
+
name: 'custom command',
|
|
45
|
+
description: '',
|
|
46
|
+
target: { name: 'locator', description: '' },
|
|
47
|
+
}
|
|
48
|
+
try {
|
|
49
|
+
const command = { command: 'customCommand', target: 'id=a', value: '' }
|
|
50
|
+
expect(await Command.emit(command, opts)).toBe(
|
|
51
|
+
"# Can't export command: customCommand | id=a | "
|
|
52
|
+
)
|
|
53
|
+
const multiline = { ...command, value: 'a\nraise Exception()' }
|
|
54
|
+
expect(await Command.emit(multiline, opts)).toBe(
|
|
55
|
+
"# Can't export command: customCommand | id=a | a raise Exception()"
|
|
56
|
+
)
|
|
57
|
+
} finally {
|
|
58
|
+
delete Commands.customCommand
|
|
59
|
+
}
|
|
60
|
+
})
|
|
61
|
+
it('should not escape backticks in values', async () => {
|
|
62
|
+
const command = { command: 'type', target: 'id=a', value: "it's `ok`" }
|
|
63
|
+
expect(await Command.emit(command, opts)).toBe(
|
|
64
|
+
'self.driver.find_element(By.ID, "a").send_keys("it\\\'s `ok`")'
|
|
65
|
+
)
|
|
66
|
+
})
|
|
67
|
+
it('should escape a text check value once', async () => {
|
|
68
|
+
const command = {
|
|
69
|
+
command: 'assertText',
|
|
70
|
+
target: 'id=a',
|
|
71
|
+
value: 'a "b" `c`',
|
|
72
|
+
}
|
|
73
|
+
const { commands } = await Command.emit(command, opts)
|
|
74
|
+
expect(commands[0].statement).toBe(
|
|
75
|
+
'assert self.driver.find_element(By.ID, "a").text == "a \\"b\\" `c`"'
|
|
76
|
+
)
|
|
53
77
|
})
|
|
54
78
|
it('should emit `add selection` command', () => {
|
|
55
79
|
const command = {
|
|
@@ -187,6 +211,14 @@ describe('command code emitter', () => {
|
|
|
187
211
|
}
|
|
188
212
|
return expect(prettify(command)).resolves.toMatchSnapshot()
|
|
189
213
|
})
|
|
214
|
+
it('should emit `assert title` command with an empty title', () => {
|
|
215
|
+
const command = {
|
|
216
|
+
command: 'assertTitle',
|
|
217
|
+
target: '',
|
|
218
|
+
value: '',
|
|
219
|
+
}
|
|
220
|
+
return expect(prettify(command)).resolves.toMatchSnapshot()
|
|
221
|
+
})
|
|
190
222
|
it('should emit `assert value` command', () => {
|
|
191
223
|
const command = {
|
|
192
224
|
command: 'assertValue',
|
|
@@ -375,14 +407,6 @@ describe('command code emitter', () => {
|
|
|
375
407
|
}
|
|
376
408
|
return expect(prettify(command)).resolves.toMatchSnapshot()
|
|
377
409
|
})
|
|
378
|
-
it.skip('should emit `mouse move` event', () => {
|
|
379
|
-
const command = {
|
|
380
|
-
command: 'mouseMove',
|
|
381
|
-
target: 'id=button',
|
|
382
|
-
value: '',
|
|
383
|
-
}
|
|
384
|
-
return expect(prettify(command)).resolves.toMatchSnapshot()
|
|
385
|
-
})
|
|
386
410
|
it('should emit `mouse move at` event', () => {
|
|
387
411
|
const command = {
|
|
388
412
|
command: 'mouseMoveAt',
|
|
@@ -463,6 +487,14 @@ describe('command code emitter', () => {
|
|
|
463
487
|
}
|
|
464
488
|
return expect(prettify(command)).resolves.toMatchSnapshot()
|
|
465
489
|
})
|
|
490
|
+
it('should emit `run` command for a test with a capitalized name', () => {
|
|
491
|
+
const command = { command: 'run', target: 'Some Test Case', value: '' }
|
|
492
|
+
return expect(prettify(command)).resolves.toMatchSnapshot()
|
|
493
|
+
})
|
|
494
|
+
it('should emit a comment for `run` with a test name from a variable', async () => {
|
|
495
|
+
const command = { command: 'run', target: '${testName}', value: '' }
|
|
496
|
+
expect(await Command.emit(command, opts)).toMatchSnapshot()
|
|
497
|
+
})
|
|
466
498
|
it('should emit `run script` command', () => {
|
|
467
499
|
const command = {
|
|
468
500
|
command: 'runScript',
|
|
@@ -565,22 +597,6 @@ describe('command code emitter', () => {
|
|
|
565
597
|
}
|
|
566
598
|
return expect(prettify(command)).resolves.toMatchSnapshot()
|
|
567
599
|
})
|
|
568
|
-
it('should skip playback supported commands, that are not supported in webdriver', () => {
|
|
569
|
-
return Promise.all([
|
|
570
|
-
expect(
|
|
571
|
-
prettify({ command: 'answerOnNextPrompt', target: 'blah' })
|
|
572
|
-
).resolves.toMatchSnapshot(),
|
|
573
|
-
expect(
|
|
574
|
-
prettify({ command: 'chooseCancelOnNextConfirmation' })
|
|
575
|
-
).resolves.toMatchSnapshot(),
|
|
576
|
-
expect(
|
|
577
|
-
prettify({ command: 'chooseCancelOnNextPrompt' })
|
|
578
|
-
).resolves.toMatchSnapshot(),
|
|
579
|
-
expect(
|
|
580
|
-
prettify({ command: 'chooseOkOnNextConfirmation' })
|
|
581
|
-
).resolves.toMatchSnapshot(),
|
|
582
|
-
])
|
|
583
|
-
})
|
|
584
600
|
it('should emit `store` command', () => {
|
|
585
601
|
const command = {
|
|
586
602
|
command: 'store',
|
|
@@ -637,26 +653,28 @@ describe('command code emitter', () => {
|
|
|
637
653
|
}
|
|
638
654
|
return expect(prettify(command)).resolves.toMatchSnapshot()
|
|
639
655
|
})
|
|
640
|
-
it('should emit `store
|
|
656
|
+
it('should emit `store element count` command', () => {
|
|
641
657
|
const command = {
|
|
642
|
-
command: '
|
|
658
|
+
command: 'storeElementCount',
|
|
643
659
|
target: 'xpath=button',
|
|
644
660
|
value: 'myVar',
|
|
645
661
|
}
|
|
646
662
|
return expect(prettify(command)).resolves.toMatchSnapshot()
|
|
647
663
|
})
|
|
648
|
-
it('should emit `
|
|
664
|
+
it('should emit `times` command', () => {
|
|
649
665
|
const command = {
|
|
650
|
-
command:
|
|
651
|
-
target: '
|
|
666
|
+
command: ControlFlowCommandNames.times,
|
|
667
|
+
target: '5',
|
|
652
668
|
value: '',
|
|
653
669
|
}
|
|
654
|
-
return expect(
|
|
670
|
+
return expect(
|
|
671
|
+
prettify(command, { fullPayload: true })
|
|
672
|
+
).resolves.toMatchSnapshot()
|
|
655
673
|
})
|
|
656
|
-
it('should emit `times` command', () => {
|
|
674
|
+
it('should emit `times` command with a variable count', () => {
|
|
657
675
|
const command = {
|
|
658
676
|
command: ControlFlowCommandNames.times,
|
|
659
|
-
target: '
|
|
677
|
+
target: '${count}',
|
|
660
678
|
value: '',
|
|
661
679
|
}
|
|
662
680
|
return expect(
|
|
@@ -847,25 +865,41 @@ describe('command code emitter', () => {
|
|
|
847
865
|
}
|
|
848
866
|
return expect(prettify(command)).resolves.toMatchSnapshot()
|
|
849
867
|
})
|
|
850
|
-
it('should emit `answer
|
|
868
|
+
it('should emit `answer prompt` command', () => {
|
|
851
869
|
const command = {
|
|
852
|
-
command: '
|
|
870
|
+
command: 'answerPrompt',
|
|
853
871
|
target: 'an answer',
|
|
854
872
|
value: '',
|
|
855
873
|
}
|
|
856
874
|
return expect(prettify(command)).resolves.toMatchSnapshot()
|
|
857
875
|
})
|
|
858
|
-
it('should emit `
|
|
876
|
+
it('should emit `dismiss prompt` command', () => {
|
|
877
|
+
const command = {
|
|
878
|
+
command: 'dismissPrompt',
|
|
879
|
+
target: '',
|
|
880
|
+
value: '',
|
|
881
|
+
}
|
|
882
|
+
return expect(prettify(command)).resolves.toMatchSnapshot()
|
|
883
|
+
})
|
|
884
|
+
it('should emit `accept confirmation` command', () => {
|
|
885
|
+
const command = {
|
|
886
|
+
command: 'acceptConfirmation',
|
|
887
|
+
target: '',
|
|
888
|
+
value: '',
|
|
889
|
+
}
|
|
890
|
+
return expect(prettify(command)).resolves.toMatchSnapshot()
|
|
891
|
+
})
|
|
892
|
+
it('should emit `accept alert` command', () => {
|
|
859
893
|
const command = {
|
|
860
|
-
command: '
|
|
894
|
+
command: 'acceptAlert',
|
|
861
895
|
target: '',
|
|
862
896
|
value: '',
|
|
863
897
|
}
|
|
864
898
|
return expect(prettify(command)).resolves.toMatchSnapshot()
|
|
865
899
|
})
|
|
866
|
-
it('should emit `
|
|
900
|
+
it('should emit `dismiss confirmation` command', () => {
|
|
867
901
|
const command = {
|
|
868
|
-
command: '
|
|
902
|
+
command: 'dismissConfirmation',
|
|
869
903
|
target: '',
|
|
870
904
|
value: '',
|
|
871
905
|
}
|
|
@@ -881,6 +915,16 @@ describe('command code emitter', () => {
|
|
|
881
915
|
prettify(command, { fullPayload: true })
|
|
882
916
|
).resolves.toMatchSnapshot()
|
|
883
917
|
})
|
|
918
|
+
it('should emit `while` command with a loop limit', () => {
|
|
919
|
+
const command = {
|
|
920
|
+
command: ControlFlowCommandNames.while,
|
|
921
|
+
target: 'true',
|
|
922
|
+
value: '5',
|
|
923
|
+
}
|
|
924
|
+
return expect(
|
|
925
|
+
prettify(command, { fullPayload: true })
|
|
926
|
+
).resolves.toMatchSnapshot()
|
|
927
|
+
})
|
|
884
928
|
it('should emit new window handling, if command opens a new window', () => {
|
|
885
929
|
const command = {
|
|
886
930
|
command: 'click',
|