-1

Is there a way where I can Run a script to run a website and perform log in etc. and before running a test suite using Nightwatch JS? I have tried to use beforeeach hook in global.js, but so far failed to make it work. If there is a solution for this? I will appreciate if you can respond with examples.

nhrcpt
  • 812
  • 1
  • 11
  • 40
  • 1
    See: [How do I do X?](https://meta.stackoverflow.com/questions/253069/whats-the-appropriate-new-current-close-reason-for-how-do-i-do-x) The expectation on SO is that the user asking a question not only does research to answer their own question but also shares that research, code attempts, and results. This demonstrates that you’ve taken the time to try to help yourself, it saves us from reiterating obvious answers, and most of all it helps you get a more specific and relevant answer! See also: [ask] – JeffC Sep 10 '18 at 03:12
  • Hi Jeff, I believe the question is self explanatory. I could post a lot of garbage scripts here which would add zero value to the question. I asked the question because I am stuck, so it would be more appropriate if I could get an answer to my problem. Thanks – nhrcpt Sep 10 '18 at 21:40
  • 1
    Then don't post a bunch of garbage scripts. You are describing existing attempts and that they failed but given us no details. We aren't going to guess what you did because that's a waste of our time. Post a [mcve] and a description of how it failed, including any error messages, etc. if you want help. – JeffC Sep 10 '18 at 21:48

1 Answers1

0

Finally we figured out a solution. In the below snippet the Globals.js file is the common login module that we need to run before running each test script.

 const loginPage = require("../../Globals.js");
// START ------> Import Login Module from Globals.js
module.exports = {
  beforeEach: function (client) {
    loginPage.login(client);
 },
nhrcpt
  • 812
  • 1
  • 11
  • 40