Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
:rocket: - new feature
:beetle: - bugfix
:x: - deprecation/removal
:pencil: - chore

## [Unreleased]
- :pencil: cleaned up dependencies

## [0.44.0]
- :rocket: added option to take full page screenshot (_config.browser.screenshot.fullPage_)
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ module.exports = {
```

## Playwright traces
@qavajs support capturing playwright traces. https://playwright.dev/docs/next/trace-viewer-intro
@qavajs support capturing playwright traces.
https://playwright.dev/docs/next/trace-viewer-intro

Trace Viewer - https://trace.playwright.dev/

```typescript
Expand Down
2 changes: 1 addition & 1 deletion globals.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Browser, BrowserContext, Page } from 'playwright';
import { Browser, BrowserContext, Page } from '@playwright/test';
import { BrowserManager } from './src/browserManager';

declare global {
Expand Down
81 changes: 40 additions & 41 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"homepage": "https://github.com/qavajs/steps-playwright#readme",
"devDependencies": {
"@cucumber/cucumber": "^10.3.1",
"@qavajs/cli": "^0.34.2",
"@qavajs/cli": "^0.35.0",
"@qavajs/console-formatter": "^0.7.1",
"@qavajs/html-formatter": "^0.15.4",
"@qavajs/memory": "^1.7.0",
Expand All @@ -40,12 +40,11 @@
"electron": "^27.1.3",
"express": "^4.18.2",
"ts-node": "^10.9.2",
"typescript": "^5.3.3",
"typescript": "^5.4.2",
"vitest": "^1.3.1"
},
"dependencies": {
"@playwright/test": "^1.41.2",
"@qavajs/validation": "^0.7.1",
"playwright": "^1.41.2"
"@playwright/test": "^1.42.1",
"@qavajs/validation": "^0.7.1"
}
}
3 changes: 1 addition & 2 deletions src/actions.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { When } from '@cucumber/cucumber';
import { getValue, getElement } from './transformers';
import { po } from '@qavajs/po-playwright';
import { expect } from '@playwright/test';
import { expect, Browser, BrowserContext, Page } from '@playwright/test';
import { parseCoords, parseCoordsAsObject, sleep } from './utils/utils';
import { Browser, BrowserContext, Page } from 'playwright';

declare global {
var browser: Browser;
Expand Down
2 changes: 1 addition & 1 deletion src/browserManager.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { driverProvider } from './driverProvider';
import { Browser, BrowserContext, ElectronApplication, Page } from 'playwright';
import { Browser, BrowserContext, ElectronApplication, Page } from '@playwright/test';

type BrowserDict = {
[key: string]: Browser;
Expand Down
9 changes: 4 additions & 5 deletions src/conditionWait.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Locator } from 'playwright';
import { expect } from '@playwright/test';
import { Locator, expect } from '@playwright/test';
import { throwTimeoutError } from './utils/utils';

export const conditionValidations = {
Expand All @@ -25,19 +24,19 @@ const waits = {
reverse: boolean,
timeout: number,
timeoutMsg: string
) => element.waitFor({state: reverse ? 'detached' : 'attached', timeout}),
) => element.waitFor({ state: reverse ? 'detached' : 'attached', timeout }),
[conditionValidations.VISIBLE]: (
element: Locator,
reverse: boolean,
timeout: number,
timeoutMsg: string
) => element.waitFor({state: reverse ? 'hidden' : 'visible', timeout}),
) => element.waitFor({ state: reverse ? 'hidden' : 'visible', timeout }),
[conditionValidations.INVISIBLE]: (
element: Locator,
reverse: boolean,
timeout: number,
timeoutMsg: string
) => element.waitFor({state: reverse ? 'visible' : 'hidden', timeout}),
) => element.waitFor({ state: reverse ? 'visible' : 'hidden', timeout }),
[conditionValidations.IN_VIEWPORT]: (
element: Locator,
reverse: boolean,
Expand Down
2 changes: 1 addition & 1 deletion src/driverProvider.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { chromium, firefox, webkit, _electron as electron, Browser, BrowserType } from 'playwright';
import { chromium, firefox, webkit, _electron as electron, Browser, BrowserType } from '@playwright/test';
const browsers: any = { chromium, firefox, webkit, electron };

export async function driverProvider(driverConfig: any): Promise<Browser> {
Expand Down
8 changes: 4 additions & 4 deletions src/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
ITestStepHookParameter
} from '@cucumber/cucumber';
import defaultTimeouts from './defaultTimeouts';
import { Browser, BrowserContext, Page } from 'playwright';
import { Browser, BrowserContext, Page } from '@playwright/test';
import { po } from '@qavajs/po-playwright';
import {
saveScreenshotAfterStep,
Expand All @@ -18,7 +18,7 @@ import {
} from './utils/utils';
import { readFile } from 'node:fs/promises';
import { createJSEngine } from './selectorEngines';
import browserManager, {BrowserManager} from './browserManager';
import browserManager, { BrowserManager } from './browserManager';
import tracingManager from './utils/tracingManager';

declare global {
Expand All @@ -34,7 +34,7 @@ BeforeAll(async function () {
await createJSEngine();
});

Before({name: 'Init'}, async function () {
Before({ name: 'Init' }, async function () {
const driverConfig = config.browser ?? config.driver;
driverConfig.isElectron = driverConfig.capabilities.browserName === 'electron';
driverConfig.timeout = {
Expand Down Expand Up @@ -75,7 +75,7 @@ AfterStep(async function (step: ITestStepHookParameter) {
}
});

After({name: 'Teardown'}, async function (scenario: ITestCaseHookParameter) {
After({ name: 'Teardown' }, async function (scenario: ITestCaseHookParameter) {
await tracingManager.stop(config.driverConfig, this, scenario);
await browserManager.teardown({
reuseSession: config.driverConfig.reuseSession,
Expand Down
2 changes: 1 addition & 1 deletion src/selectorEngines.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { selectors } from 'playwright';
import { selectors } from '@playwright/test';

export async function createJSEngine() {
const jsEngine = () => ({
Expand Down
4 changes: 2 additions & 2 deletions src/transformers.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { conditionWait, conditionWaitExtractRegexp } from './conditionWait';
import { po } from '@qavajs/po-playwright';
import memory from '@qavajs/memory';
import { Locator } from 'playwright';
import { Locator } from '@playwright/test';

export function getValue(alias: string): any {
return memory.getValue(alias)
Expand All @@ -14,7 +14,7 @@ export async function getElement(alias: string): Promise<Locator> {
export function getConditionWait(condition: string): Function {
const match = condition.match(conditionWaitExtractRegexp) as RegExpMatchArray;
if (!match) throw new Error(`${condition} wait is not implemented`);
const [ _, reverse, validation ] = match;
const [_, reverse, validation] = match;
return async function (element: Locator, timeout: number) {
await conditionWait(element, validation, timeout, Boolean(reverse))
}
Expand Down
2 changes: 1 addition & 1 deletion src/validations.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Then } from '@cucumber/cucumber';
import { getValue, getElement, getConditionWait } from './transformers';
import { getValidation, getPollValidation } from '@qavajs/validation';
import { Locator } from 'playwright';
import { Locator } from '@playwright/test';

/**
* Verify element condition
Expand Down
17 changes: 8 additions & 9 deletions test-e2e/step-definitions/index.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,31 @@
import { Then } from '@cucumber/cucumber';
import memory from '@qavajs/memory';
import { Page } from 'playwright';
import { expect } from 'chai';
import { Page, expect } from '@playwright/test';

declare global {
var page: Page;
}

Then('I expect {string} memory value to be equal {string}', async function(actual, expected) {
Then('I expect {string} memory value to be equal {string}', async function (actual, expected) {
const actualValue = memory.getValue(actual);
const expectedValue = memory.getValue(expected);
expect(expectedValue).to.eql(actualValue);
expect(expectedValue).toEqual(actualValue);
});

Then('I expect {string} memory value to contain {string}', async function(actual, expected) {
Then('I expect {string} memory value to contain {string}', async function (actual, expected) {
const actualValue = memory.getValue(actual);
const expectedValue = memory.getValue(expected);
expect(actualValue).to.contain(expectedValue);
expect(actualValue).toContain(expectedValue);
});

Then('I expect {string} memory value to have type {string}', async function(actual, expected) {
Then('I expect {string} memory value to have type {string}', async function (actual, expected) {
const actualValue = memory.getValue(actual);
const expectedValue = memory.getValue(expected);
expect(actualValue).to.be.a(expectedValue);
expect(typeof actualValue === expectedValue).toBeTruthy();
});

Then('I expect viewport size to equal {string}', async function (expectedSize) {
const expectedValue = await memory.getValue(expectedSize);
const actualValue = page.viewportSize();
expect(actualValue).to.deep.equal(expectedValue, 'Viewport size do not match');
expect(actualValue).toEqual(expectedValue);
})
Loading