I am having 3 issues with my Night Watch Script. Could someone please help me out.

156 views
Skip to first unread message

Krishna A

unread,
Mar 28, 2019, 2:27:23 AM3/28/19
to NightwatchJs
Issue-1: Not able to run Single Test Using Night Watch in Chrome Browser

I'm getting "The "path" argument must be of type string. Received type object" when trying to run a single test case using night watch.

I have 2 test files namely mywrkouthomepage.js and mywrkoutlogin.js under tests directory. 

I am planning to run mywrkoutlogin.js using the command 


node nightwatch --test tests\mywrkoutlogin 


and it throws me with an exception "The "path" argument must be of type string. Received type object"



Issue-2: Trying to click on Login Button but it says element is not interactable


module.exports = {

  before(browser) {
    browser.maximizeWindow();
  },

  'MyWrkOuts Login Test#1' : function (browser) {
    browser
      .url('https://www.mywrkouts.com/')
      .waitForElementVisible('body', 2000)
      .useXpath().click("//*[contains(text(),'Login')]")
      .pause(5000);
  },

  after(browser, done) {
    browser.end(() => {
      console.info('*--*--*--*--*--*--*--*--*--*--*--*--*');
      console.info('*-- Clossing session... Good bye! --*');
      console.info('*--*--*--*--*--*--*--*--*--*--*--*--*');
      done();
    });
  }
};

Here is the error message:
 tests/mywrkoutslogin.js Results for:  MyWrkOuts Login Test#1 
 tests/mywrkoutslogin.js ✔ Element <body> was visible after 33 milliseconds. 
 tests/mywrkoutslogin.js Error while running .clickElement() protocol action: element not interactable 
 tests/mywrkoutslogin.js  
 tests/mywrkoutslogin.js   An error occurred while running .click() command on <//*[contains(text(),'Login')]>: element not interactable 
 tests/mywrkoutslogin.js        at processTicksAndRejections (internal/process/next_tick.js:81:5) 
 tests/mywrkoutslogin.js ✖ [Mywrkoutslogin] MyWrkOuts Login Test#1 (6.871s) 
 tests/mywrkoutslogin.js *--*--*--*--*--*--*--*--*--*--*--*--* 
 tests/mywrkoutslogin.js *-- Clossing session... Good bye! --* 
 tests/mywrkoutslogin.js *--*--*--*--*--*--*--*--*--*--*--*--*

Issue-3: How to use ImplicitWait for each and every statement in Issue-2 rather than using pause command?

Thanks in advance,
Krishna

Per T

unread,
Mar 28, 2019, 3:40:46 AM3/28/19
to NightwatchJs
The first thing that struck me is your very vague xpath for login button. This xpath //*[contains(text(),'Login')] will match a text field that contains Login as well, like a headline for example. Those elements are not interactable.

I'd suggest to narrow the hit rate down by using example //button[contains(text(),'Login')]

Curtis Miller

unread,
Mar 28, 2019, 10:14:30 AM3/28/19
to nightw...@googlegroups.com
Good morning Krishna,

To answer your questions:
Issue #1 - could we see the error output for the single test run like you provided for Issue 2.
Issue #2 - someone already mentioned using a better selector,  //button[contains(text(),"Login")] that should help narrow down your test failure.
Issue #3 - you'll want to use a custom command like below.

exports.command = function(selector, callback) {
const { waitForConditionTimeout } = this.globals;

this.waitForElementVisible(selector, waitForConditionTimeout, function() {
// The nulls below are required or the runner throws exceptions
this.moveToElement(selector, null, null)
.click(selector);
});

if (typeof callback === 'function') {
callback.call(this);
}

return this;
};

Regards,

--curtis

--
You received this message because you are subscribed to the Google Groups "NightwatchJs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nightwatchjs...@googlegroups.com.
To post to this group, send email to nightw...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nightwatchjs/16b6fd88-32a5-4f19-af95-1e6227410f67%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Krishna A

unread,
Mar 28, 2019, 5:49:42 PM3/28/19
to NightwatchJs
Hi Curtis,

  Thanks for the quick reply Curtis. Please find  error log for Issue-1:

Krishnas-MacBook-Pro-2:mywrkoutsautomation $ node nightwatch --test tests\ mywrkoutlogin
 tests/mywrkouthomepage.js   The "path" argument must be of type string. Received type object 
 tests/mywrkouthomepage.js        at validateString (internal/validators.js:125:11) 
 tests/mywrkouthomepage.js        at Object.resolve (path.js:977:7) 
 tests/mywrkouthomepage.js        at process.runNextTicks [as _tickCallback] (internal/process/next_tick.js:47:5) 
 tests/mywrkouthomepage.js        at Function.Module.runMain (internal/modules/cjs/loader.js:865:11) 
 tests/mywrkouthomepage.js        at internal/main/run_main_module.js:21:11 
 tests/mywrkoutlogin.js   The "path" argument must be of type string. Received type object 
 tests/mywrkoutlogin.js        at validateString (internal/validators.js:125:11) 
 tests/mywrkoutlogin.js        at Object.resolve (path.js:977:7) 
 tests/mywrkoutlogin.js        at process.runNextTicks [as _tickCallback] (internal/process/next_tick.js:47:5) 
 tests/mywrkoutlogin.js        at Function.Module.runMain (internal/modules/cjs/loader.js:865:11) 
 tests/mywrkoutlogin.js        at internal/main/run_main_module.js:21:11 

And also please find my nightwatch.json

{
"src_folders": [
"tests"
],
"output_folder": "reports",
"custom_commands_path": "",
"custom_assertions_path": "",
"selenium": {
"start_process": true,
"server_path": "./lib/drivers/selenium-server-standalone-3.12.0.jar",
"log_path": "",
"host": "127.0.0.1",
"port": 4445,
"cli_args": {
"webdriver.chrome.driver": "./lib/drivers/chromedriverMac"
}
},
"test_workers": {
"enabled": true,
"workers": "auto"
},
"test_settings" : {
"default" : {
"desiredCapabilities" : {
"browserName" : "chrome",
"javascriptEnabled": true,
"acceptSslCerts": true,
"chromeOptions": {
"args" : ["--no-sandbox"]
},
"loggingPrefs": {"driver": "INFO", "server": "OFF", "browser": "INFO"}
}
},
"chrome" : {
"desiredCapabilities": {
"browserName": "chrome",
"javascriptEnabled": true,
"acceptSslCerts": true,
"chromeOptions" : {
"args" : ["--no-sandbox"]
},
"loggingPrefs": {"driver": "INFO", "server": "OFF", "browser": "INFO"}
}
}
}
}

Thanks,
Krishna

On Thursday, March 28, 2019 at 9:14:30 AM UTC-5, Curtis Miller wrote:
Good morning Krishna,

To answer your questions:
Issue #1 - could we see the error output for the single test run like you provided for Issue 2.
Issue #2 - someone already mentioned using a better selector,  //button[contains(text(),"Login")] that should help narrow down your test failure.
Issue #3 - you'll want to use a custom command like below.

exports.command = function(selector, callback) {
const { waitForConditionTimeout } = this.globals;

this.waitForElementVisible(selector, waitForConditionTimeout, function() {
// The nulls below are required or the runner throws exceptions
this.moveToElement(selector, null, null)
.click(selector);
});

if (typeof callback === 'function') {
callback.call(this);
}

return this;
};

Regards,

--curtis

To unsubscribe from this group and stop receiving emails from it, send an email to nightw...@googlegroups.com.

Krishna Chaitanya

unread,
Apr 2, 2019, 3:35:12 AM4/2/19
to NightwatchJs
Hi Curtis,

   Could you please reply if you get a chance to look into the issue?

Thanks,
Krishna

To unsubscribe from this group and stop receiving emails from it, send an email to nightwatchjs...@googlegroups.com.

To post to this group, send email to nightw...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages