Running Gwen on BrowserStack
Follow the instructions here to remotely execute your Gwen features on a variety of platforms, browsers and devices hosted on BrowserStack.
Get started
Start a new Gwen project or use an existing one.
Settings file
Create a new browserstack.conf
settings file in your browsers
directory as shown.
./project # Your project root
└── /gwen
└── /browsers
└──browserstack.conf # BrowserStack settings file
Add the following content
gwen {
web {
capabilities {
"bstack:options" {
os = "OS X"
osVersion = "Monterey"
}
}
remote {
url = "https://${env.BROWSERSTACK_USERNAME}:${env.BROWSERSTACK_ACCESS_KEY}@hub-cloud.browserstack.com/wd/hub"
}
}
}
This example configures BrowserStack to run on a Mac OS X Monterey desktop. You can configure any supported BrowserStack capabilities you require depending on which platform, browser, or device you want to target. If no browser or device is specified, Gwen will run the default browser governed by your gwen.target.browser setting. To override this default, just add the browserName
capability to your settings file.
For example: to run on Edge browser:
gwen {
web {
capabilities {
"bstack:options" {
os = "OS X"
osVersion = "Monterey"
}
browserName = "Edge"
}
remote {
url = "https://${env.BROWSERSTACK_USERNAME}:${env.BROWSERSTACK_ACCESS_KEY}@hub-cloud.browserstack.com/wd/hub"
}
}
}
Or to run on the chrome browser on a Pixel 6 phone:
gwen {
web {
capabilities {
"bstack:options" {
osVersion = "12.0"
deviceName = "Google Pixel 6"
}
browserName = "chrome"
}
remote {
url = "https://${env.BROWSERSTACK_USERNAME}:${env.BROWSERSTACK_ACCESS_KEY}@hub-cloud.browserstack.com/wd/hub"
}
}
}
Package JSON script
Add the following gwen:browserstack
script to the scripts
section of the package.json
file in your project.
./project # Your project root
└── package.json # Package json file
"scripts": {
"gwen:browserstack": "gwen -b -c gwen/conf/browsers/browserstack.conf gwen/features"
}
Or to run the samples bundled in Gwen:
"scripts": {
"gwen:browserstack": "gwen -b -c gwen/conf/browsers/browserstack.conf gwen/features/samples"
}
Launch
Set the following enviornment variables on your system (where you will launch Gwen) to your BrowserStack username and access key:
- BROWSERSTACK_USERNAME
- BROWSERSTACK_ACCESS_KEY
Then run the following command in the root of your project to launch Gwen on Browserstack
- Yarn
- npm
- pnpm
yarn gwen:browserstack
npm run gwen:browserstack
pnpm gwen:browserstack
Open BrowserStack's Automate dashboard to view your executions.