1

I am new to backstopjs and I have backstop.json (part of it ) as

 "onBeforeScript": "puppet/onBefore.js",
  "onReadyScript": "puppet/onReady.js",
  "scenarios": [
    {
      "label": "CBP Homepage",
      "cookiePath": "backstop_data/engine_scripts/cookies.json",
      "url": "development/url/somepage",
      "referenceUrl": "uat/url/somepage",
      .
      .
    }

I would like to run log in to development site when run reference(backstop reference) and and login to UAT when run test (backstop test) in onBeforeScript ?How do I achieve this or any suggestion for resource to follow ?

ryan
  • 81
  • 8
  • 1
    Unfortunately could not get any help so answering my own question after a bit digging found this tutorial that is useful to setup project dynamically.In case if this could be of use to someone: https://www.linkedin.com/pulse/backstopjs-deep-dive-marc-roland-dacanay/ . – ryan Jan 15 '19 at 00:35
  • did you got the solution, how to fill the login page and submit using backstopJS – rocky Sep 16 '20 at 10:31

1 Answers1

4

The following script worked for me (I based it on puppeteer scripts):

module.exports = async (page, scenario) => {
    await page.goto(scenario.url)
    await page.type('input[name="username"]', 'XXXXXXX');
    await page.type('input[name="password"]', 'XXXXXXX');
    await page.click('button[type="submit"]');
    await page.waitForNavigation();
}

The script was added to onBefore.js

Mehedi Hassan
  • 87
  • 1
  • 13