@seleniumhq/code-export-csharp-xunit 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.
@@ -158,7 +158,7 @@ using OpenQA.Selenium.Remote;
158
158
  using OpenQA.Selenium.Support.UI;
159
159
  using OpenQA.Selenium.Interactions;
160
160
  using Xunit;
161
- namespace Login
161
+ namespace Reusedmethods
162
162
  {
163
163
  public class SuiteTests : IDisposable {
164
164
  public IWebDriver driver {get; private set;}
@@ -180,7 +180,13 @@ public class SuiteTests : IDisposable {
180
180
  driver.FindElement(By.LinkText(\\"Form Authentication\\")).Click();
181
181
  driver.FindElement(By.Id(\\"username\\")).SendKeys(vars[\\"username\\"].ToString());
182
182
  driver.FindElement(By.Id(\\"password\\")).SendKeys(vars[\\"password\\"].ToString());
183
- driver.FindElement(By.CssSelector(\\".fa\\")).Click();
183
+ if ((Boolean) js.ExecuteScript(\\"return (true)\\")) {
184
+ driver.FindElement(By.CssSelector(\\".fa\\")).Click();
185
+ }
186
+ }
187
+ public void tinymethod()
188
+ {
189
+ vars[\\"value\\"] = \\"field\\";
184
190
  }
185
191
  [Fact]
186
192
  public void Invalidcredentials() {
@@ -194,6 +200,13 @@ public class SuiteTests : IDisposable {
194
200
  vars[\\"password\\"] = \\"SuperSecretPassword!\\";
195
201
  login();
196
202
  }
203
+ [Fact]
204
+ public void Twomethods() {
205
+ vars[\\"username\\"] = \\"blah\\";
206
+ vars[\\"password\\"] = \\"blah\\";
207
+ login();
208
+ tinymethod();
209
+ }
197
210
  }
198
211
  }"
199
212
  `;
@@ -400,7 +413,9 @@ public class SuiteTests : IDisposable {
400
413
  driver.FindElement(By.LinkText(\\"Form Authentication\\")).Click();
401
414
  driver.FindElement(By.Id(\\"username\\")).SendKeys(vars[\\"username\\"].ToString());
402
415
  driver.FindElement(By.Id(\\"password\\")).SendKeys(vars[\\"password\\"].ToString());
403
- driver.FindElement(By.CssSelector(\\".fa\\")).Click();
416
+ if ((Boolean) js.ExecuteScript(\\"return (true)\\")) {
417
+ driver.FindElement(By.CssSelector(\\".fa\\")).Click();
418
+ }
404
419
  }
405
420
  [Fact]
406
421
  public void Validcredentials() {
@@ -18,7 +18,7 @@
18
18
  import Command from '../../src/command'
19
19
  import { Commands } from '../../../selenium-ide/src/neo/models/Command'
20
20
  import { opts } from '../../src/index'
21
- import { codeExport as exporter } from '@seleniumhq/side-utils'
21
+ import { codeExport as exporter } from '@seleniumhq/side-code-export'
22
22
 
23
23
  const commandPrefixPadding = opts.commandPrefixPadding
24
24
 
@@ -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# xUnit', () => {
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-xunit",
3
- "version": "3.16.0",
3
+ "version": "3.17.4",
4
4
  "description": "Export Selenium IDE project contents to C# XUnit",
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, location } from '@seleniumhq/code-export-csharp-commons'
20
20
  const emitters = { ...Command.emitters }
21
21
 
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: empty,
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'
@@ -68,6 +68,7 @@ export async function emitTest({
68
68
  project,
69
69
  enableOriginTracing,
70
70
  beforeEachOptions,
71
+ enableDescriptionAsComment,
71
72
  }) {
72
73
  global.baseUrl = baseUrl
73
74
  const testDeclaration = generateTestDeclaration(test.name)
@@ -75,6 +76,7 @@ export async function emitTest({
75
76
  ...opts,
76
77
  testDeclaration,
77
78
  enableOriginTracing,
79
+ enableDescriptionAsComment,
78
80
  project,
79
81
  })
80
82
  const suiteName = test.name
@@ -100,10 +102,12 @@ export async function emitSuite({
100
102
  project,
101
103
  enableOriginTracing,
102
104
  beforeEachOptions,
105
+ enableDescriptionAsComment,
103
106
  }) {
104
107
  global.baseUrl = baseUrl
105
108
  const result = await exporter.emit.testsFromSuite(tests, suite, opts, {
106
109
  enableOriginTracing,
110
+ enableDescriptionAsComment,
107
111
  generateTestDeclaration,
108
112
  project,
109
113
  })
@@ -160,6 +164,7 @@ export default {
160
164
  test: emitTest,
161
165
  suite: emitSuite,
162
166
  locator: location.emit,
167
+ command: emitter.emit,
163
168
  },
164
169
  register: {
165
170
  command: emitter.register,
package/dist/command.js DELETED
@@ -1,268 +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
- function _objectSpread2(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
13
-
14
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
15
-
16
- const emitters = _objectSpread2({}, _codeExportCsharpCommons.Command.emitters);
17
-
18
- _sideUtils.codeExport.register.preprocessors(emitters);
19
-
20
- function register(command, emitter) {
21
- _sideUtils.codeExport.register.emitter({
22
- command,
23
- emitter,
24
- emitters: emitters
25
- });
26
- }
27
-
28
- function emit(command) {
29
- return _sideUtils.codeExport.emit.command(command, emitters[command.command], {
30
- variableLookup: _codeExportCsharpCommons.Command.variableLookup,
31
- emitNewWindowHandling: _codeExportCsharpCommons.Command.extras.emitNewWindowHandling
32
- });
33
- }
34
-
35
- function canEmit(commandName) {
36
- return !!emitters[commandName];
37
- }
38
-
39
- emitters.assert = emitAssert;
40
- emitters.verify = emitAssert;
41
-
42
- function emitAssert(varName, value) {
43
- return Promise.resolve(`Assert.Equal(vars["${varName}"].ToString(), "${value}");`);
44
- }
45
-
46
- emitters.assertAlert = emitAssertAlert;
47
- emitters.assertConfirmation = emitAssertAlert;
48
- emitters.assertPrompt = emitAssertAlert;
49
-
50
- function emitAssertAlert(AlertText) {
51
- return Promise.resolve(`Assert.Equal(driver.SwitchTo().Alert().Text, "${AlertText}");`);
52
- }
53
-
54
- emitters.assertChecked = emitVerifyChecked;
55
- emitters.verifyChecked = emitVerifyChecked;
56
-
57
- async function emitVerifyChecked(locator) {
58
- return Promise.resolve(`Assert.True(driver.FindElement(${await _codeExportCsharpCommons.location.emit(locator)}).Selected);`);
59
- }
60
-
61
- emitters.assertEditable = emitVerifyEditable;
62
- emitters.verifyEditable = emitVerifyEditable;
63
-
64
- async function emitVerifyEditable(locator) {
65
- const commands = [{
66
- level: 0,
67
- statement: '{'
68
- }, {
69
- level: 1,
70
- statement: `var element = driver.FindElement(${await _codeExportCsharpCommons.location.emit(locator)});`
71
- }, {
72
- level: 1,
73
- statement: 'Boolean isEditable = element.Enabled && element.GetAttribute("readonly") == null;'
74
- }, {
75
- level: 1,
76
- statement: 'Assert.True(isEditable);'
77
- }, {
78
- level: 0,
79
- statement: '}'
80
- }];
81
- return Promise.resolve({
82
- commands
83
- });
84
- }
85
-
86
- emitters.assertElementPresent = emitVerifyElementPresent;
87
- emitters.verifyElementPresent = emitVerifyElementPresent;
88
-
89
- async function emitVerifyElementPresent(locator) {
90
- const commands = [{
91
- level: 0,
92
- statement: '{'
93
- }, {
94
- level: 1,
95
- statement: `IReadOnlyCollection<IWebElement> elements = driver.FindElements(${await _codeExportCsharpCommons.location.emit(locator)});`
96
- }, {
97
- level: 1,
98
- statement: 'Assert.True(elements.Count > 0);'
99
- }, {
100
- level: 0,
101
- statement: '}'
102
- }];
103
- return Promise.resolve({
104
- commands
105
- });
106
- }
107
-
108
- emitters.assertElementNotPresent = emitVerifyElementNotPresent;
109
- emitters.verifyElementNotPresent = emitVerifyElementNotPresent;
110
-
111
- async function emitVerifyElementNotPresent(locator) {
112
- const commands = [{
113
- level: 0,
114
- statement: '{'
115
- }, {
116
- level: 1,
117
- statement: `IReadOnlyCollection<IWebElement> elements = driver.FindElements(${await _codeExportCsharpCommons.location.emit(locator)});`
118
- }, {
119
- level: 1,
120
- statement: 'Assert.True(elements.Count == 0);'
121
- }, {
122
- level: 0,
123
- statement: '}'
124
- }];
125
- return Promise.resolve({
126
- commands
127
- });
128
- }
129
-
130
- emitters.assertNotChecked = emitVerifyNotChecked;
131
- emitters.verifyNotChecked = emitVerifyNotChecked;
132
-
133
- async function emitVerifyNotChecked(locator) {
134
- return Promise.resolve(`Assert.False(driver.FindElement(${await _codeExportCsharpCommons.location.emit(locator)}).Selected);`);
135
- }
136
-
137
- emitters.assertNotEditable = emitVerifyNotEditable;
138
- emitters.verifyNotEdtiable = emitVerifyNotEditable;
139
-
140
- async function emitVerifyNotEditable(locator) {
141
- const commands = [{
142
- level: 0,
143
- statement: '{'
144
- }, {
145
- level: 1,
146
- statement: `var element = driver.FindElement(${await _codeExportCsharpCommons.location.emit(locator)});`
147
- }, {
148
- level: 1,
149
- statement: 'Boolean isEditable = element.Enabled && element.GetAttribute("readonly") == null;'
150
- }, {
151
- level: 1,
152
- statement: 'Assert.False(isEditable);'
153
- }, {
154
- level: 0,
155
- statement: '}'
156
- }];
157
- return Promise.resolve({
158
- commands
159
- });
160
- }
161
-
162
- emitters.assertNotSelectedValue = emitVerifyNotSelectedValue;
163
- emitters.verifyNotSelectedValue = emitVerifyNotSelectedValue;
164
-
165
- async function emitVerifyNotSelectedValue(locator, expectedValue) {
166
- const commands = [{
167
- level: 0,
168
- statement: '{'
169
- }, {
170
- level: 1,
171
- statement: `String value = driver.FindElement(${await _codeExportCsharpCommons.location.emit(locator)}).GetAttribute("value");`
172
- }, {
173
- level: 1,
174
- statement: `Assert.NotEqual(value, ${_sideUtils.codeExport.emit.text(expectedValue)});`
175
- }, {
176
- level: 0,
177
- statement: '}'
178
- }];
179
- return Promise.resolve({
180
- commands
181
- });
182
- }
183
-
184
- emitters.assertNotText = emitVerifyNotText;
185
- emitters.verifyNotText = emitVerifyNotText;
186
-
187
- async function emitVerifyNotText(locator, text) {
188
- const result = `driver.FindElement(${await _codeExportCsharpCommons.location.emit(locator)}).Text`;
189
- return Promise.resolve(`Assert.NotEqual(${result}, "${_sideUtils.codeExport.emit.text(text)}");`);
190
- }
191
-
192
- emitters.assertSelectedLabel = emitVerifySelectedLabel;
193
- emitters.verifySelectedLabel = emitVerifySelectedLabel;
194
-
195
- async function emitVerifySelectedLabel(locator, labelValue) {
196
- const commands = [{
197
- level: 0,
198
- statement: '{'
199
- }, {
200
- level: 1,
201
- statement: `var element = driver.FindElement(${await _codeExportCsharpCommons.location.emit(locator)});`
202
- }, {
203
- level: 1,
204
- statement: 'String value = element.GetAttribute("value");'
205
- }, {
206
- level: 1,
207
- statement: `String locator = String.Format("option[@value='%s']", "value");`
208
- }, {
209
- level: 1,
210
- statement: 'String selectedText = element.FindElement(By.XPath(locator)).Text;'
211
- }, {
212
- level: 1,
213
- statement: `Assert.Equal(selectedText, "${labelValue}");`
214
- }, {
215
- level: 0,
216
- statement: '}'
217
- }];
218
- return Promise.resolve({
219
- commands
220
- });
221
- }
222
-
223
- emitters.assertSelectedValue = emitVerifyValue;
224
- emitters.verifySelectedValue = emitVerifyValue;
225
- emitters.assertValue = emitVerifyValue;
226
-
227
- async function emitVerifyValue(locator, value) {
228
- const commands = [{
229
- level: 0,
230
- statement: '{'
231
- }, {
232
- level: 1,
233
- statement: `String value = driver.FindElement(${await _codeExportCsharpCommons.location.emit(locator)}).GetAttribute("value");`
234
- }, {
235
- level: 1,
236
- statement: `Assert.Equal(value, "${value}");`
237
- }, {
238
- level: 0,
239
- statement: '}'
240
- }];
241
- return Promise.resolve({
242
- commands
243
- });
244
- }
245
-
246
- emitters.assertText = emitVerifyText;
247
- emitters.verifyText = emitVerifyText;
248
-
249
- async function emitVerifyText(locator, text) {
250
- return Promise.resolve(`Assert.Equal(driver.FindElement(${await _codeExportCsharpCommons.location.emit(locator)}).Text, "${_sideUtils.codeExport.emit.text(text)}");`);
251
- }
252
-
253
- emitters.assertTitle = emitVerifyTitle;
254
- emitters.verifyTitle = emitVerifyTitle;
255
-
256
- async function emitVerifyTitle(title) {
257
- return Promise.resolve(`Assert.Equal(driver.Title, "${title}");`);
258
- }
259
-
260
- var _default = {
261
- canEmit,
262
- emit,
263
- register,
264
- extras: {
265
- emitWaitForWindow: _codeExportCsharpCommons.Command.extras.emitWaitForWindow
266
- }
267
- };
268
- exports.default = _default;
package/dist/hook.js DELETED
@@ -1,169 +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: empty,
28
- afterEach,
29
- beforeAll: empty,
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 beforeEach() {
51
- const params = {
52
- startingSyntax: ({
53
- browserName,
54
- gridUrl
55
- } = {}) => ({
56
- commands: [{
57
- level: 0,
58
- statement: `public SuiteTests()`
59
- }, {
60
- level: 0,
61
- statement: `{`
62
- }, {
63
- level: 1,
64
- statement: gridUrl ? `driver = new RemoteWebDriver(new Uri("${gridUrl}"), new ${browserName ? browserName : 'Chrome'}Options().ToCapabilities());` : `driver = new ${browserName ? browserName : 'Chrome'}Driver();`
65
- }, {
66
- level: 1,
67
- statement: `js = (IJavaScriptExecutor)driver;`
68
- }, {
69
- level: 1,
70
- statement: `vars = new Dictionary<String, Object>();`
71
- }]
72
- }),
73
- endingSyntax: {
74
- commands: [{
75
- level: 0,
76
- statement: '}'
77
- }]
78
- }
79
- };
80
- return params;
81
- }
82
-
83
- function afterEach() {
84
- const params = {
85
- startingSyntax: {
86
- commands: [{
87
- level: 0,
88
- statement: `public void Dispose()`
89
- }, {
90
- level: 0,
91
- statement: `{`
92
- }, {
93
- level: 1,
94
- statement: `driver.Quit();`
95
- }]
96
- },
97
- endingSyntax: {
98
- commands: [{
99
- level: 0,
100
- statement: '}'
101
- }]
102
- }
103
- };
104
- return params;
105
- }
106
-
107
- function declareDependencies() {
108
- const params = {
109
- startingSyntax: {
110
- commands: [{
111
- level: 0,
112
- statement: `using System;`
113
- }, {
114
- level: 0,
115
- statement: `using System.Collections.Generic;`
116
- }, {
117
- level: 0,
118
- statement: `using System.Linq;`
119
- }, {
120
- level: 0,
121
- statement: 'using System.Threading;'
122
- }, {
123
- level: 0,
124
- statement: `using OpenQA.Selenium;`
125
- }, {
126
- level: 0,
127
- statement: `using OpenQA.Selenium.Chrome;`
128
- }, {
129
- level: 0,
130
- statement: `using OpenQA.Selenium.Firefox;`
131
- }, {
132
- level: 0,
133
- statement: `using OpenQA.Selenium.Remote;`
134
- }, {
135
- level: 0,
136
- statement: `using OpenQA.Selenium.Support.UI;`
137
- }, {
138
- level: 0,
139
- statement: `using OpenQA.Selenium.Interactions;`
140
- }, {
141
- level: 0,
142
- statement: `using Xunit;`
143
- }]
144
- }
145
- };
146
- return params;
147
- }
148
-
149
- function declareVariables() {
150
- const params = {
151
- startingSyntax: {
152
- commands: [{
153
- level: 0,
154
- statement: `public IWebDriver driver {get; private set;}`
155
- }, {
156
- level: 0,
157
- statement: `public IDictionary<String, Object> vars {get; private set;}`
158
- }, {
159
- level: 0,
160
- statement: `public IJavaScriptExecutor js {get; private set;}`
161
- }]
162
- }
163
- };
164
- return params;
165
- }
166
-
167
- function empty() {
168
- return {};
169
- }
package/dist/index.js DELETED
@@ -1,176 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.emitTest = emitTest;
7
- exports.emitSuite = emitSuite;
8
- exports.default = exports.opts = exports.displayName = void 0;
9
-
10
- var _sideUtils = require("@seleniumhq/side-utils");
11
-
12
- var _command = _interopRequireDefault(require("./command"));
13
-
14
- var _codeExportCsharpCommons = require("@seleniumhq/code-export-csharp-commons");
15
-
16
- var _hook = require("./hook");
17
-
18
- var _diffSequences = _interopRequireDefault(require("diff-sequences"));
19
-
20
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
-
22
- function _objectSpread2(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
23
-
24
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
25
-
26
- // Define language options
27
- const displayName = 'C# xUnit';
28
- exports.displayName = displayName;
29
- let opts = {};
30
- exports.opts = opts;
31
- opts.emitter = _command.default;
32
- opts.hooks = (0, _hook.generateHooks)();
33
- opts.fileExtension = '.cs';
34
- opts.commandPrefixPadding = ' ';
35
- opts.terminatingKeyword = '}';
36
- opts.commentPrefix = '//';
37
- opts.generateMethodDeclaration = generateMethodDeclaration; // Create generators for dynamic string creation of primary entities (e.g., filename, methods, test, and suite)
38
-
39
- function generateTestDeclaration(name) {
40
- return `[Fact]\npublic void ${_sideUtils.codeExport.parsers.capitalize(_sideUtils.codeExport.parsers.sanitizeName(name))}() {`;
41
- }
42
-
43
- function generateSuiteDeclaration() {
44
- return `public class SuiteTests : IDisposable {`;
45
- }
46
-
47
- function generateMethodDeclaration(name) {
48
- return `public void ${_sideUtils.codeExport.parsers.sanitizeName(name)}() \n{`;
49
- }
50
-
51
- function generateNamespace(name) {
52
- return `namespace ${_sideUtils.codeExport.parsers.capitalize(_sideUtils.codeExport.parsers.sanitizeName(name))}\n{\n`;
53
- }
54
-
55
- function generateFilename(name) {
56
- return `${_sideUtils.codeExport.parsers.capitalize(_sideUtils.codeExport.parsers.sanitizeName(name))}Test${opts.fileExtension}`;
57
- } // Emit an individual test, wrapped in a suite (using the test name as the suite name)
58
-
59
-
60
- async function emitTest({
61
- baseUrl,
62
- test,
63
- tests,
64
- project,
65
- enableOriginTracing,
66
- beforeEachOptions
67
- }) {
68
- global.baseUrl = baseUrl;
69
- const testDeclaration = generateTestDeclaration(test.name);
70
- const result = await _sideUtils.codeExport.emit.test(test, tests, _objectSpread2({}, opts, {
71
- testDeclaration,
72
- enableOriginTracing,
73
- project
74
- }));
75
- const suiteName = test.name;
76
- const suiteDeclaration = generateSuiteDeclaration();
77
-
78
- var _suite = await _sideUtils.codeExport.emit.suite(result, tests, _objectSpread2({}, opts, {
79
- suiteDeclaration,
80
- suiteName,
81
- project,
82
- beforeEachOptions
83
- }));
84
-
85
- return {
86
- filename: generateFilename(test.name),
87
- body: _sideUtils.codeExport.emit.orderedSuite(_suite)
88
- };
89
- } // Emit a suite with all of its tests
90
-
91
-
92
- async function emitSuite({
93
- baseUrl,
94
- suite,
95
- tests,
96
- project,
97
- enableOriginTracing,
98
- beforeEachOptions
99
- }) {
100
- global.baseUrl = baseUrl;
101
- const result = await _sideUtils.codeExport.emit.testsFromSuite(tests, suite, opts, {
102
- enableOriginTracing,
103
- generateTestDeclaration,
104
- project
105
- });
106
- const suiteDeclaration = generateSuiteDeclaration();
107
-
108
- var _suite = await _sideUtils.codeExport.emit.suite(result, tests, _objectSpread2({}, opts, {
109
- suiteDeclaration,
110
- suite,
111
- project,
112
- beforeEachOptions
113
- }));
114
-
115
- return {
116
- filename: generateFilename(suite.name),
117
- body: emitOrderedSuite(_suite, suite.name)
118
- };
119
- }
120
-
121
- function emitOrderedSuite(emittedSuite, name) {
122
- let result = '';
123
- result += emittedSuite.headerComment;
124
- result += emittedSuite.dependencies;
125
- result += `${generateNamespace(name)}`;
126
- result += emittedSuite.suiteDeclaration;
127
- result += emittedSuite.variables; //result += emittedSuite.beforeAll
128
-
129
- result += emittedSuite.beforeEach;
130
- result += emittedSuite.afterEach; //result += emittedSuite.afterAll
131
-
132
- result += emittedSuite.methods;
133
-
134
- if (emittedSuite.tests.testDeclaration) {
135
- const test = emittedSuite.tests;
136
- result += test.testDeclaration;
137
- result += test.inEachBegin;
138
- result += test.commands;
139
- result += test.inEachEnd;
140
- result += test.testEnd;
141
- } else {
142
- for (const testName in emittedSuite.tests) {
143
- const test = emittedSuite.tests[testName];
144
- result += test.testDeclaration;
145
- result += test.inEachBegin;
146
- result += test.commands;
147
- result += test.inEachEnd;
148
- result += test.testEnd;
149
- }
150
- }
151
-
152
- result += emittedSuite.suiteEnd;
153
- result += '}'; // terminate namespace
154
-
155
- return result;
156
- }
157
-
158
- var _default2 = {
159
- emit: {
160
- test: emitTest,
161
- suite: emitSuite,
162
- locator: _codeExportCsharpCommons.location.emit
163
- },
164
- register: {
165
- command: _command.default.register,
166
- variable: opts.hooks.declareVariables.register,
167
- dependency: opts.hooks.declareDependencies.register,
168
- beforeAll: opts.hooks.beforeAll.register,
169
- beforeEach: opts.hooks.beforeEach.register,
170
- afterEach: opts.hooks.afterEach.register,
171
- afterAll: opts.hooks.afterAll.register,
172
- inEachBegin: opts.hooks.inEachBegin.register,
173
- inEachEnd: opts.hooks.inEachEnd.register
174
- }
175
- };
176
- exports.default = _default2;
package/dist/location.js DELETED
@@ -1,68 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.emit = emit;
7
- exports.default = void 0;
8
-
9
- var _sideUtils = require("@seleniumhq/side-utils");
10
-
11
- // Licensed to the Software Freedom Conservancy (SFC) under one
12
- // or more contributor license agreements. See the NOTICE file
13
- // distributed with this work for additional information
14
- // regarding copyright ownership. The SFC licenses this file
15
- // to you under the Apache License, Version 2.0 (the
16
- // "License"); you may not use this file except in compliance
17
- // with the License. You may obtain a copy of the License at
18
- //
19
- // http://www.apache.org/licenses/LICENSE-2.0
20
- //
21
- // Unless required by applicable law or agreed to in writing,
22
- // software distributed under the License is distributed on an
23
- // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
24
- // KIND, either express or implied. See the License for the
25
- // specific language governing permissions and limitations
26
- // under the License.
27
- const emitters = {
28
- id: emitId,
29
- name: emitName,
30
- link: emitLink,
31
- linkText: emitLink,
32
- partialLinkText: emitPartialLinkText,
33
- css: emitCss,
34
- xpath: emitXpath
35
- };
36
-
37
- function emit(location) {
38
- return _sideUtils.codeExport.emit.location(location, emitters);
39
- }
40
-
41
- var _default = {
42
- emit
43
- };
44
- exports.default = _default;
45
-
46
- function emitId(selector) {
47
- return Promise.resolve(`By.Id("${selector}")`);
48
- }
49
-
50
- function emitName(selector) {
51
- return Promise.resolve(`By.Name("${selector}")`);
52
- }
53
-
54
- function emitLink(selector) {
55
- return Promise.resolve(`By.LinkText("${selector}")`);
56
- }
57
-
58
- function emitPartialLinkText(selector) {
59
- return Promise.resolve(`By.PartialLinkText("${selector}")`);
60
- }
61
-
62
- function emitCss(selector) {
63
- return Promise.resolve(`By.CssSelector("${selector}")`);
64
- }
65
-
66
- function emitXpath(selector) {
67
- return Promise.resolve(`By.XPath("${selector}")`);
68
- }
package/dist/selection.js DELETED
@@ -1,57 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.emit = emit;
7
- exports.default = void 0;
8
-
9
- var _sideUtils = require("@seleniumhq/side-utils");
10
-
11
- // Licensed to the Software Freedom Conservancy (SFC) under one
12
- // or more contributor license agreements. See the NOTICE file
13
- // distributed with this work for additional information
14
- // regarding copyright ownership. The SFC licenses this file
15
- // to you under the Apache License, Version 2.0 (the
16
- // "License"); you may not use this file except in compliance
17
- // with the License. You may obtain a copy of the License at
18
- //
19
- // http://www.apache.org/licenses/LICENSE-2.0
20
- //
21
- // Unless required by applicable law or agreed to in writing,
22
- // software distributed under the License is distributed on an
23
- // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
24
- // KIND, either express or implied. See the License for the
25
- // specific language governing permissions and limitations
26
- // under the License.
27
- const emitters = {
28
- id: emitId,
29
- value: emitValue,
30
- label: emitLabel,
31
- index: emitIndex
32
- };
33
-
34
- function emit(location) {
35
- return _sideUtils.codeExport.emit.selection(location, emitters);
36
- }
37
-
38
- var _default = {
39
- emit
40
- };
41
- exports.default = _default;
42
-
43
- function emitId(id) {
44
- return Promise.resolve(`By.CssSelector("*[id='${id}']")`);
45
- }
46
-
47
- function emitValue(value) {
48
- return Promise.resolve(`By.CssSelector("*[value='${value}']")`);
49
- }
50
-
51
- function emitLabel(label) {
52
- return Promise.resolve(`By.XPath("//option[. = '${label}']")`);
53
- }
54
-
55
- function emitIndex(index) {
56
- return Promise.resolve(`By.CssSelector("*:nth-child(${index})")`);
57
- }