@seleniumhq/code-export-csharp-nunit 3.16.0 → 3.17.4

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.
@@ -263,7 +263,7 @@ exports[`command code emitter should emit \`open\` with absolute url 1`] = `"dri
263
263
  exports[`command code emitter should emit \`pause\` command 1`] = `
264
264
  "try {
265
265
  Thread.Sleep(300);
266
- } catch {
266
+ } catch (Exception e) {
267
267
  Console.WriteLine(\\"{0} Exception caught.\\", e);
268
268
  }"
269
269
  `;
@@ -464,6 +464,13 @@ exports[`command code emitter should emit \`waitForElementVisible\` command 1`]
464
464
  }"
465
465
  `;
466
466
 
467
+ exports[`command code emitter should emit \`waitForText\` command 1`] = `
468
+ "{
469
+ WebDriverWait wait = new WebDriverWait(driver, System.TimeSpan.FromSeconds(30));
470
+ wait.Until(driver => driver.FindElement(By.CssSelector(\\"#blah\\")).Text == \\"text\\");
471
+ }"
472
+ `;
473
+
467
474
  exports[`command code emitter should emit \`while\` command 1`] = `
468
475
  Object {
469
476
  "body": "while ((Boolean) js.ExecuteScript(\\"return (true)\\")) {",
@@ -160,7 +160,7 @@ using OpenQA.Selenium.Support.UI;
160
160
  using OpenQA.Selenium.Interactions;
161
161
  using NUnit.Framework;
162
162
  [TestFixture]
163
- public class LoginTest {
163
+ public class ReusedmethodsTest {
164
164
  private IWebDriver driver;
165
165
  public IDictionary<string, object> vars {get; private set;}
166
166
  private IJavaScriptExecutor js;
@@ -179,7 +179,12 @@ public class LoginTest {
179
179
  driver.FindElement(By.LinkText(\\"Form Authentication\\")).Click();
180
180
  driver.FindElement(By.Id(\\"username\\")).SendKeys(vars[\\"username\\"].ToString());
181
181
  driver.FindElement(By.Id(\\"password\\")).SendKeys(vars[\\"password\\"].ToString());
182
- driver.FindElement(By.CssSelector(\\".fa\\")).Click();
182
+ if ((Boolean) js.ExecuteScript(\\"return (true)\\")) {
183
+ driver.FindElement(By.CssSelector(\\".fa\\")).Click();
184
+ }
185
+ }
186
+ public void tinymethod() {
187
+ vars[\\"value\\"] = \\"field\\";
183
188
  }
184
189
  [Test]
185
190
  public void invalidcredentials() {
@@ -193,6 +198,13 @@ public class LoginTest {
193
198
  vars[\\"password\\"] = \\"SuperSecretPassword!\\";
194
199
  login();
195
200
  }
201
+ [Test]
202
+ public void twomethods() {
203
+ vars[\\"username\\"] = \\"blah\\";
204
+ vars[\\"password\\"] = \\"blah\\";
205
+ login();
206
+ tinymethod();
207
+ }
196
208
  }
197
209
  "
198
210
  `;
@@ -400,7 +412,9 @@ public class ValidcredentialsTest {
400
412
  driver.FindElement(By.LinkText(\\"Form Authentication\\")).Click();
401
413
  driver.FindElement(By.Id(\\"username\\")).SendKeys(vars[\\"username\\"].ToString());
402
414
  driver.FindElement(By.Id(\\"password\\")).SendKeys(vars[\\"password\\"].ToString());
403
- driver.FindElement(By.CssSelector(\\".fa\\")).Click();
415
+ if ((Boolean) js.ExecuteScript(\\"return (true)\\")) {
416
+ driver.FindElement(By.CssSelector(\\".fa\\")).Click();
417
+ }
404
418
  }
405
419
  [Test]
406
420
  public void validcredentials() {
@@ -21,7 +21,7 @@ import {
21
21
  ControlFlowCommandNames,
22
22
  } from '../../../selenium-ide/src/neo/models/Command'
23
23
  import { opts } from '../../src/index'
24
- import { codeExport as exporter } from '@seleniumhq/side-utils'
24
+ import { codeExport as exporter } from '@seleniumhq/side-code-export'
25
25
 
26
26
  const commandPrefixPadding = opts.commandPrefixPadding
27
27
 
@@ -839,6 +839,14 @@ describe('command code emitter', () => {
839
839
  }
840
840
  return expect(prettify(command)).resolves.toMatchSnapshot()
841
841
  })
842
+ it('should emit `waitForText` command', () => {
843
+ const command = {
844
+ command: 'waitForText',
845
+ target: 'css=#blah',
846
+ value: 'text',
847
+ }
848
+ return expect(prettify(command)).resolves.toMatchSnapshot()
849
+ })
842
850
  it('should emit `answer on visible prompt` command', () => {
843
851
  const command = {
844
852
  command: 'webdriverAnswerOnVisiblePrompt',
@@ -17,8 +17,14 @@
17
17
 
18
18
  import fs from 'fs'
19
19
  import path from 'path'
20
- import { emitTest, emitSuite, _emitMethod, _findTestByName } from '../../src'
21
- import { project as projectProcessor } from '@seleniumhq/side-utils'
20
+ import codeExport, {
21
+ emitTest,
22
+ emitSuite,
23
+ _emitMethod,
24
+ _findTestByName,
25
+ } from '../../src'
26
+ import Command from '../../src/command'
27
+ import { project as projectProcessor } from '@seleniumhq/side-code-export'
22
28
 
23
29
  function readFile(filename) {
24
30
  return JSON.parse(
@@ -28,7 +34,7 @@ function readFile(filename) {
28
34
  '..',
29
35
  '..',
30
36
  '..',
31
- 'side-utils',
37
+ 'side-code-export',
32
38
  '__test__',
33
39
  'test-files',
34
40
  filename
@@ -132,6 +138,9 @@ describe('Code Export C# NUnit', () => {
132
138
  expect(results.body).toBeDefined()
133
139
  expect(results.body).toMatchSnapshot()
134
140
  })
141
+ it('should export the command emitter', () => {
142
+ expect(Command.emit).toStrictEqual(codeExport.emit.command)
143
+ })
135
144
  })
136
145
 
137
146
  function normalizeProject(project) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seleniumhq/code-export-csharp-nunit",
3
- "version": "3.16.0",
3
+ "version": "3.17.4",
4
4
  "description": "Export Selenium IDE project contents to C# NUnit",
5
5
  "repository": "https://github.com/SeleniumHQ/selenium-ide",
6
6
  "keywords": [
@@ -21,8 +21,8 @@
21
21
  "@babel/preset-env": "^7.4.5"
22
22
  },
23
23
  "dependencies": {
24
- "@seleniumhq/code-export-csharp-commons": "^3.16.0",
25
- "@seleniumhq/side-utils": "^3.16.0"
24
+ "@seleniumhq/code-export-csharp-commons": "^3.17.4",
25
+ "@seleniumhq/side-code-export": "^4.0.0-alpha.0"
26
26
  },
27
- "gitHead": "70be270a6733b9cd14a9a86f11cbffaf7892c585"
27
+ "gitHead": "351d5762ed774d624831bf9a7a02ae4fb8e70ea9"
28
28
  }
package/src/command.js CHANGED
@@ -15,7 +15,7 @@
15
15
  // specific language governing permissions and limitations
16
16
  // under the License.
17
17
 
18
- import { codeExport as exporter } from '@seleniumhq/side-utils'
18
+ import { codeExport as exporter } from '@seleniumhq/side-code-export'
19
19
  import { Command } from '@seleniumhq/code-export-csharp-commons'
20
20
 
21
21
  exporter.register.preprocessors(Command.emitters)
package/src/hook.js CHANGED
@@ -15,7 +15,7 @@
15
15
  // specific language governing permissions and limitations
16
16
  // under the License.
17
17
 
18
- import { codeExport as exporter } from '@seleniumhq/side-utils'
18
+ import { codeExport as exporter } from '@seleniumhq/side-code-export'
19
19
 
20
20
  const emitters = {
21
21
  afterAll,
package/src/index.js CHANGED
@@ -15,7 +15,7 @@
15
15
  // specific language governing permissions and limitations
16
16
  // under the License.
17
17
 
18
- import { codeExport as exporter } from '@seleniumhq/side-utils'
18
+ import { codeExport as exporter } from '@seleniumhq/side-code-export'
19
19
  import emitter from './command'
20
20
  import { location } from '@seleniumhq/code-export-csharp-commons'
21
21
  import { generateHooks } from './hook'
@@ -60,6 +60,7 @@ export async function emitTest({
60
60
  project,
61
61
  enableOriginTracing,
62
62
  beforeEachOptions,
63
+ enableDescriptionAsComment,
63
64
  }) {
64
65
  global.baseUrl = baseUrl
65
66
  const testDeclaration = generateTestDeclaration(test.name)
@@ -67,6 +68,7 @@ export async function emitTest({
67
68
  ...opts,
68
69
  testDeclaration,
69
70
  enableOriginTracing,
71
+ enableDescriptionAsComment,
70
72
  project,
71
73
  })
72
74
  const suiteName = test.name
@@ -92,10 +94,12 @@ export async function emitSuite({
92
94
  project,
93
95
  enableOriginTracing,
94
96
  beforeEachOptions,
97
+ enableDescriptionAsComment,
95
98
  }) {
96
99
  global.baseUrl = baseUrl
97
100
  const result = await exporter.emit.testsFromSuite(tests, suite, opts, {
98
101
  enableOriginTracing,
102
+ enableDescriptionAsComment,
99
103
  generateTestDeclaration,
100
104
  project,
101
105
  })
@@ -118,6 +122,7 @@ export default {
118
122
  test: emitTest,
119
123
  suite: emitSuite,
120
124
  locator: location.emit,
125
+ command: emitter.emit,
121
126
  },
122
127
  register: {
123
128
  command: emitter.register,
package/dist/command.js DELETED
@@ -1,57 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _sideUtils = require("@seleniumhq/side-utils");
9
-
10
- var _codeExportCsharpCommons = require("@seleniumhq/code-export-csharp-commons");
11
-
12
- // Licensed to the Software Freedom Conservancy (SFC) under one
13
- // or more contributor license agreements. See the NOTICE file
14
- // distributed with this work for additional information
15
- // regarding copyright ownership. The SFC licenses this file
16
- // to you under the Apache License, Version 2.0 (the
17
- // "License"); you may not use this file except in compliance
18
- // with the License. You may obtain a copy of the License at
19
- //
20
- // http://www.apache.org/licenses/LICENSE-2.0
21
- //
22
- // Unless required by applicable law or agreed to in writing,
23
- // software distributed under the License is distributed on an
24
- // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
25
- // KIND, either express or implied. See the License for the
26
- // specific language governing permissions and limitations
27
- // under the License.
28
- _sideUtils.codeExport.register.preprocessors(_codeExportCsharpCommons.Command.emitters);
29
-
30
- function register(command, emitter) {
31
- _sideUtils.codeExport.register.emitter({
32
- command,
33
- emitter,
34
- emitters: _codeExportCsharpCommons.Command.emitters
35
- });
36
- }
37
-
38
- function emit(command) {
39
- return _sideUtils.codeExport.emit.command(command, _codeExportCsharpCommons.Command.emitters[command.command], {
40
- variableLookup: _codeExportCsharpCommons.Command.variableLookup,
41
- emitNewWindowHandling: _codeExportCsharpCommons.Command.extras.emitNewWindowHandling
42
- });
43
- }
44
-
45
- function canEmit(commandName) {
46
- return !!_codeExportCsharpCommons.Command.emitters[commandName];
47
- }
48
-
49
- var _default = {
50
- canEmit,
51
- emit,
52
- register,
53
- extras: {
54
- emitWaitForWindow: _codeExportCsharpCommons.Command.extras.emitWaitForWindow
55
- }
56
- };
57
- exports.default = _default;
package/dist/hook.js DELETED
@@ -1,216 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.generateHooks = generateHooks;
7
-
8
- var _sideUtils = require("@seleniumhq/side-utils");
9
-
10
- // Licensed to the Software Freedom Conservancy (SFC) under one
11
- // or more contributor license agreements. See the NOTICE file
12
- // distributed with this work for additional information
13
- // regarding copyright ownership. The SFC licenses this file
14
- // to you under the Apache License, Version 2.0 (the
15
- // "License"); you may not use this file except in compliance
16
- // with the License. You may obtain a copy of the License at
17
- //
18
- // http://www.apache.org/licenses/LICENSE-2.0
19
- //
20
- // Unless required by applicable law or agreed to in writing,
21
- // software distributed under the License is distributed on an
22
- // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
23
- // KIND, either express or implied. See the License for the
24
- // specific language governing permissions and limitations
25
- // under the License.
26
- const emitters = {
27
- afterAll,
28
- afterEach,
29
- beforeAll,
30
- beforeEach,
31
- declareDependencies,
32
- declareMethods: empty,
33
- declareVariables,
34
- inEachBegin: empty,
35
- inEachEnd: empty
36
- };
37
-
38
- function generate(hookName) {
39
- return new _sideUtils.codeExport.hook(emitters[hookName]());
40
- }
41
-
42
- function generateHooks() {
43
- let result = {};
44
- Object.keys(emitters).forEach(hookName => {
45
- result[hookName] = generate(hookName);
46
- });
47
- return result;
48
- }
49
-
50
- function afterAll() {
51
- const params = {
52
- startingSyntax: {
53
- commands: [{
54
- level: 0,
55
- statement: '[OneTimeTearDown]'
56
- }, {
57
- level: 0,
58
- statement: 'public void FinalTearDown() {'
59
- }]
60
- },
61
- endingSyntax: {
62
- commands: [{
63
- level: 0,
64
- statement: '}'
65
- }]
66
- },
67
- registrationLevel: 1
68
- };
69
- return params;
70
- }
71
-
72
- function afterEach() {
73
- const params = {
74
- startingSyntax: {
75
- commands: [{
76
- level: 0,
77
- statement: '[TearDown]'
78
- }, {
79
- level: 0,
80
- statement: 'protected void TearDown() {'
81
- }, {
82
- level: 1,
83
- statement: 'driver.Quit();'
84
- }]
85
- },
86
- endingSyntax: {
87
- commands: [{
88
- level: 0,
89
- statement: '}'
90
- }]
91
- }
92
- };
93
- return params;
94
- }
95
-
96
- function beforeAll() {
97
- const params = {
98
- startingSyntax: {
99
- commands: [{
100
- level: 0,
101
- statement: '[OneTimeSetUp]'
102
- }, {
103
- level: 0,
104
- statement: 'public void InitialSetUp() {'
105
- }]
106
- },
107
- endingSyntax: {
108
- commands: [{
109
- level: 0,
110
- statement: '}'
111
- }]
112
- },
113
- registrationLevel: 1
114
- };
115
- return params;
116
- }
117
-
118
- function beforeEach() {
119
- const params = {
120
- startingSyntax: ({
121
- browserName,
122
- gridUrl
123
- } = {}) => ({
124
- commands: [{
125
- level: 0,
126
- statement: '[SetUp]'
127
- }, {
128
- level: 0,
129
- statement: 'public void SetUp() {'
130
- }, {
131
- level: 1,
132
- statement: gridUrl ? `driver = new RemoteWebDriver(new Uri("${gridUrl}"), new ${browserName ? browserName : 'Chrome'}Options().ToCapabilities());` : `driver = new ${browserName ? browserName : 'Chrome'}Driver();`
133
- }, {
134
- level: 1,
135
- statement: 'js = (IJavaScriptExecutor)driver;'
136
- }, {
137
- level: 1,
138
- statement: 'vars = new Dictionary<string, object>();'
139
- }]
140
- }),
141
- endingSyntax: {
142
- commands: [{
143
- level: 0,
144
- statement: '}'
145
- }]
146
- }
147
- };
148
- return params;
149
- }
150
-
151
- function declareDependencies() {
152
- const params = {
153
- startingSyntax: {
154
- commands: [{
155
- level: 0,
156
- statement: 'using System;'
157
- }, {
158
- level: 0,
159
- statement: 'using System.Collections;'
160
- }, {
161
- level: 0,
162
- statement: 'using System.Collections.Generic;'
163
- }, {
164
- level: 0,
165
- statement: 'using System.Linq;'
166
- }, {
167
- level: 0,
168
- statement: 'using System.Threading;'
169
- }, {
170
- level: 0,
171
- statement: 'using OpenQA.Selenium;'
172
- }, {
173
- level: 0,
174
- statement: 'using OpenQA.Selenium.Chrome;'
175
- }, {
176
- level: 0,
177
- statement: 'using OpenQA.Selenium.Firefox;'
178
- }, {
179
- level: 0,
180
- statement: `using OpenQA.Selenium.Remote;`
181
- }, {
182
- level: 0,
183
- statement: 'using OpenQA.Selenium.Support.UI;'
184
- }, {
185
- level: 0,
186
- statement: 'using OpenQA.Selenium.Interactions;'
187
- }, {
188
- level: 0,
189
- statement: 'using NUnit.Framework;'
190
- }]
191
- }
192
- };
193
- return params;
194
- }
195
-
196
- function declareVariables() {
197
- const params = {
198
- startingSyntax: {
199
- commands: [{
200
- level: 0,
201
- statement: 'private IWebDriver driver;'
202
- }, {
203
- level: 0,
204
- statement: 'public IDictionary<string, object> vars {get; private set;}'
205
- }, {
206
- level: 0,
207
- statement: 'private IJavaScriptExecutor js;'
208
- }]
209
- }
210
- };
211
- return params;
212
- }
213
-
214
- function empty() {
215
- return {};
216
- }
@@ -1,48 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- // Licensed to the Software Freedom Conservancy (SFC) under one
7
- // or more contributor license agreements. See the NOTICE file
8
- // distributed with this work for additional information
9
- // regarding copyright ownership. The SFC licenses this file
10
- // to you under the Apache License, Version 2.0 (the
11
- // "License"); you may not use this file except in compliance
12
- // with the License. You may obtain a copy of the License at
13
- //
14
- // http://www.apache.org/licenses/LICENSE-2.0
15
- //
16
- // Unless required by applicable law or agreed to in writing,
17
- // software distributed under the License is distributed on an
18
- // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19
- // KIND, either express or implied. See the License for the
20
- // specific language governing permissions and limitations
21
- // under the License.
22
-
23
- let afterAll = `
24
- @AfterAll
25
- public void finalTearDown() {
26
- `;
27
-
28
- let hooks = [];
29
-
30
- function register(statement) {
31
- hooks.push(statement);
32
- }
33
-
34
- function clear() {
35
- hooks = [];
36
- }
37
-
38
- function emit({ isOptional } = { isOptional: false }) {
39
- if (isOptional && !hooks.length) return '';
40
- return afterAll + hooks.join('\r\n') + ` }
41
- `;
42
- }
43
-
44
- exports.default = {
45
- register,
46
- clear,
47
- emit
48
- };
@@ -1,49 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- // Licensed to the Software Freedom Conservancy (SFC) under one
7
- // or more contributor license agreements. See the NOTICE file
8
- // distributed with this work for additional information
9
- // regarding copyright ownership. The SFC licenses this file
10
- // to you under the Apache License, Version 2.0 (the
11
- // "License"); you may not use this file except in compliance
12
- // with the License. You may obtain a copy of the License at
13
- //
14
- // http://www.apache.org/licenses/LICENSE-2.0
15
- //
16
- // Unless required by applicable law or agreed to in writing,
17
- // software distributed under the License is distributed on an
18
- // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19
- // KIND, either express or implied. See the License for the
20
- // specific language governing permissions and limitations
21
- // under the License.
22
-
23
- let afterEach = `
24
- @After
25
- public void tearDown() {
26
- driver.quit();
27
- `;
28
-
29
- let hooks = [];
30
-
31
- function register(statement) {
32
- hooks.push(statement);
33
- }
34
-
35
- function clear() {
36
- hooks = [];
37
- }
38
-
39
- function emit({ isOptional } = { isOptional: false }) {
40
- if (isOptional && !hooks.length) return '';
41
- return afterEach + hooks.join('\r\n') + ` }
42
- `;
43
- }
44
-
45
- exports.default = {
46
- register,
47
- clear,
48
- emit
49
- };
@@ -1,48 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- // Licensed to the Software Freedom Conservancy (SFC) under one
7
- // or more contributor license agreements. See the NOTICE file
8
- // distributed with this work for additional information
9
- // regarding copyright ownership. The SFC licenses this file
10
- // to you under the Apache License, Version 2.0 (the
11
- // "License"); you may not use this file except in compliance
12
- // with the License. You may obtain a copy of the License at
13
- //
14
- // http://www.apache.org/licenses/LICENSE-2.0
15
- //
16
- // Unless required by applicable law or agreed to in writing,
17
- // software distributed under the License is distributed on an
18
- // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19
- // KIND, either express or implied. See the License for the
20
- // specific language governing permissions and limitations
21
- // under the License.
22
-
23
- let beforeAll = `
24
- @BeforeAll
25
- public void initialSetUp() {
26
- `;
27
-
28
- let hooks = [];
29
-
30
- function register(statement) {
31
- hooks.push(statement);
32
- }
33
-
34
- function clear() {
35
- hooks = [];
36
- }
37
-
38
- function emit({ isOptional } = { isOptional: false }) {
39
- if (isOptional && !hooks.length) return '';
40
- return beforeAll + hooks.join('\r\n') + ` }
41
- `;
42
- }
43
-
44
- exports.default = {
45
- register,
46
- clear,
47
- emit
48
- };
@@ -1,50 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- // Licensed to the Software Freedom Conservancy (SFC) under one
7
- // or more contributor license agreements. See the NOTICE file
8
- // distributed with this work for additional information
9
- // regarding copyright ownership. The SFC licenses this file
10
- // to you under the Apache License, Version 2.0 (the
11
- // "License"); you may not use this file except in compliance
12
- // with the License. You may obtain a copy of the License at
13
- //
14
- // http://www.apache.org/licenses/LICENSE-2.0
15
- //
16
- // Unless required by applicable law or agreed to in writing,
17
- // software distributed under the License is distributed on an
18
- // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19
- // KIND, either express or implied. See the License for the
20
- // specific language governing permissions and limitations
21
- // under the License.
22
-
23
- let beforeEach = `
24
- @Before
25
- public void setUp() {
26
- driver = new FirefoxDriver();
27
- js = (JavascriptExecutor) driver;
28
- `;
29
-
30
- let hooks = [];
31
-
32
- function register(statement) {
33
- hooks.push(statement);
34
- }
35
-
36
- function clear() {
37
- hooks = [];
38
- }
39
-
40
- function emit({ isOptional } = { isOptional: false }) {
41
- if (isOptional && !hooks.length) return '';
42
- return beforeEach + hooks.join('\r\n') + ` }
43
- `;
44
- }
45
-
46
- exports.default = {
47
- register,
48
- clear,
49
- emit
50
- };