Can protractor be made to run slowly?

Below is my solution to do that. So basically I created a decorator for current control flow execute function, which now additionaly queues a delay of 100ms before each queued action. This needs to be run before any tests are invoked (outside describe block) var origFn = browser.driver.controlFlow().execute; browser.driver.controlFlow().execute = function() { var args = … Read more

In Cypress, set a token in localStorage before test

Here’s an example of adding a command cy.login() that you can use in any Cypress test, or put in a beforeEach hook. Cypress.Commands.add(‘login’, () => { cy.request({ method: ‘POST’, url: ‘http://localhost:3000/api/users/login’, body: { user: { email: ‘jake@jake.jake’, password: ‘jakejake’, } } }) .then((resp) => { window.localStorage.setItem(‘jwt’, resp.body.user.token) }) }) Then in your test: beforeEach(() => … Read more

How to test file inputs with Cypress?

it(‘Testing picture uploading’, () => { cy.fixture(‘testPicture.png’).then(fileContent => { cy.get(‘input[type=”file”]’).attachFile({ fileContent: fileContent.toString(), fileName: ‘testPicture.png’, mimeType: ‘image/png’ }); }); }); Use cypress file upload package: https://www.npmjs.com/package/cypress-file-upload Note: testPicture.png must be in fixture folder of cypress

How to fill an input field using Puppeteer?

Just set value of input like this: await page.$eval(‘#email’, el => el.value=”test@example.com”); Here is an example of using it on Wikipedia: const puppeteer = require(‘puppeteer’); (async () => { const browser = await puppeteer.launch(); const page = await browser.newPage(); await page.goto(‘https://en.wikipedia.org’, {waitUntil: ‘networkidle2’}); await page.waitForSelector(‘input[name=search]’); // await page.type(‘input[name=search]’, ‘Adenosine triphosphate’); await page.$eval(‘input[name=search]’, el => el.value=”Adenosine … Read more