2.7.0 โ€ข Published 5 months ago

@qavajs/steps-playwright v2.7.0

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

npm version

@qavajs/steps-playwright

@qavajs/steps-playwright provides a comprehensive set of pre-built step definitions for qavajs, powered by Playwright. It enables easy and efficient browser automation in a behavior-driven development (BDD) style using Cucumber syntax.

Features

  • โœ… Predefined steps for web automation using Playwright
  • ๐Ÿ”„ Seamless integration with @qavajs/core
  • ๐Ÿงฉ Support for dynamic locators and parameters
  • ๐Ÿงช Built-in assertions and synchronization steps
  • ๐Ÿ”ง Easily extendable for custom needs

Installation

npm install @qavajs/steps-playwright

Configuration

import App from './page_object'
export default {
    require: [
        'node_modules/@qavajs/steps-playwright/index.js'
    ],
    browser: {
        timeout: {
            present: 10000,
            visible: 20000,
            page: 10000,
            value: 5000, // expect value timeout
            valueInterval: 500, // expect value interval
            pageRefreshInterval: 2000 // refresh page for _I refresh page..._ steps
        },
        capabilities: {
            browserName: 'chromium',
            headless: true
        }
    },
    pageObject: new App()
}

Context variables

@qavajs/steps-playwright exposes following to step context

variabletypedescription
this.playwright.browserBrowser \| ElectronApplicationbrowser instance
this.playwright.driverBrowser \| ElectronApplicationbrowser instance (alias for browser)
this.playwright.contextBrowserContextcurrent browser context
this.playwright.pagePagecurrent context page

Connect to playwright server

In order to connect to playwright server pass wsEndpoint property in capabilities object

export default {
    browser: {
        capabilities: {
            browserName: 'chromium',
            wsEndpoint: 'ws://127.0.0.1:60291/2bd48ce272de2b543e4c8c533f664b83'
        }
    },
}

Connect to cdp endpoint

In order to connect to CDP endpoint pass cdpEndpoint property in capabilities object

export default {
    browser: {
        capabilities: {
            browserName: 'chromium',
            cdpEndpoint: 'http://localhost:9222/'
        }
    },
}

Screenshot strategy

@qavajs/steps-playwright has build-in capability to take screenshot on particular event. If you need to add screenshot to your report add screenshot.event property to profile config. Supported events:

  • onFail
  • beforeStep
  • afterStep
export default {
    browser: {
        screenshot: {
            event: ['onFail'], //event to take screenshot
            fullPage: true // option to take full page screenshot (default false)
        }
    }
}

Playwright traces

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

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

export default {
    //...
    browser: {
        trace: {
            event: ['onFail'], // Events to save trace. Possible value onFail or afterScenario 
            dir: 'dirToStoreTraces', // Dir to store traces. Default - traces/
            attach: true, // Whether trace need to be attached to cucumber report. Default - false
            screenshots: true, // Whether to capture screenshots during tracing. Screenshots are used to build a timeline preview. Default - true
            snapshots: true, // Whether to capture DOM and network activity
        }
    }
}

Video

export default {
    //...
    browser: {
        video: {
            event: ['onFail'], // Events to save video. Possible value onFail or afterScenario 
            dir: 'dirToStoreVideo', // Dir to store video. Default is video/
            size: { width: 640, height: 480 }, // Video resolution
            attach: true // Define if trace need to be attached to cucumber report. Default false
        }
    }
}

reuseSession

reuseSession flag allows to share session between tests in frames of process. But setting of this flag transfers session control to user.

export default {
    browser: {
        reuseSession: true
    }
}

restartBrowser

restartBrowser flag allows to restart browser between tests instead of default restarting context

export default {
    browser: {
        restartBrowser: true
    }
}

Development and testing

Install dependencies

npm install

Install playwright browsers

npm install:browsers`

Build lib

npm run build

Execute unit test (with vitest)

npm run test`

Execute e2e browser tests

npm run test:e2e`

Execute e2e electron tests

npm run test:e2e:electron`
1.0.1

6 months ago

2.2.1

9 months ago

2.2.0

10 months ago

2.4.0

8 months ago

2.6.0

6 months ago

2.0.0

11 months ago

2.3.0

9 months ago

2.5.0

6 months ago

2.7.0

5 months ago

2.1.0

10 months ago

1.0.0

1 year ago

0.53.0

1 year ago

0.54.0

1 year ago

0.52.0

1 year ago

0.51.0

1 year ago

0.48.0

1 year ago

0.46.3

1 year ago

0.50.0

1 year ago

0.47.1

1 year ago

0.49.0

1 year ago

0.47.0

1 year ago

0.46.2

1 year ago

0.46.0

2 years ago

0.46.1

2 years ago

0.45.0

2 years ago

0.44.0

2 years ago

0.43.1

2 years ago

0.42.0

2 years ago

0.41.5

2 years ago

0.41.4

2 years ago

0.41.3

2 years ago

0.41.2

2 years ago

0.41.1

2 years ago

0.40.0

2 years ago

0.41.0

2 years ago

0.39.0

2 years ago

0.38.0

2 years ago

0.37.0

2 years ago

0.36.0

2 years ago

0.35.0

2 years ago

0.34.0

2 years ago

0.33.0

2 years ago

0.32.0

2 years ago

0.31.0

2 years ago

0.30.0

2 years ago

0.29.0

2 years ago

0.28.0

2 years ago

0.29.1

2 years ago

0.27.0

2 years ago

0.0.20

2 years ago

0.0.21

2 years ago

0.0.22

2 years ago

0.0.23

2 years ago

0.0.24

2 years ago

0.26.0

2 years ago

0.25.0

2 years ago

0.0.15

3 years ago

0.0.16

3 years ago

0.0.17

3 years ago

0.0.18

3 years ago

0.0.19

3 years ago

0.0.14

3 years ago

0.0.10

3 years ago

0.0.11

3 years ago

0.0.13

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago