-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
493 additions
and
1 deletion.
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,27 @@ | ||
name: Playwright Tests | ||
on: | ||
push: | ||
branches: [ main, master ] | ||
pull_request: | ||
branches: [ main, master ] | ||
jobs: | ||
test: | ||
timeout-minutes: 60 | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: lts/* | ||
- name: Install dependencies | ||
run: npm install -g pnpm && pnpm install | ||
- name: Install Playwright Browsers | ||
run: pnpm exec playwright install --with-deps | ||
- name: Run Playwright tests | ||
run: pnpm exec playwright test | ||
- uses: actions/upload-artifact@v4 | ||
if: always() | ||
with: | ||
name: playwright-report | ||
path: playwright-report/ | ||
retention-days: 30 |
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,6 @@ | ||
node_modules/ | ||
/test-results/ | ||
/playwright-report/ | ||
/blob-report/ | ||
/playwright/.cache/ | ||
.env |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1 +1,25 @@ | ||
# shay-automation-task | ||
# shay-automation-task | ||
|
||
This project is the automation home assignment - https://docs.google.com/document/d/1ixrNCz_rgYYVfeGnUi9ZnBL-OUsqvsP4IaxIAuguRWk/edit | ||
|
||
## Prerequisites | ||
|
||
Before you begin, ensure you have met the following requirements: | ||
|
||
- Node.js (version 18.x or later) | ||
- pnpm (version 8.x or later) | ||
- Access to Cloudinary account credentials | ||
|
||
## Setup | ||
|
||
1. **Clone this Repository** | ||
2. Install the project dependencies using pnpm: | ||
pnpm install | ||
3. Create a .env file in the root directory of the project and add your Cloudinary credentials: | ||
EMAIL=your-email | ||
PASSWORD=your-password | ||
**Make sure to replace your-email and your-password with your actual Cloudinary credentials** | ||
4. Install Playwright: | ||
pnpm exec playwright install | ||
5. To run the tests, use the following command: | ||
pnpm exec playwright test |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,19 @@ | ||
{ | ||
"name": "shay-automation-task", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": {}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": { | ||
"dotenv": "^16.4.5", | ||
"playwright": "^1.45.3", | ||
"uuid": "^10.0.0" | ||
}, | ||
"devDependencies": { | ||
"@playwright/test": "^1.45.3", | ||
"@types/node": "^22.0.0" | ||
} | ||
} |
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,82 @@ | ||
import { defineConfig, devices } from '@playwright/test'; | ||
|
||
/** | ||
* Read environment variables from file. | ||
* https://github.com/motdotla/dotenv | ||
*/ | ||
// import dotenv from 'dotenv'; | ||
// dotenv.config({ path: path.resolve(__dirname, '.env') }); | ||
|
||
/** | ||
* See https://playwright.dev/docs/test-configuration. | ||
*/ | ||
export default defineConfig({ | ||
testDir: './tests', | ||
/* Run tests in files in parallel */ | ||
fullyParallel: true, | ||
/* Set timeout to 50 sec */ | ||
timeout: 60000, | ||
/* Fail the build on CI if you accidentally left test.only in the source code. */ | ||
forbidOnly: !!process.env.CI, | ||
/* Retry on CI only */ | ||
retries: process.env.CI ? 2 : 0, | ||
/* Opt out of parallel tests on CI. */ | ||
workers: process.env.CI ? 1 : undefined, | ||
/* Reporter to use. See https://playwright.dev/docs/test-reporters */ | ||
reporter: 'html', | ||
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ | ||
use: { | ||
headless: false, | ||
/* Base URL to use in actions like `await page.goto('/')`. */ | ||
// baseURL: 'http://127.0.0.1:3000', | ||
|
||
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ | ||
trace: 'retain-on-failure', | ||
screenshot: 'only-on-failure', | ||
}, | ||
|
||
/* Configure projects for major browsers */ | ||
projects: [ | ||
{ | ||
name: 'chromium', | ||
use: { ...devices['Desktop Chrome'] }, | ||
}, | ||
|
||
// { | ||
// name: 'firefox', | ||
// use: { ...devices['Desktop Firefox'] }, | ||
// }, | ||
|
||
// { | ||
// name: 'webkit', | ||
// use: { ...devices['Desktop Safari'] }, | ||
// }, | ||
|
||
/* Test against mobile viewports. */ | ||
// { | ||
// name: 'Mobile Chrome', | ||
// use: { ...devices['Pixel 5'] }, | ||
// }, | ||
// { | ||
// name: 'Mobile Safari', | ||
// use: { ...devices['iPhone 12'] }, | ||
// }, | ||
|
||
/* Test against branded browsers. */ | ||
// { | ||
// name: 'Microsoft Edge', | ||
// use: { ...devices['Desktop Edge'], channel: 'msedge' }, | ||
// }, | ||
// { | ||
// name: 'Google Chrome', | ||
// use: { ...devices['Desktop Chrome'], channel: 'chrome' }, | ||
// }, | ||
], | ||
|
||
/* Run your local dev server before starting the tests */ | ||
// webServer: { | ||
// command: 'npm run start', | ||
// url: 'http://127.0.0.1:3000', | ||
// reuseExistingServer: !process.env.CI, | ||
// }, | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,17 @@ | ||
import {Locator, Page} from '@playwright/test'; | ||
|
||
const ASSET_TITLE_SELECTOR = "//*[@data-test='manage-top-bar']//*[@data-test='asset-title']";; | ||
|
||
|
||
/** | ||
* Asset manage page object | ||
*/ | ||
export class AssetManagePage { | ||
public page: Page; | ||
public assetTitle: Locator | ||
|
||
constructor(page: Page) { | ||
this.page = page; | ||
this.assetTitle = page.locator(ASSET_TITLE_SELECTOR); | ||
} | ||
} |
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,37 @@ | ||
import {Locator, Page} from '@playwright/test'; | ||
|
||
const EMAIL_FIELD_SELECTOR = "//*[@id='user_session_email']"; | ||
const PASSWORD_FIELD_SELECTOR = "//*[@id='user_session_password']"; | ||
const LOGIN_BUTTON_SELECTOR = "//*[@id='sign-in']"; | ||
|
||
|
||
/** | ||
* Login page object | ||
*/ | ||
export class LoginPage { | ||
public page: Page; | ||
public emailInput: Locator; | ||
public passwordInput: Locator; | ||
public loginButton: Locator; | ||
|
||
|
||
constructor(page: Page) { | ||
this.page = page; | ||
this.emailInput = page.locator(EMAIL_FIELD_SELECTOR); | ||
this.passwordInput = page.locator(PASSWORD_FIELD_SELECTOR); | ||
this.loginButton = page.locator(LOGIN_BUTTON_SELECTOR); | ||
} | ||
|
||
/** | ||
* Make login | ||
*/ | ||
public async login(email: string, password: string) { | ||
await this.emailInput.fill(email); | ||
await this.passwordInput.fill(password); | ||
await this.loginButton.click(); | ||
} | ||
|
||
public async goto(): Promise<void> { | ||
await this.page.goto('https://console-staging.cloudinary.com/users/login'); | ||
} | ||
} |
Oops, something went wrong.