Skip to content

Commit

Permalink
Replace password and user with .env variable #1
Browse files Browse the repository at this point in the history
  • Loading branch information
geofranzi committed Nov 11, 2023
1 parent 4bccb1b commit 18d7b5f
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ node_modules/
/playwright-report/
/playwright/.cache/
/playwright/.auth/
.env
14 changes: 14 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,8 @@
},
"scripts": {
"run all tests": "npx playwright test"
},
"dependencies": {
"dotenv": "^16.3.1"
}
}
2 changes: 2 additions & 0 deletions playwright.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// @ts-check
const { defineConfig, devices } = require('@playwright/test');

import 'dotenv/config';

module.exports = defineConfig({

testDir: './tests',
Expand Down
12 changes: 8 additions & 4 deletions tests/GlobalSetupLogin.spec.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import { test as setup, expect } from '@playwright/test';

const authFile = 'playwright/.auth/user.json';
export const host = process.env.HOST;

const user = process.env.ACCOUNT_USERNAME
const password = process.env.ACCOUNT_PASSWORD

const authFile = 'playwright/.auth/user.json';

setup('Authenticate', async ({ page }) => {
await page.goto('https://www.bexis.uni-jena.de/Account/Login');
await page.goto(`${host}/Account/Login`);
await page.getByLabel('Email or Username').click();
await page.getByLabel('Email or Username').fill('');
await page.getByLabel('Email or Username').fill(user);
await page.getByLabel('Password').click();
await page.getByLabel('Password').fill('');
await page.getByLabel('Password').fill(password);
await page.getByRole('button', {name: 'Log in'}).click();
console.log(await page.title());
await expect(page).toHaveTitle('BExIS - News');
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,11 @@ [email protected]:
resolved "https://registry.npmjs.org/diff/-/diff-5.0.0.tgz"
integrity sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w==

dotenv@^16.3.1:
version "16.3.1"
resolved "https://registry.npmjs.org/dotenv/-/dotenv-16.3.1.tgz"
integrity sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ==

emoji-regex@^8.0.0:
version "8.0.0"
resolved "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz"
Expand Down

0 comments on commit 18d7b5f

Please sign in to comment.