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
2 changes: 1 addition & 1 deletion .github/workflows/Semgrep.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:

container:
# A Docker image with Semgrep installed. Do not change this.
image: returntocorp/semgrep:1.166.0
image: returntocorp/semgrep:1.166.0@sha256:c180f0c93a17b420c0af5006214a29d3c747c5459c732b740191adf657dd0068
# Skip any PR created by dependabot to avoid permission issues:
if: (github.actor != 'dependabot[bot]')

Expand Down
2 changes: 1 addition & 1 deletion .npmrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ save-exact=true
engine-strict=true
legacy-peer-deps=false
audit-level=high
access=public
min-release-age=7
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,13 @@
# browserstack-playwright-robot-load-testing-sample
Sample repository for Playwright framework to do load testing

## Notes before you adapt this sample

- **Dependencies are hash-pinned.** `requirements.txt` is a lock with a hash for every package, so pip refuses anything that doesn't match. Edit the direct dependencies in `requirements.in`, then regenerate the lock:

```sh
uv pip compile requirements.in --universal --python-version 3.10 --generate-hashes -o requirements.txt
```

- **Set thresholds for your own SLA.** `browserstack-load.yml` ships an error-rate and a p95 response-time threshold. Without thresholds every run reports as passed, however the application behaves.
- **Every VU logs in as the same demo user.** That's fine against bstackdemo.com. Against your own application, give each VU its own test account. Concurrent sessions sharing one account race on the same cart and orders, and that can hide real failures.
46 changes: 46 additions & 0 deletions browserstack-load.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
projectName: Robot Framework Playwright Load Testing Sample
testName: robot-playwright-sample
testType: Playwright
framework: robot
language: python
files:
dependencies:
- requirements.txt
testConfigs:
- tests/
# Pass/fail criteria for the run. Tune these to your application's SLA.
thresholds:
- metric: error-percentage
condition: "<"
threshold: 5
unit: "%"
type: blu
requestType: entireTestRun
failOnBreach: false
- metric: p95-response-time
condition: "<"
threshold: 10000
unit: ms
type: blu
requestType: entireTestRun
failOnBreach: false
headless: true
vus: 2
regions:
- loadzone: eu-central-1
percent: 100
loadProfile:
type: ramping
stages:
- type: ramp-up
duration: 10s
from: 0
to: 2
- type: hold
duration: 1m30s
from: 2
to: 2
- type: ramp-down
duration: 10s
from: 2
to: 0
2 changes: 2 additions & 0 deletions requirements.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
robotframework==7.1.0
robotframework-browser==18.4.0
256 changes: 256 additions & 0 deletions requirements.txt

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions resources/common.resource
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
*** Settings ***
Library Browser

*** Variables ***
${BASE_URL} https://bstackdemo.com/
${BROWSER} chromium
${HEADLESS} ${FALSE}

*** Keywords ***
Open BStackDemo
[Documentation] Opens a Playwright browser session via Browser library and navigates to bstackdemo.
New Browser browser=${BROWSER} headless=${HEADLESS}
New Context viewport={'width': 1280, 'height': 720}
New Page ${BASE_URL}
14 changes: 14 additions & 0 deletions tests/bstack_test_add_to_cart.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
*** Settings ***
Resource ../resources/common.resource
Test Setup Open BStackDemo
Test Teardown Close Browser

*** Test Cases ***
BStackDemo Test Add To Cart
[Documentation] Adds a product to the cart and asserts the cart shows the same product name.
Wait For Elements State css=[id="3"] > p visible timeout=10s
${product_to_add}= Get Text css=[id="3"] > p
Click css=[id="3"] > .shelf-item__buy-btn
Wait For Elements State css=.float-cart--open .shelf-item__details p.title visible timeout=10s
${product_in_cart}= Get Text css=.float-cart--open .shelf-item__details p.title
Should Be Equal ${product_in_cart} ${product_to_add}
51 changes: 51 additions & 0 deletions tests/bstack_test_checkout_flow.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
*** Settings ***
Resource ../resources/common.resource
Test Setup Open BStackDemo
Test Teardown Close Browser

*** Test Cases ***
BStackDemo Test Checkout Flow
[Documentation] Signs in, adds two items, completes the address form, and proceeds through checkout.

# sign in
Wait For Elements State id=signin visible timeout=15s
Click id=signin

Wait For Elements State css=#username svg visible timeout=15s
Click css=#username svg
Wait For Elements State id=react-select-2-option-0-0 visible timeout=15s
Click id=react-select-2-option-0-0

Wait For Elements State css=#password svg visible timeout=15s
Click css=#password svg
Wait For Elements State id=react-select-3-option-0-0 visible timeout=15s
Click id=react-select-3-option-0-0

Click id=login-btn

# add two items to cart
Wait For Elements State css=[id="1"] > .shelf-item__buy-btn visible timeout=15s
Click css=[id="1"] > .shelf-item__buy-btn
Wait For Elements State css=div.float-cart__close-btn visible timeout=15s
Click css=div.float-cart__close-btn
Wait For Elements State css=[id="2"] > .shelf-item__buy-btn visible timeout=15s
Click css=[id="2"] > .shelf-item__buy-btn
Wait For Elements State css=.buy-btn visible timeout=15s
Click css=.buy-btn

# add address details
Wait For Elements State id=firstNameInput visible timeout=15s
Fill Text id=firstNameInput first
Fill Text id=lastNameInput last
Fill Text id=addressLine1Input address
Fill Text id=provinceInput province
Fill Text id=postCodeInput pincode

# checkout
Click id=checkout-shipping-continue
Wait For Elements State id=confirmation-message visible timeout=15s
Get Text id=confirmation-message == Your Order has been successfully placed.
Wait For Elements State xpath=//*[normalize-space()='Continue'] visible timeout=15s
Click xpath=//*[normalize-space()='Continue']
Wait For Elements State xpath=//*[normalize-space()='Orders'] visible timeout=15s
Click xpath=//*[normalize-space()='Orders']
Loading