import { promise } from 'protractor'; import { environment } from './../src/environments/environment' function sleep(ms) { return new Promise(resolve => setTimeout(resolve, ms)); } describe('Puppeteer tests', () => { beforeAll(async () => { // await page.goto('http://127.0.0.1:8080') }) test('[table] login', async () => { // const browser = await puppeteer.launch({headless: false}); await page.setViewport({width: 1200, height: 720}); await page.goto('http://127.0.0.1:8080'); // wait until page load await page.waitForSelector('.btn-ok') await page.evaluate( () => { let a: HTMLInputElement = document.querySelector('input[type="text"]') a.value = '' let b: HTMLInputElement = document.querySelector('input[type="password"') b.value = '' }) await page.type('input[type="text"]', environment.defaultuser); await page.type('input[type="password"]', environment.defaultuserpwd); // click and wait for navigation await Promise.all([ page.click('.btn-ok'), // page.waitForNavigation({ waitUntil: 'networkidle0' }), ]); await page.waitForSelector('.circle') expect(3 + 2).toBe(5); },30000); test('[table] Clear Code button and set pin', async () => { // const browser = await puppeteer.launch({headless: false}); await page.setViewport({width: 1200, height: 720}); await page.goto('http://127.0.0.1:8080'); // wait until page load await page.waitForSelector('.btn-ok') await page.evaluate( () => { let a: HTMLInputElement = document.querySelector('input[type="text"]') a.value = '' let b: HTMLInputElement = document.querySelector('input[type="password"') b.value = '' }) await page.type('input[type="text"]', environment.defaultuser); await page.type('input[type="password"]', environment.defaultuserpwd); // click and wait for navigation await Promise.all([ page.click('.btn-ok'), // page.waitForNavigation({ waitUntil: 'networkidle0' }), ]); await page.waitForSelector('.circle') // define code await page.click('.circle') await page.click('.circle') await page.click('.circle') // clear code await page.click('.cy-clear') // define code await page.click('.circle') await page.click('.circle') await page.click('.circle') await page.click('.circle') await page.click('.div-profile') expect(3 + 2).toBe(5); },30000); });