How do you dynamically load launch_url and append a relative path to it

nightwatch.js

Solution

If you have specified a "launch_url" in your nightwatch.json file, you can access it on the 'client' object passed into your tests. For example:

module.exports = {
    'Demo test Google' : function (client) {
        client
            .url(client.launch_url)
            .waitForElementVisible('body', 1000)
            .setValue('input[type=text]', 'nightwatch')
            .waitForElementVisible('button[name=btnG]', 1000)
            .click('button[name=btnG]')
            .pause(1000)
            .assert.containsText('#main', 'Night Watch')
            .end();
    }
};

So, for your example code:

this.test = function (client) {
  client.url(client.launch_url + "/a/b/c"); // >> should result in the browser going to www.xxx.com/a/b/c 
};

Problem

I am trying to use the property `launch_url` in my tests and append a relative path to it before sending the browser to that url. I know that `browser.init();` send the browser to the address in `launch_url` but I was wondering if it is possible to append some string to the retrieved url before executing the redirect. Assuming my `launch_url` is `www.xxx.com`, I'd like to do something like: ``` this.test = function (client) { client.init("/a/b/c"); // >> should result in the browser going to www.xxx.com/a/b/c }; ``` Any idea? Thanks

Original source