@cuppet/core 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,79 +1,79 @@
1
- /**
2
- * @module appiumTesting
3
- */
4
- const config = require('config');
5
-
6
- module.exports = {
7
- /**
8
- * Handles UiSelector case as it requires special prefixing
9
- * @param {string} selector
10
- * @returns {string} - Either the original selector or a UiSelector formatted string
11
- */
12
- prepareSelector: function (selector) {
13
- if (selector.startsWith('.')) {
14
- // If the selector starts with ., treat it as a UiSelector
15
- // For example .text('Example Text') becomes android='new UiSelector().text("Example Text")'
16
- return `android=new UiSelector()${selector}`;
17
- } else {
18
- return selector; // Otherwise, return the selector as is
19
- }
20
- },
21
-
22
- /**
23
- * @param {import('@wdio/globals').driver} driver - The WebDriverIO appium instance.
24
- * @param {string} androidPackage - The name of the Android package.
25
- * @param {string} activity - The name of the Android activity.
26
- * @returns {Promise<void>} - Resolves when the session is reloaded successfully.
27
- * @throws Will throw an error if the element is not found or not clickable.
28
- */
29
- reloadSession: async function (driver, androidPackage, activity) {
30
- const appiumCapabilities = config.get('appiumCapabilities');
31
- const capabilities = {
32
- ...appiumCapabilities,
33
- 'appium:appPackage': androidPackage,
34
- 'appium:appActivity': activity,
35
- };
36
- // Reload the session with the updated capabilities
37
- await driver.reloadSession(capabilities);
38
- },
39
-
40
- /**
41
- * @param {import('@wdio/globals')} driver - The WebDriverIO appium instance.
42
- * @param {string} selector - The selector of the element to click.
43
- * Possible values for selector: https://webdriver.io/docs/selectors/
44
- * - A UiSelector string, e.g. '.text("Example Text")'
45
- * - An ID selector (e.g. 'com.example:id/button1')
46
- * - A class name selector (e.g. 'android.widget.Button')
47
- * - An accessibility ID selector (e.g. '~button1')
48
- * @returns {Promise<void>} - Resolves when the element is clicked successfully.
49
- * @throws Will throw an error if the element is not found or not clickable.
50
- */
51
- clickElement: async function (driver, selector) {
52
- try {
53
- // $ and $$ are not async functions, as Wdio uses lazy loading.
54
- // The actual element is not fetched until an action is performed like .click(), .getText(), .isDisplayed(), etc.
55
- const element = driver.$(selector);
56
- await element.waitForDisplayed({ timeout: 5000 });
57
- await element.click();
58
- } catch (error) {
59
- throw new Error(`Error clicking element with selector ${selector}: ${error}`);
60
- }
61
- },
62
-
63
- /**
64
- * @param {import('@wdio/globals').driver} driver - The WebDriverIO appium instance.
65
- * @param {string} selector - The selector of the element.
66
- * @returns {Promise<void>} - Resolves when the element is scrolled into view successfully.
67
- * @throws Will throw an error if the element is not found.
68
- */
69
- scrollToElement: async function (driver, selector) {
70
- try {
71
- await driver.findElement(
72
- '-android uiautomator',
73
- `new UiScrollable(new UiSelector().scrollable(true)).scrollIntoView(new UiSelector().${selector})`
74
- );
75
- } catch (error) {
76
- throw new Error(`Cannot find element with selector ${selector}: ${error}`);
77
- }
78
- },
79
- };
1
+ /**
2
+ * @module appiumTesting
3
+ */
4
+ const config = require('config');
5
+
6
+ module.exports = {
7
+ /**
8
+ * Handles UiSelector case as it requires special prefixing
9
+ * @param {string} selector
10
+ * @returns {string} - Either the original selector or a UiSelector formatted string
11
+ */
12
+ prepareSelector: function (selector) {
13
+ if (selector.startsWith('.')) {
14
+ // If the selector starts with ., treat it as a UiSelector
15
+ // For example .text('Example Text') becomes android='new UiSelector().text("Example Text")'
16
+ return `android=new UiSelector()${selector}`;
17
+ } else {
18
+ return selector; // Otherwise, return the selector as is
19
+ }
20
+ },
21
+
22
+ /**
23
+ * @param {import('@wdio/globals').driver} driver - The WebDriverIO appium instance.
24
+ * @param {string} androidPackage - The name of the Android package.
25
+ * @param {string} activity - The name of the Android activity.
26
+ * @returns {Promise<void>} - Resolves when the session is reloaded successfully.
27
+ * @throws Will throw an error if the element is not found or not clickable.
28
+ */
29
+ reloadSession: async function (driver, androidPackage, activity) {
30
+ const appiumCapabilities = config.get('appiumCapabilities');
31
+ const capabilities = {
32
+ ...appiumCapabilities,
33
+ 'appium:appPackage': androidPackage,
34
+ 'appium:appActivity': activity,
35
+ };
36
+ // Reload the session with the updated capabilities
37
+ await driver.reloadSession(capabilities);
38
+ },
39
+
40
+ /**
41
+ * @param {import('@wdio/globals')} driver - The WebDriverIO appium instance.
42
+ * @param {string} selector - The selector of the element to click.
43
+ * Possible values for selector: https://webdriver.io/docs/selectors/
44
+ * - A UiSelector string, e.g. '.text("Example Text")'
45
+ * - An ID selector (e.g. 'com.example:id/button1')
46
+ * - A class name selector (e.g. 'android.widget.Button')
47
+ * - An accessibility ID selector (e.g. '~button1')
48
+ * @returns {Promise<void>} - Resolves when the element is clicked successfully.
49
+ * @throws Will throw an error if the element is not found or not clickable.
50
+ */
51
+ clickElement: async function (driver, selector) {
52
+ try {
53
+ // $ and $$ are not async functions, as Wdio uses lazy loading.
54
+ // The actual element is not fetched until an action is performed like .click(), .getText(), .isDisplayed(), etc.
55
+ const element = driver.$(selector);
56
+ await element.waitForDisplayed({ timeout: 5000 });
57
+ await element.click();
58
+ } catch (error) {
59
+ throw new Error(`Error clicking element with selector ${selector}: ${error}`);
60
+ }
61
+ },
62
+
63
+ /**
64
+ * @param {import('@wdio/globals').driver} driver - The WebDriverIO appium instance.
65
+ * @param {string} selector - The selector of the element.
66
+ * @returns {Promise<void>} - Resolves when the element is scrolled into view successfully.
67
+ * @throws Will throw an error if the element is not found.
68
+ */
69
+ scrollToElement: async function (driver, selector) {
70
+ try {
71
+ await driver.findElement(
72
+ '-android uiautomator',
73
+ `new UiScrollable(new UiSelector().scrollable(true)).scrollIntoView(new UiSelector().${selector})`
74
+ );
75
+ } catch (error) {
76
+ throw new Error(`Cannot find element with selector ${selector}: ${error}`);
77
+ }
78
+ },
79
+ };
@@ -1,67 +1,67 @@
1
- const config = require('config');
2
- const backStop = require('backstopjs');
3
- const backStopConfig = require('../backStopData/backStopConfig.json');
4
-
5
- module.exports = {
6
- /**
7
- *
8
- * @returns {Object} - the backstop configuration object
9
- */
10
- backstopConfigPrepare: function () {
11
- let newConfig = backStopConfig;
12
- newConfig.id = process.env.NODE_CONFIG_ENV;
13
- newConfig.viewports[0].width = Number(config.get('viewport.width'));
14
- newConfig.viewports[0].height = Number(config.get('viewport.height'));
15
- newConfig.engineOptions.args = config.get('args');
16
- return newConfig;
17
- },
18
-
19
- /**
20
- *
21
- * @param command
22
- * @param configObject
23
- * @returns {Promise<void>}
24
- */
25
- runBackStop: async function (command, configObject) {
26
- await backStop(command, { config: configObject })
27
- .then(() => {
28
- console.log(`${command} backstop run executed successfully!`);
29
- // test successful
30
- })
31
- .catch((error) => {
32
- throw new Error(error);
33
- });
34
- },
35
-
36
- /**
37
- *
38
- * @param scenarioName
39
- * @param path
40
- * @param testCommand
41
- * @returns {Promise<void>}
42
- */
43
- runBackStopSingleScenario: async function (scenarioName, path, testCommand) {
44
- const newConfig = this.backstopConfigPrepare();
45
- newConfig.scenarios[0].label = scenarioName;
46
- newConfig.scenarios[0].url = path;
47
- await this.runBackStop(testCommand, newConfig);
48
- },
49
- /**
50
- *
51
- * @param pages
52
- * @param testCommand
53
- * @returns {Promise<void>}
54
- */
55
- runBackstopMultiplePages: async function (pages, testCommand) {
56
- const newConfig = this.backstopConfigPrepare();
57
- newConfig.scenarios = [];
58
- pages.forEach((page) => {
59
- newConfig.scenarios.push({
60
- label: page.label,
61
- url: page.url,
62
- // Add other scenario properties as needed...
63
- });
64
- });
65
- await this.runBackStop(testCommand, newConfig);
66
- },
67
- };
1
+ const config = require('config');
2
+ const backStop = require('backstopjs');
3
+ const backStopConfig = require('../backStopData/backStopConfig.json');
4
+
5
+ module.exports = {
6
+ /**
7
+ *
8
+ * @returns {Object} - the backstop configuration object
9
+ */
10
+ backstopConfigPrepare: function () {
11
+ let newConfig = backStopConfig;
12
+ newConfig.id = process.env.NODE_CONFIG_ENV;
13
+ newConfig.viewports[0].width = Number(config.get('viewport.width'));
14
+ newConfig.viewports[0].height = Number(config.get('viewport.height'));
15
+ newConfig.engineOptions.args = config.get('args');
16
+ return newConfig;
17
+ },
18
+
19
+ /**
20
+ *
21
+ * @param command
22
+ * @param configObject
23
+ * @returns {Promise<void>}
24
+ */
25
+ runBackStop: async function (command, configObject) {
26
+ await backStop(command, { config: configObject })
27
+ .then(() => {
28
+ console.log(`${command} backstop run executed successfully!`);
29
+ // test successful
30
+ })
31
+ .catch((error) => {
32
+ throw new Error(error);
33
+ });
34
+ },
35
+
36
+ /**
37
+ *
38
+ * @param scenarioName
39
+ * @param path
40
+ * @param testCommand
41
+ * @returns {Promise<void>}
42
+ */
43
+ runBackStopSingleScenario: async function (scenarioName, path, testCommand) {
44
+ const newConfig = this.backstopConfigPrepare();
45
+ newConfig.scenarios[0].label = scenarioName;
46
+ newConfig.scenarios[0].url = path;
47
+ await this.runBackStop(testCommand, newConfig);
48
+ },
49
+ /**
50
+ *
51
+ * @param pages
52
+ * @param testCommand
53
+ * @returns {Promise<void>}
54
+ */
55
+ runBackstopMultiplePages: async function (pages, testCommand) {
56
+ const newConfig = this.backstopConfigPrepare();
57
+ newConfig.scenarios = [];
58
+ pages.forEach((page) => {
59
+ newConfig.scenarios.push({
60
+ label: page.label,
61
+ url: page.url,
62
+ // Add other scenario properties as needed...
63
+ });
64
+ });
65
+ await this.runBackStop(testCommand, newConfig);
66
+ },
67
+ };
@@ -1,17 +1,17 @@
1
- // Cuppet Core Step Definitions
2
- // This file exports all step definitions for use in consuming projects
3
-
4
- module.exports = {
5
- accessibilitySteps: require('./features/app/stepDefinitions/accessibilitySteps'),
6
- apiSteps: require('./features/app/stepDefinitions/apiSteps'),
7
- appiumSteps: require('./features/app/stepDefinitions/appiumSteps'),
8
- generalSteps: require('./features/app/stepDefinitions/generalSteps'),
9
- helperSteps: require('./features/app/stepDefinitions/helperSteps'),
10
- iframeSteps: require('./features/app/stepDefinitions/iframeSteps'),
11
- ifVisibleSteps: require('./features/app/stepDefinitions/ifVisibleSteps'),
12
- lighthouseSteps: require('./features/app/stepDefinitions/lighthouseSteps'),
13
- pageElements: require('./features/app/stepDefinitions/pageElements'),
14
- pageElementsConfig: require('./features/app/stepDefinitions/pageElementsConfig'),
15
- pageElementsJson: require('./features/app/stepDefinitions/pageElementsJson'),
16
- visualRegressionSteps: require('./features/app/stepDefinitions/visualRegressionSteps')
17
- };
1
+ // Cuppet Core Step Definitions
2
+ // This file exports all step definitions for use in consuming projects
3
+
4
+ module.exports = {
5
+ accessibilitySteps: require('./features/app/stepDefinitions/accessibilitySteps'),
6
+ apiSteps: require('./features/app/stepDefinitions/apiSteps'),
7
+ appiumSteps: require('./features/app/stepDefinitions/appiumSteps'),
8
+ generalSteps: require('./features/app/stepDefinitions/generalSteps'),
9
+ helperSteps: require('./features/app/stepDefinitions/helperSteps'),
10
+ iframeSteps: require('./features/app/stepDefinitions/iframeSteps'),
11
+ ifVisibleSteps: require('./features/app/stepDefinitions/ifVisibleSteps'),
12
+ lighthouseSteps: require('./features/app/stepDefinitions/lighthouseSteps'),
13
+ pageElements: require('./features/app/stepDefinitions/pageElements'),
14
+ pageElementsConfig: require('./features/app/stepDefinitions/pageElementsConfig'),
15
+ pageElementsJson: require('./features/app/stepDefinitions/pageElementsJson'),
16
+ visualRegressionSteps: require('./features/app/stepDefinitions/visualRegressionSteps'),
17
+ };