Skip to content

Instantly share code, notes, and snippets.

View MarcusFelling's full-sized avatar

Marcus Felling MarcusFelling

View GitHub Profile
import { test as setup } from '@playwright/test';
const authFile = '.auth/user.json';
setup('authenticate', async ({ browser }) => {
const page = await browser.newPage();
await page.goto('');
// Sign in using creds from env variables
const dialogPromise = page.waitForEvent('popup');
await page.getByText('LOGIN').click();
import type { PlaywrightTestConfig } from '@playwright/test';
const config: PlaywrightTestConfig = {
// register global setup for login
globalSetup: require.resolve('./global-setup'),
use: {
// Tell all tests to load signed-in state from 'storageState.json'.
storageState: 'storageState.json'
}
};
import { chromium, FullConfig } from '@playwright/test';
async function globalSetup(config: FullConfig) {
const browser = await chromium.launch();
const page = await browser.newPage();
await page.goto(process.env.BASEURL);
// Sign in using creds from env variables
await page.getByTitle('Sign In').click();
await page.getByPlaceholder("Email\\, phone\\, or Skype").fill(process.env.AADUSERNAME);
await page.getByPlaceholder("Email\\, phone\\, or Skype").press('Enter');
name: Playwright Tests
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest
test:
name: "Test site using Playwright"
runs-on: ubuntu-20.04
container: mcr.microsoft.com/playwright:focal
steps:
- uses: actions/checkout@master
- uses: actions/setup-node@v2
with:
node-version: '14.x'
- name: Install dependencies
- name: Publish HTML report to testresults.marcusfelling.com
if: always() # We want this to always run, even if test fail prior to this step running
uses: peaceiris/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: playwright-report/ # This is where index.html will be output
keep_files: true # Set this to true to make sure we don't wipe out the other content in GitHub Pages
user_name: 'github-actions[bot]' # This will be the username that gets stamped in the repo commit
user_email: 'github-actions[bot]@users.noreply.github.com' # This will be the user email that gets stamped in the repo commit
name: Demo.Playwright
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
test:
name: "Test site using Playwright"
timeout-minutes: 60
const { test, expect } = require('@playwright/test');
test('test', async ({ page }) => {
// Go to https://nunzioweb.com/iframes-example.htm
await page.goto('https://nunzioweb.com/iframes-example.htm');
// Click img[alt="Killer Klowns From Outer Space"]
await page.frame({
url: 'https://nunzioweb.com/001-opacity-example.htm'
// Change scope to create resource group
targetScope = 'subscription'
// Create resource Group
resource rg 'Microsoft.Resources/resourceGroups@2021-04-01' = {
name: 'myIoTProjectRG'
location: 'eastus'
}
// Create IoT project inside resource group above
@minLength(1)
@maxLength(11)
param projectName string = 'demo'
param location string = resourceGroup().location
var unique = uniqueString(resourceGroup().id)
var iotHubName = '${projectName}Hub${unique}'
var storageAccountName = '${toLower(projectName)}${unique}'
var storageEndpoint = '${projectName}StorageEndpoint'