webship-js 1.0.43 → 1.0.45
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/.eslintrc.json +0 -0
- package/CNAME +0 -0
- package/dist/nightwatch.conf.dev.js +93 -0
- package/examples/about-us.html +0 -0
- package/examples/contact-us.html +0 -0
- package/examples/index.html +0 -0
- package/examples/test--then--i-should--see-text-in-element.html +0 -0
- package/examples/test--then--i-should--see-text-matching-pattern.html +0 -0
- package/examples/test--then--the-checkbox-checked.html +0 -0
- package/examples/test--then--the-element-should_not-contain-cssproperty.html +0 -0
- package/examples/test--then--the-link-should-contain.html +0 -0
- package/examples/test--when--i-attach-file-to-feild.html +0 -0
- package/examples/test--when--i-check-uncheck-checkbox.html +0 -0
- package/examples/test--when--i-click-link.html +0 -0
- package/examples/test--when--i-press-button.html +0 -0
- package/examples/test--when--i-reload-page.html +0 -0
- package/examples/test--when--i-scroll-functionality.html +0 -0
- package/examples/test--when--i-scroll-left-right-functionality.html +0 -0
- package/examples/test--when--i-select-option-from-dropdownlist.html +0 -0
- package/examples/test--when-i-wait-max-of-time.html +0 -0
- package/examples/test--when-i-wait-page-until-is-loaded.html +0 -0
- package/examples/test--when-i-wait-specific-time.html +0 -0
- package/generate-reports.js +0 -0
- package/nightwatch.conf.js +1 -1
- package/package.json +1 -1
- package/tests/assets/webshipco.png +0 -0
- package/tests/features/api-step-definitions-individual.feature +185 -0
- package/tests/features/complete-api-testing-examples.feature +205 -0
- package/tests/features/test--given--i-am-on-homepage.feature +2 -2
- package/tests/features/test--then--i-should--not--see-text-in-element.feature +2 -2
- package/tests/features/test--then--i-should--see-text-in-element-by-attr.feature +2 -2
- package/tests/features/test--then--i-should--see-text-in-element.feature +2 -2
- package/tests/features/test--then--i-should--see-text-matching-pattern-in-element.feature +2 -2
- package/tests/features/test--then--i-should--see-text-matching-pattern.feature +2 -2
- package/tests/features/test--then--i-should-be-on-page.feature +2 -2
- package/tests/features/test--then--i-should-be-on-the-homepage.feature +2 -2
- package/tests/features/test--then--i-should-not-see-an-element-by-attr.feature +2 -2
- package/tests/features/test--then--i-should-not-see-an-element.feature +2 -2
- package/tests/features/test--then--i-should-see-an-element-by-attr.feature +2 -2
- package/tests/features/test--then--i-should-see-an-element.feature +2 -2
- package/tests/features/test--then--i-should-see-text-in-table-row.feature +2 -2
- package/tests/features/test--then--the-checkbox-is-checked.feature +2 -2
- package/tests/features/test--then--the-checkbox-should-be-checked.feature +2 -2
- package/tests/features/test--then--the-element-should-contain-cssproperty.feature +2 -2
- package/tests/features/test--then--the-element-should-not-contain-cssproperty.feature +2 -2
- package/tests/features/test--then--the-field-should-contain-value.feature +2 -2
- package/tests/features/test--then--the-response-should-contain.feature +2 -2
- package/tests/features/test--then--the-response-status-code-should-be.feature +2 -2
- package/tests/features/test--then--the-url-should-match.feature +2 -2
- package/tests/features/test--then-the-link-should-contain-by-attribute.feature +2 -2
- package/tests/features/test--then-the-link-should-contain.feature +2 -2
- package/tests/features/test--when--i-attach-file-to-feild.feature +2 -2
- package/tests/features/test--when--i-check-checkbox.feature +2 -2
- package/tests/features/test--when--i-click-link-by-attribute.feature +2 -2
- package/tests/features/test--when--i-click-link.feature +2 -2
- package/tests/features/test--when--i-click-text-in-table-row.feature +21 -21
- package/tests/features/test--when--i-fill-in-by-attr.feature +2 -2
- package/tests/features/test--when--i-fill-in-table-by-attr.feature +2 -2
- package/tests/features/test--when--i-fill-in.feature +2 -2
- package/tests/features/test--when--i-go-to-homepage.feature +3 -3
- package/tests/features/test--when--i-move-forward-backward-one-page.feature +2 -2
- package/tests/features/test--when--i-press-button-by-attribute.feature +2 -2
- package/tests/features/test--when--i-press-button.feature +2 -2
- package/tests/features/test--when--i-reload-page.feature +2 -2
- package/tests/features/test--when--i-scroll-left-right.feature +2 -2
- package/tests/features/test--when--i-scroll.feature +2 -2
- package/tests/features/test--when--i-select-option-from-dropdownlist.feature +2 -2
- package/tests/features/test--when--i-wait-page-is-loaded.feature +2 -2
- package/tests/features/test--when--i-wait-time.feature +2 -2
- package/tests/step-definitions/webship-api.js +547 -0
- package/tests/step-definitions/webship.js +71 -62
|
@@ -14,8 +14,8 @@ const path = require('path');
|
|
|
14
14
|
* @param {string} key
|
|
15
15
|
*/
|
|
16
16
|
function safePause(key) {
|
|
17
|
-
const time = (global.browser
|
|
18
|
-
if (time > 0 && global.browser
|
|
17
|
+
const time = (global.browser && global.browser.globals && global.browser.globals.minimum_wait_time && global.browser.globals.minimum_wait_time[key]) || 0;
|
|
18
|
+
if (time > 0 && global.browser && global.browser.pause) {
|
|
19
19
|
global.browser.pause(time);
|
|
20
20
|
}
|
|
21
21
|
}
|
|
@@ -265,71 +265,80 @@ When(/^(I |we )*click "([^"]*)?" by( its)*( "([^"]*)?")* (attribute|attr)$/, fun
|
|
|
265
265
|
*/
|
|
266
266
|
When(/^(I |we )*click "([^"]*)?" in( the)* "([^"]*)?" row$/, function (pronounCase, clickText, theCase, rowIdentifier) {
|
|
267
267
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
268
|
+
return browser.execute(function(rowId, targetText) {
|
|
269
|
+
// Find all tables on the page
|
|
270
|
+
const tables = document.querySelectorAll('table');
|
|
271
|
+
if (tables.length === 0) {
|
|
271
272
|
throw new Error('No tables found on the page');
|
|
272
273
|
}
|
|
273
274
|
|
|
274
275
|
// Search through each table for the row containing the identifier
|
|
275
|
-
let
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
if (rowText.value && rowText.value.includes(rowIdentifier)) {
|
|
290
|
-
|
|
291
|
-
// Found the correct row, now look for the clickable text within this row
|
|
292
|
-
browser.elements('css selector', '*', row, function (cellElements) {
|
|
293
|
-
cellElements.value.forEach(function (element) {
|
|
294
|
-
if (foundElement) return; // Skip if already found
|
|
295
|
-
|
|
296
|
-
browser.getText(element, function (elementText) {
|
|
297
|
-
if (elementText.value && elementText.value.trim() === clickText) {
|
|
298
|
-
// Found the target text, click it
|
|
299
|
-
browser.click(element);
|
|
300
|
-
foundElement = true;
|
|
301
|
-
return;
|
|
302
|
-
}
|
|
303
|
-
});
|
|
304
|
-
|
|
305
|
-
// Also check if element is a link or button with the text
|
|
306
|
-
browser.getAttribute(element, 'tagName', function (tagName) {
|
|
307
|
-
if (foundElement) return;
|
|
308
|
-
|
|
309
|
-
if (tagName.value && (tagName.value.toLowerCase() === 'a' || tagName.value.toLowerCase() === 'button')) {
|
|
310
|
-
browser.getText(element, function (linkText) {
|
|
311
|
-
if (linkText.value && linkText.value.trim() === clickText) {
|
|
312
|
-
browser.click(element);
|
|
313
|
-
foundElement = true;
|
|
314
|
-
return;
|
|
315
|
-
}
|
|
316
|
-
});
|
|
317
|
-
}
|
|
318
|
-
});
|
|
319
|
-
});
|
|
320
|
-
});
|
|
276
|
+
for (let table of tables) {
|
|
277
|
+
const rows = table.querySelectorAll('tr');
|
|
278
|
+
for (let row of rows) {
|
|
279
|
+
const rowText = row.textContent || row.innerText;
|
|
280
|
+
if (rowText.includes(rowId)) {
|
|
281
|
+
// Found the correct row, now look for clickable elements with the target text
|
|
282
|
+
|
|
283
|
+
// First, try to find exact text matches in clickable elements
|
|
284
|
+
const clickableElements = row.querySelectorAll('a, button, [onclick], [role="button"], .btn, input[type="submit"], input[type="button"]');
|
|
285
|
+
for (let element of clickableElements) {
|
|
286
|
+
const elementText = (element.textContent || element.innerText || element.value || '').trim();
|
|
287
|
+
if (elementText === targetText) {
|
|
288
|
+
element.click();
|
|
289
|
+
return { success: true, element: element.tagName };
|
|
321
290
|
}
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
// If not found in obvious clickable elements, search all elements
|
|
294
|
+
const allElements = row.querySelectorAll('*');
|
|
295
|
+
for (let element of allElements) {
|
|
296
|
+
const elementText = (element.textContent || element.innerText || '').trim();
|
|
297
|
+
if (elementText === targetText) {
|
|
298
|
+
// Check if element or parent is clickable
|
|
299
|
+
let clickableParent = element;
|
|
300
|
+
while (clickableParent && clickableParent !== row) {
|
|
301
|
+
if (clickableParent.tagName === 'A' ||
|
|
302
|
+
clickableParent.tagName === 'BUTTON' ||
|
|
303
|
+
clickableParent.onclick ||
|
|
304
|
+
clickableParent.getAttribute('role') === 'button' ||
|
|
305
|
+
clickableParent.classList.contains('btn') ||
|
|
306
|
+
clickableParent.style.cursor === 'pointer') {
|
|
307
|
+
clickableParent.click();
|
|
308
|
+
return { success: true, element: clickableParent.tagName };
|
|
309
|
+
}
|
|
310
|
+
clickableParent = clickableParent.parentElement;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
// If no clickable parent found, try clicking the element itself
|
|
314
|
+
try {
|
|
315
|
+
element.click();
|
|
316
|
+
return { success: true, element: element.tagName };
|
|
317
|
+
} catch (e) {
|
|
318
|
+
// Continue searching if click failed
|
|
319
|
+
continue;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
// Row found but target text not clickable
|
|
325
|
+
return {
|
|
326
|
+
success: false,
|
|
327
|
+
error: `Found row containing "${rowId}" but could not find clickable "${targetText}" within it. Row contains: ${rowText.substring(0, 200)}...`
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
// Row not found
|
|
334
|
+
return {
|
|
335
|
+
success: false,
|
|
336
|
+
error: `Could not find row containing "${rowId}". Available rows: ${Array.from(document.querySelectorAll('table tr')).map(r => (r.textContent || '').substring(0, 50)).join(', ')}`
|
|
337
|
+
};
|
|
338
|
+
|
|
339
|
+
}, [rowIdentifier, clickText], function(result) {
|
|
340
|
+
if (!result.value.success) {
|
|
341
|
+
throw new Error(result.value.error || `Could not find "${clickText}" in the "${rowIdentifier}" row. Please verify the table structure and text content.`);
|
|
333
342
|
}
|
|
334
343
|
});
|
|
335
344
|
});
|