Skip to content

Commit c236490

Browse files
Merge pull request #1 from abhi2810/main
initial commit
2 parents 880db69 + befee0e commit c236490

17 files changed

+9828
-1
lines changed

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
node_modules
2+
screenshots
3+
videos
4+
downloads
5+
report
6+
log
7+
*.log
8+
results
9+
build_artifacts

README.md

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,34 @@
11
# cucumber-js-cypress-browserstack
2-
Creating a sample repo for Cypress - Cucumber
2+
3+
## Introduction
4+
5+
Cypress is a next generation front end testing tool built for the modern web. Cucumber is a software tool that supports behavior-driven development (BDD).
6+
7+
This BrowserStack Example repository demonstrates a Cypress framework with parallel testing capabilities. The Cypress test scripts are written for the open source [BrowserStack Demo web application](https://bstackdemo.com) ([Github](https://github.com/browserstack/browserstack-demo-app)).
8+
9+
The Cypress tests are run on different platforms like on-prem and BrowserStack using various run configurations and test capabilities.
10+
11+
## Pre-requisites
12+
13+
You need BrowserStack credentials to be able to run Cypress tests. You have to replace `YOUR_USERNAME` and `YOUR_ACCESS_KEY` in the sample scripts in this repository with your BrowserStack credentials which can be found in your [Account Settings](https://www.browserstack.com/accounts/settings) page.
14+
15+
**Alternatively, you can set the environment variables `BROWSERSTACK_USERNAME` and `BROWSERSTACK_ACCESS_KEY` with your credentials and all the scripts in this repository should work fine**
16+
17+
NOTE: **Supported on Node v14+**
18+
19+
## Run Cypress test on BrowserStack
20+
21+
1. Clone this repository
22+
2. Install the dependencies using `npm install`
23+
3. Run the sample script using `npm run sample-test`
24+
25+
## Run sample test on privately hosted websites
26+
27+
Run the sample Local test using `npm run sample-local-test`
28+
29+
## Additional Resources
30+
31+
- View your test results on the [BrowserStack Automate dashboard](https://www.browserstack.com/automate)
32+
- Documentation for writing [Automate test scripts in Cypress](https://www.browserstack.com/docs/automate/cypress)
33+
- [List of Browsers & mobile devices](https://www.browserstack.com/list-of-browsers-and-platforms/cypress_testing) for automation testing on BrowserStack
34+
- For testing public web applications behind IP restriction, [Inbound IP Whitelisting](https://www.browserstack.com/local-testing/inbound-ip-whitelisting) can be enabled with the [BrowserStack Enterprise](https://www.browserstack.com/enterprise) offering

browserstack.json

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
"auth": {
3+
"username": "BROWSERSTACK_USERNAME",
4+
"access_key": "BROWSERSTACK_ACCESS_KEY"
5+
},
6+
"browsers": [
7+
{
8+
"browser": "chrome",
9+
"os": "Windows 10",
10+
"versions": ["latest"]
11+
},
12+
{
13+
"browser": "edge",
14+
"os": "Windows 11",
15+
"versions": ["latest"]
16+
},
17+
{
18+
"browser": "firefox",
19+
"os": "OS X Big Sur",
20+
"versions": ["latest"]
21+
}
22+
],
23+
"run_settings": {
24+
"cypress_config_file": "./cypress.config.js",
25+
"project_name": "BrowserStack Examples",
26+
"build_name": "browserstack-build-1",
27+
"downloads": ["./results"],
28+
"exclude": [],
29+
"parallels": "3",
30+
"npm_dependencies": {
31+
"cypress": "^12.5.1",
32+
"cypress-cucumber-preprocessor": "^4.3.1",
33+
"cypress-multi-reporters": "^1.6.2",
34+
"cypress-xpath": "^2.0.1",
35+
"mocha-junit-reporter": "^2.2.0",
36+
"mochawesome": "^7.1.3"
37+
},
38+
"package_config_options": {
39+
"cypress-cucumber-preprocessor": {
40+
"stepDefinitions": "cypress/support/step_definitions"
41+
}
42+
},
43+
"headless": true
44+
},
45+
"connection_settings": {
46+
"local": true,
47+
"local_identifier": null,
48+
"local_mode": null,
49+
"local_config_file": null
50+
},
51+
"disable_usage_reporting": false
52+
}

cypress.config.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
const { defineConfig } = require("cypress");
2+
const cucumber = require("cypress-cucumber-preprocessor").default;
3+
4+
module.exports = defineConfig({
5+
watchForFileChanges: true,
6+
experimentalWebKitSupport: true,
7+
reporter: "cypress-multi-reporters",
8+
reporterOptions: {
9+
configFile: "reporterConfig.json",
10+
},
11+
12+
e2e: {
13+
setupNodeEvents(on, config) {
14+
on("file:preprocessor", cucumber());
15+
},
16+
specPattern: "**/e2e.feature",
17+
baseUrl: "https://bstackdemo.com/",
18+
excludeSpecPattern: ["*.js"],
19+
},
20+
});

cypress/e2e/e2e.feature

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Feature: End to End Feature
2+
3+
@e2e
4+
Scenario: End to End Scenario
5+
Given I navigate to website
6+
And I SignIn as "fav_user" with "testingisfun99" password
7+
And I add three products to cart
8+
And I click on Buy Button
9+
And I enter shipping details "first", "last", "test address", "test province" and "123456"
10+
And I click on Checkout Button
11+
And I click on "Orders" link
12+
Then I should see elements in list

cypress/e2e/local.feature

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Feature: Local Feature
2+
3+
@local
4+
Scenario: Local Scenario
5+
Given I navigate to local website
6+
Then I should see sample local page

cypress/support/e2e.js

Whitespace-only changes.

cypress/support/pages/login.page.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class login {
2+
username() {
3+
return cy.get("#username", { timeout: 30000 });
4+
}
5+
password() {
6+
return cy.get("#password", { timeout: 30000 });
7+
}
8+
logInButton() {
9+
return cy.get("#login-btn", { timeout: 30000 });
10+
}
11+
logOutButton() {
12+
return cy.get("#logout", { timeout: 30000 });
13+
}
14+
}
15+
export default login;

cypress/support/pages/orders.page.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class orders {
2+
checkout() {
3+
return cy.get("#checkout-shipping-continue", { timeout: 30000 });
4+
}
5+
return() {
6+
return cy.get(
7+
".button.button--tertiary.optimizedCheckout-buttonSecondary",
8+
{ timeout: 30000 }
9+
);
10+
}
11+
orders() {
12+
return cy.get("#orders", { timeout: 30000 });
13+
}
14+
}
15+
export default orders;
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
class purchase {
2+
item1() {
3+
return cy
4+
.get("#1", { timeout: 30000 })
5+
.should("be.visible")
6+
.children(".shelf-item__buy-btn");
7+
}
8+
item2() {
9+
return cy.get("#2").children(".shelf-item__buy-btn");
10+
}
11+
item3() {
12+
return cy.get("#5").children(".shelf-item__buy-btn");
13+
}
14+
buyButton() {
15+
return cy.get(".buy-btn");
16+
}
17+
}
18+
export default purchase;

0 commit comments

Comments
 (0)