Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ghoshasish99/puppeteer-cucumber
This repository explains how to use Puppeteer with Cucumber
https://github.com/ghoshasish99/puppeteer-cucumber
cucumber-js javascript moon puppeteer testautomation testautomationframework
Last synced: 18 days ago
JSON representation
This repository explains how to use Puppeteer with Cucumber
- Host: GitHub
- URL: https://github.com/ghoshasish99/puppeteer-cucumber
- Owner: ghoshasish99
- Created: 2021-01-15T20:28:41.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2021-01-17T13:29:48.000Z (about 4 years ago)
- Last Synced: 2024-11-15T06:42:34.680Z (3 months ago)
- Topics: cucumber-js, javascript, moon, puppeteer, testautomation, testautomationframework
- Language: JavaScript
- Homepage:
- Size: 44.9 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
![Puppeteer Test Execution](https://github.com/ghoshasish99/Puppeteer-Cucumber/workflows/Puppeteer%20Test%20Execution/badge.svg)
# Puppeteer (execution on Moon) with CucumberJS
Puppeteer end-to-end test automation with CucumberJS
## Getting Started* To install Puppeteer : `npm install puppeteer --save-dev`
* To install Cucumber : `npm install cucumber --save-dev`
* To install Junit Reporter : `npm install cucumberjs-junitxml --save-dev`
* To install Chai : `npm install chai --save-dev`
## To execute the testsDefine the scripts in package.json as follows :
```json
"scripts": {
"test": "cucumber-js --parallel 1 -f json:report/report.json && node report.js && cat report/report.json | npx cucumber-junit > report/junitreport.xml"
}
```
Finally execute the tests with `npm test`### Create a global browser for the test session
```Javascript
BeforeAll(async() =>{
if (moonHost){
global.browser = await puppeteer.connect({
timeout: 10000,
browserWSEndpoint : 'ws://'+moonHost+':4444/cdtp/chrome',
headless:false
});
}
else{
global.browser = await puppeteer.launch();
}
});
```
### Create a fresh browser context for each test
```Javascript
Before(async() =>{
global.context = await global.browser.createIncognitoBrowserContext();
global.page = await global.context.newPage();
});
```
### A sample Feature file
```gherkin
Scenario Outline: Login to the E-Shop Application with Wrong Password
Given User launched eshop login page
When User logged in eshop using the invalid emailid "" and the invalid password ""
Then User should not get logged inExamples:
| EmailID | Password |
| [email protected] | Testing$1 |
```
### A sample stepdefinition
```Javascript
When('User logged in eshop using the invalid emailid {string} and the invalid password {string}',async(username,password) =>{
await loginpage.login(username,password);
});
```
### Example of how a Puppeteer code snippet looks
```Javascript
const puppeteer= require('puppeteer');(async () => {
const browser = await puppeteer.launch();
const context = await browser.createIncognitoBrowserContext();
const page = await context.newPage();
await page.goto('https://www.example.com/');
await page.screenshot({ path: 'page.png', fullPage: true });await browser.close();
})();
```
For more on Puppeteer click [here](https://pptr.dev/)To know about Moon, how to deploy and use Moon, read the article below :
https://ghoshasish99.medium.com/deploy-moon-on-azure-and-google-cloud-607a9604bccc