Skip to content

Commit 07b5aeb

Browse files
added logs to hooks and validation steps (#30)
1 parent 87e4be3 commit 07b5aeb

File tree

7 files changed

+89
-82
lines changed

7 files changed

+89
-82
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 0.0.15
2+
- :rocket: added validation logs
3+
14
## 0.0.14
25
- :rocket: added custom timeout parameter
36

package-lock.json

Lines changed: 49 additions & 65 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@qavajs/steps-playwright",
3-
"version": "0.0.14",
3+
"version": "0.0.15",
44
"description": "steps to interact with playwright",
55
"main": "./index.js",
66
"scripts": {
@@ -22,8 +22,8 @@
2222
},
2323
"homepage": "https://github.com/qavajs/steps-playwright#readme",
2424
"devDependencies": {
25-
"@cucumber/cucumber": "^8.11.1",
26-
"@qavajs/cli": "^0.0.18",
25+
"@cucumber/cucumber": "^9.0.0",
26+
"@qavajs/cli": "^0.0.19",
2727
"@qavajs/memory": "^1.2.0",
2828
"@qavajs/webstorm-adapter": "^8.0.0",
2929
"@qavajs/xunit-formatter": "^0.0.3",
@@ -36,8 +36,8 @@
3636
"@qavajs/po-playwright": "^0.0.7"
3737
},
3838
"dependencies": {
39-
"@playwright/test": "^1.31.1",
39+
"@playwright/test": "^1.31.2",
4040
"@qavajs/validation": "^0.0.3",
41-
"playwright": "^1.31.1"
41+
"playwright": "^1.31.2"
4242
}
4343
}

src/hooks.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ Before(async function () {
3333
global.driver = global.browser;
3434
po.init(page, { timeout: config.driverConfig.timeout.present });
3535
po.register(config.pageObject);
36+
this.log(`browser instance started:\n${JSON.stringify(config.driverConfig, null, 2)}`);
3637
});
3738

3839
BeforeStep(async function () {
@@ -66,5 +67,6 @@ After(async function (scenario) {
6667
}
6768
if (global.browser) {
6869
await browser.close();
70+
this.log('browser instance closed');
6971
}
7072
});

src/validations.ts

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { Then } from '@cucumber/cucumber';
2-
import { getValue, getElement, getConditionWait } from './transformers';
3-
import { getValidation } from '@qavajs/validation';
1+
import {Then} from '@cucumber/cucumber';
2+
import {getValue, getElement, getConditionWait} from './transformers';
3+
import {getValidation} from '@qavajs/validation';
44

55
/**
66
* Verify element condition
@@ -31,6 +31,8 @@ Then(
3131
const element = await getElement(alias);
3232
const validation = getValidation(validationType);
3333
const elementText: string = await element.innerText();
34+
this.log(`AR: ${elementText}`);
35+
this.log(`ER: ${expectedValue}`);
3436
validation(elementText, expectedValue);
3537
}
3638
);
@@ -52,6 +54,8 @@ Then(
5254
const element = await getElement(alias);
5355
const validation = getValidation(validationType);
5456
const actualValue = await element.evaluate((node: any, propertyName: string) => node[propertyName], propertyName);
57+
this.log(`AR: ${actualValue}`);
58+
this.log(`ER: ${expectedValue}`);
5559
validation(actualValue, expectedValue);
5660
}
5761
);
@@ -72,6 +76,8 @@ Then(
7276
const element = await getElement(alias);
7377
const validation = getValidation(validationType);
7478
const actualValue = await element.getAttribute(attributeName);
79+
this.log(`AR: ${actualValue}`);
80+
this.log(`ER: ${expectedValue}`);
7581
validation(actualValue, expectedValue);
7682
}
7783
);
@@ -89,6 +95,8 @@ Then(
8995
const validation = getValidation(validationType);
9096
const expectedUrl = await getValue(expected);
9197
const actualUrl = page.url();
98+
this.log(`AR: ${actualUrl}`);
99+
this.log(`ER: ${expectedUrl}`);
92100
validation(actualUrl, expectedUrl);
93101
}
94102
);
@@ -108,7 +116,10 @@ Then(
108116
const expectedValue = await getValue(value);
109117
const collection = await getElement(alias);
110118
const validation = getValidation(validationType);
111-
validation(await collection.count(), expectedValue);
119+
const actualCount = await collection.count();
120+
this.log(`AR: ${actualCount}`);
121+
this.log(`ER: ${expectedValue}`);
122+
validation(actualCount, expectedValue);
112123
}
113124
);
114125

@@ -124,6 +135,8 @@ Then(
124135
const validation = getValidation(validationType);
125136
const expectedTitle = await getValue(expected);
126137
const actualTitle = await page.title();
138+
this.log(`AR: ${actualTitle}`);
139+
this.log(`ER: ${expectedTitle}`);
127140
validation(actualTitle, expectedTitle);
128141
}
129142
);
@@ -211,6 +224,8 @@ Then(
211224
(node: Element, propertyName: string) => getComputedStyle(node).getPropertyValue(propertyName),
212225
propertyName
213226
);
227+
this.log(`AR: ${actualValue}`);
228+
this.log(`ER: ${expectedValue}`);
214229
validation(actualValue, expectedValue);
215230
}
216231
);
@@ -222,10 +237,13 @@ Then(
222237
* @example I expect text of alert does not contain 'coffee'
223238
*/
224239
Then('I expect text of alert {playwrightValidation} {string}', async function (validationType: string, expectedValue: string) {
225-
const alertText = await new Promise<string>(resolve => page.once('dialog', async (dialog) => {
226-
resolve(dialog.message());
227-
}));
228-
const validation = getValidation(validationType);
229-
validation(alertText, expectedValue);
240+
const alertText = await new Promise<string>(resolve => page.once('dialog', async (dialog) => {
241+
resolve(dialog.message());
242+
}));
243+
const expected = await getValue(expectedValue);
244+
const validation = getValidation(validationType);
245+
this.log(`AR: ${alertText}`);
246+
this.log(`ER: ${expected}`);
247+
validation(alertText, expectedValue);
230248
}
231249
);

0 commit comments

Comments
 (0)