-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement playwright examples (#353)
- Loading branch information
1 parent
b7486c1
commit 667aba0
Showing
14 changed files
with
970 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
name: Playwright | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- '**/playwright/**' | ||
pull_request: | ||
paths: | ||
- '**/playwright/**' | ||
workflow_dispatch: | ||
|
||
env: | ||
SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }} | ||
SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }} | ||
GITHUB_TOKEN: ${{ github.token }} | ||
|
||
jobs: | ||
tests: | ||
name: Tests | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
target: [ reporter, grid, saucectl ] | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Setup Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: '18' | ||
- name: Install dependencies | ||
working-directory: playwright | ||
run: npm install | ||
- name: Run ${{matrix.target}} tests | ||
working-directory: playwright | ||
run: npm run test.${{matrix.target}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
node_modules/ | ||
artifacts/ | ||
sauce-app-payload* | ||
/test-results/ | ||
/playwright-report/ | ||
/playwright/.cache/ | ||
/__assets__ | ||
.DS_Store | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
apiVersion: v1alpha | ||
kind: playwright | ||
sauce: | ||
region: us-west-1 | ||
concurrency: 10 # Controls how many suites are executed at the same time. | ||
playwright: | ||
version: package.json # See https://docs.saucelabs.com/web-apps/automated-testing/playwright/#supported-testing-platforms for a list of supported versions. | ||
configFile: playwright.config.js # See https://docs.saucelabs.com/web-apps/automated-testing/playwright/yaml/#configfile for a list of supported configuration files. | ||
# Controls what files are available in the context of a test run (unless explicitly excluded by .sauceignore). | ||
rootDir: ./ | ||
suites: | ||
- name: "Playwright Saucectl" | ||
platformName: "macOS 13" | ||
screenResolution: "1440x900" | ||
testMatch: [".*.js"] | ||
params: | ||
browserName: "chromium" | ||
project: "saucectl" | ||
|
||
reporters: | ||
spotlight: # Prints an overview of failed or otherwise interesting jobs. | ||
enabled: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# This file instructs saucectl to not package any files mentioned here. | ||
.git/ | ||
.github/ | ||
.DS_Store | ||
.hg/ | ||
.vscode/ | ||
.idea/ | ||
.gitignore | ||
.hgignore | ||
.gitlab-ci.yml | ||
.npmrc | ||
*.gif | ||
# Remove this to have node_modules uploaded with code | ||
node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
MIT License | ||
|
||
Copyright (c) 2025 Sauce Labs | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# Playwright | ||
|
||
## Overview | ||
|
||
Playwright uses a low-level protocol to provide access to implementation details of the application under test. | ||
It allows setting event listeners to take specific actions when certain criteria are met | ||
(e.g., whenever the app requests to load an image asset, tell it to display a kitten photo instead). | ||
It is primarily written in JavaScript, but provides support for Java, Python and C# as well. | ||
The primary limitation currently is that it does not work with the production version of browsers, | ||
which means tests must be executed against a modified copy of the latest open source version | ||
of the desired browser. These custom browsers must be downloaded with each new version of Playwright. | ||
This is especially limiting for browsers like Safari, which is quite distinct from the available open source Webkit code. | ||
|
||
## Playwright on Sauce Labs | ||
|
||
There are 3 ways to execute Playwright tests with Sauce Labs, and this project demonstrates running | ||
the same tests with each approach. You can run these tests by cloning the repo and navigating to this directory. | ||
Ensure you [set the environment variables](https://docs.saucelabs.com/basics/environment-variables/), | ||
and run: | ||
```bash | ||
npm install | ||
``` | ||
|
||
### Saucectl | ||
|
||
* **Purpose**: Execute Playwright tests written in JavaScript on any Sauce Labs platform configuration. | ||
* **Use Case**: Ideal for running cross-browser/cross-platform tests without maintaining local environments. | ||
* **Reference**: https://docs.saucelabs.com/web-apps/automated-testing/playwright/ | ||
|
||
For more information on the saucectl product, read the [saucectl documentation](https://docs.saucelabs.com/dev/cli/saucectl/). | ||
For a more thorough demonstration of ways to use playwright with saucectl, take a look at the | ||
[Saucectl Playwright Example Repo](https://github.com/saucelabs/saucectl-playwright-example). | ||
|
||
To execute Playwright with saucectl from this directory, run: | ||
```bash | ||
npm run test.saucectl | ||
``` | ||
|
||
### Remote Grid | ||
|
||
* **Purpose**: Execute Playwright tests in any [suppported language](https://playwright.dev/docs/languages) | ||
by connecting to a remote Selenium Grid. | ||
* **Use Case**: Suitable for developers comfortable configuring custom code environments | ||
and seeking detailed command execution logs. This solution is limited to testing Chrome and Microsoft Edge. | ||
* **Reference**: https://playwright.dev/docs/selenium-grid | ||
|
||
To execute Playwright with a remote grid from this directory, run: | ||
```bash | ||
npm run test.grid | ||
``` | ||
|
||
### Playwright Reporter | ||
|
||
* **Purpose**: Execute Playwright tests locally and display detailed reports on Sauce Labs. | ||
* **Use Case**: Best for executing JavaScript-based Playwright tests on local machines when cross-platform testing is not needed. | ||
* **Reference**: https://docs.saucelabs.com/web-apps/automated-testing/playwright/ | ||
|
||
To execute Playwright with the playwright reporter from this directory, run: | ||
```bash | ||
npm run test.reporter | ||
``` |
Oops, something went wrong.