Skip to content

Commit

Permalink
Merge pull request #35 from softrams/new_step_added
Browse files Browse the repository at this point in the history
New continue at failure step added
  • Loading branch information
mkmurali authored Aug 7, 2023
2 parents 4ada862 + 90c2ed4 commit e57f632
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 16 deletions.
5 changes: 2 additions & 3 deletions lib/_init.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
const taiko = require("taiko");
const path = require("path");
const helpers = require("./_helpers");
const { waitFor } = require("taiko");

const headless = process.env.headless_chrome || 'true';
const browser_for_each_scenario = process.env.browser_for_each_scenario;
Expand Down Expand Up @@ -58,8 +57,8 @@ afterStep(async () => {
afterScenario(async () => {
await gauge.screenshot({ encoding: 'base64' });

if (process.env.sleep_timeout) {
await taiko.waitFor(Number(process.env.sleep_timeout));
if (process.env.sleep_after_scenario) {
await taiko.waitFor(Number(process.env.sleep_after_scenario));
}

if (browser_for_each_scenario === "true" && (!open_browser_after_test || open_browser_after_test === 'false')) {
Expand Down
24 changes: 12 additions & 12 deletions lib/_pageElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,17 +100,17 @@ const getProximitySelectors = async (taiko, element) => {

switch (helperValue) {
case "toLeftOf":
return taiko.toLeftOf(elementValue);
return await taiko.toLeftOf(elementValue);
case "toRightOf":
return taiko.toRightOf(elementValue);
return await taiko.toRightOf(elementValue);
case "above":
return taiko.above(elementValue);
return await taiko.above(elementValue);
case "below":
return taiko.below(elementValue);
return await taiko.below(elementValue);
case "near":
return taiko.near(elementValue);
return await taiko.near(elementValue);
case "within":
return taiko.within(elementValue);
return await taiko.within(elementValue);
default:
break;
}
Expand All @@ -125,7 +125,7 @@ async function getFileContent(path) {
exports.getPageElement = async (taiko, element) => {
const _element = await getHelper(taiko, element);
if (_element !== element) {
return _element;
return await _element;
}

let elementText;
Expand Down Expand Up @@ -157,24 +157,24 @@ exports.getPageElement = async (taiko, element) => {
return await taiko.$(elementLocatorValue);
}

return element;
return await element;
}

exports.checkElementState = async (taiko, element, elementState) => {
const pageElement = await this.getPageElement(taiko, element);
switch (elementState) {
case "exist":
case "exists":
await this.scrollToElementView(taiko, pageElement);
await this.scrollToElementView(taiko, await pageElement);
await taiko.waitFor(async () => (await pageElement.exists()));
break;
case "displayed":
case "visible":
await this.scrollToElementView(taiko, pageElement);
await this.scrollToElementView(taiko, await pageElement);
await taiko.waitFor(pageElement);
break;
case "enabled":
await this.scrollToElementView(taiko, pageElement);
await this.scrollToElementView(taiko, await pageElement);
await taiko.waitFor(async () => !(await pageElement.isDisabled()));
break;
case "not exists":
Expand All @@ -195,7 +195,7 @@ exports.checkElementState = async (taiko, element, elementState) => {
break;
case "not enabled":
case "disabled":
await this.scrollToElementView(taiko, pageElement);
await this.scrollToElementView(taiko, await pageElement);
await taiko.waitFor(async () => (await pageElement.isDisabled()));
break;
default:
Expand Down
6 changes: 6 additions & 0 deletions lib/page_steps_continue_on_failure.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ step(["Verify <element> <elementState>", "Verify <element> is <elementState>"]
await checkElementState(taiko, element, elementState);
});

step(["Verify <element> <elementText> <elementState>", "Verify <element> <elementText> is <elementState>"],
{continueOnFailure: true}, async (element, elementText, elementState) => {
element = element + " with text " + helpers.getValue(elementText);
await checkElementState(taiko, element, elementState);
});

step("Verify <element> text is <elementText>",
{continueOnFailure: true}, async (element, elementText) => {
elementText = helpers.getValue(elementText);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@softrams/gauge-taiko-steps",
"version": "0.1.2",
"version": "0.1.3",
"description": "Implementation of common test steps with Taiko driver for writing tests with Gauge framework",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit e57f632

Please sign in to comment.