@seleniumhq/code-export-python-pytest 3.17.2 → 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.
package/dist/hook.js DELETED
@@ -1,179 +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 specific language governing permissions and limitations
24
- // under the License.
25
- const emitters = {
26
- afterAll,
27
- afterEach,
28
- beforeAll,
29
- beforeEach,
30
- declareDependencies,
31
- declareMethods: empty,
32
- declareVariables: empty,
33
- inEachBegin: empty,
34
- inEachEnd: empty
35
- };
36
-
37
- function generate(hookName) {
38
- return new _sideUtils.codeExport.hook(emitters[hookName]());
39
- }
40
-
41
- function generateHooks() {
42
- let result = {};
43
- Object.keys(emitters).forEach(hookName => {
44
- result[hookName] = generate(hookName);
45
- });
46
- return result;
47
- }
48
-
49
- function afterAll() {
50
- const params = {
51
- startingSyntax: {
52
- commands: [{
53
- level: 0,
54
- statement: 'def teardown_class(cls):'
55
- }]
56
- },
57
- endingSyntax: {
58
- commands: [{
59
- level: 0,
60
- statement: ''
61
- }]
62
- },
63
- registrationLevel: 1
64
- };
65
- return params;
66
- }
67
-
68
- function afterEach() {
69
- const params = {
70
- startingSyntax: {
71
- commands: [{
72
- level: 0,
73
- statement: 'def teardown_method(self, method):'
74
- }, {
75
- level: 1,
76
- statement: 'self.driver.quit()'
77
- }]
78
- },
79
- endingSyntax: {
80
- commands: [{
81
- level: 0,
82
- statement: ''
83
- }]
84
- }
85
- };
86
- return params;
87
- }
88
-
89
- function beforeAll() {
90
- const params = {
91
- startingSyntax: {
92
- commands: [{
93
- level: 0,
94
- statement: 'def setup_class(cls):'
95
- }]
96
- },
97
- endingSyntax: {
98
- commands: [{
99
- level: 0,
100
- statement: ''
101
- }]
102
- },
103
- registrationLevel: 1
104
- };
105
- return params;
106
- }
107
-
108
- function beforeEach() {
109
- const params = {
110
- startingSyntax: ({
111
- browserName,
112
- gridUrl
113
- } = {}) => ({
114
- commands: [{
115
- level: 0,
116
- statement: 'def setup_method(self, method):'
117
- }, {
118
- level: 1,
119
- statement: gridUrl ? `self.driver = webdriver.Remote(command_executor='${gridUrl}', desired_capabilities=DesiredCapabilities.${browserName ? browserName.toUpperCase() : 'CHROME'})` : `self.driver = webdriver.${browserName ? browserName : 'Chrome'}()`
120
- }, {
121
- level: 1,
122
- statement: 'self.vars = {}'
123
- }]
124
- }),
125
- endingSyntax: {
126
- commands: [{
127
- level: 0,
128
- statement: ''
129
- }]
130
- }
131
- };
132
- return params;
133
- }
134
-
135
- function declareDependencies() {
136
- const params = {
137
- startingSyntax: {
138
- commands: [{
139
- level: 0,
140
- statement: 'import pytest'
141
- }, {
142
- level: 0,
143
- statement: 'import time'
144
- }, {
145
- level: 0,
146
- statement: 'import json'
147
- }, {
148
- level: 0,
149
- statement: 'from selenium import webdriver'
150
- }, {
151
- level: 0,
152
- statement: 'from selenium.webdriver.common.by import By'
153
- }, {
154
- level: 0,
155
- statement: 'from selenium.webdriver.common.action_chains import ActionChains'
156
- }, {
157
- level: 0,
158
- statement: 'from selenium.webdriver.support import expected_conditions'
159
- }, {
160
- level: 0,
161
- statement: 'from selenium.webdriver.support.wait import WebDriverWait'
162
- }, {
163
- level: 0,
164
- statement: 'from selenium.webdriver.common.keys import Keys'
165
- }, {
166
- level: 0,
167
- statement: 'from selenium.webdriver.common.desired_capabilities import DesiredCapabilities'
168
- }, {
169
- level: 0,
170
- statement: ''
171
- }]
172
- }
173
- };
174
- return params;
175
- }
176
-
177
- function empty() {
178
- return {};
179
- }
package/dist/index.js DELETED
@@ -1,138 +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 _location = _interopRequireDefault(require("./location"));
15
-
16
- var _hook = require("./hook");
17
-
18
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
-
20
- 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; }
21
-
22
- 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; }
23
-
24
- // Define language options
25
- const displayName = 'Python pytest';
26
- exports.displayName = displayName;
27
- let opts = {};
28
- exports.opts = opts;
29
- opts.emitter = _command.default;
30
- opts.hooks = (0, _hook.generateHooks)();
31
- opts.fileExtension = '.py';
32
- opts.commandPrefixPadding = ' ';
33
- opts.terminatingKeyword = '';
34
- opts.commentPrefix = '#';
35
- opts.generateMethodDeclaration = generateMethodDeclaration; // Create generators for dynamic string creation of primary entities (e.g., filename, methods, test, and suite)
36
-
37
- function generateTestDeclaration(name) {
38
- return `def test_${_sideUtils.codeExport.parsers.uncapitalize(_sideUtils.codeExport.parsers.sanitizeName(name))}(self):`;
39
- }
40
-
41
- function generateMethodDeclaration(name) {
42
- return `def ${_sideUtils.codeExport.parsers.uncapitalize(_sideUtils.codeExport.parsers.sanitizeName(name))}(self):`;
43
- }
44
-
45
- function generateSuiteDeclaration(name) {
46
- return `class Test${_sideUtils.codeExport.parsers.capitalize(_sideUtils.codeExport.parsers.sanitizeName(name))}():`;
47
- }
48
-
49
- function generateFilename(name) {
50
- return `test_${_sideUtils.codeExport.parsers.uncapitalize(_sideUtils.codeExport.parsers.sanitizeName(name))}${opts.fileExtension}`;
51
- } // Emit an individual test, wrapped in a suite (using the test name as the suite name)
52
-
53
-
54
- async function emitTest({
55
- baseUrl,
56
- test,
57
- tests,
58
- project,
59
- enableOriginTracing,
60
- beforeEachOptions,
61
- enableDescriptionAsComment
62
- }) {
63
- global.baseUrl = baseUrl;
64
- const testDeclaration = generateTestDeclaration(test.name);
65
- const result = await _sideUtils.codeExport.emit.test(test, tests, _objectSpread2({}, opts, {
66
- testDeclaration,
67
- enableOriginTracing,
68
- enableDescriptionAsComment,
69
- project
70
- }));
71
- const suiteName = test.name;
72
- const suiteDeclaration = generateSuiteDeclaration(suiteName);
73
-
74
- const _suite = await _sideUtils.codeExport.emit.suite(result, tests, _objectSpread2({}, opts, {
75
- suiteDeclaration,
76
- suiteName,
77
- project,
78
- beforeEachOptions
79
- }));
80
-
81
- return {
82
- filename: generateFilename(test.name),
83
- body: _sideUtils.codeExport.emit.orderedSuite(_suite)
84
- };
85
- } // Emit a suite with all of its tests
86
-
87
-
88
- async function emitSuite({
89
- baseUrl,
90
- suite,
91
- tests,
92
- project,
93
- enableOriginTracing,
94
- beforeEachOptions,
95
- enableDescriptionAsComment
96
- }) {
97
- global.baseUrl = baseUrl;
98
- const result = await _sideUtils.codeExport.emit.testsFromSuite(tests, suite, opts, {
99
- enableOriginTracing,
100
- enableDescriptionAsComment,
101
- generateTestDeclaration,
102
- project
103
- });
104
- const suiteDeclaration = generateSuiteDeclaration(suite.name);
105
-
106
- const _suite = await _sideUtils.codeExport.emit.suite(result, tests, _objectSpread2({}, opts, {
107
- suiteDeclaration,
108
- suite,
109
- project,
110
- beforeEachOptions
111
- }));
112
-
113
- return {
114
- filename: generateFilename(suite.name),
115
- body: _sideUtils.codeExport.emit.orderedSuite(_suite)
116
- };
117
- }
118
-
119
- var _default = {
120
- emit: {
121
- test: emitTest,
122
- suite: emitSuite,
123
- locator: _location.default.emit,
124
- command: _command.default.emit
125
- },
126
- register: {
127
- command: _command.default.register,
128
- variable: opts.hooks.declareVariables.register,
129
- dependency: opts.hooks.declareDependencies.register,
130
- beforeAll: opts.hooks.beforeAll.register,
131
- beforeEach: opts.hooks.beforeEach.register,
132
- afterEach: opts.hooks.afterEach.register,
133
- afterAll: opts.hooks.afterAll.register,
134
- inEachBegin: opts.hooks.inEachBegin.register,
135
- inEachEnd: opts.hooks.inEachEnd.register
136
- }
137
- };
138
- exports.default = _default;
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.LINK_TEXT, "${selector}"`);
56
- }
57
-
58
- function emitPartialLinkText(selector) {
59
- return Promise.resolve(`By.PARTIAL_LINK_TEXT, "${selector}"`);
60
- }
61
-
62
- function emitCss(selector) {
63
- return Promise.resolve(`By.CSS_SELECTOR, "${selector}"`);
64
- }
65
-
66
- function emitXpath(selector) {
67
- return Promise.resolve(`By.XPATH, "${selector}"`);
68
- }
package/dist/selection.js DELETED
@@ -1,61 +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.CSS_SELECTOR, "*[id='${id}']"`);
45
- }
46
-
47
- function emitValue(value) {
48
- return Promise.resolve(`By.CSS_SELECTOR, "*[value='${value}']"`);
49
- }
50
-
51
- function emitLabel(label) {
52
- if (label.startsWith('self.vars[')) {
53
- return Promise.resolve(`By.XPATH, "//option[. = '{}']".format(${label})`);
54
- }
55
-
56
- return Promise.resolve(`By.XPATH, "//option[. = '${label}']"`);
57
- }
58
-
59
- function emitIndex(index) {
60
- return Promise.resolve(`By.CSS_SELECTOR, "*:nth-child(${index})"`);
61
- }