The browser object is an important basis for all tests because it is, literally, a browser (or session) environment. I am writing an environment , in fact, as it is misleading to say that the browser in this context is equal to the current window, since you can, for example, run tests using PhantomJS without problems.
You can do some interesting things using the browser object. In my Nightwatch configuration, I set the user globals_path file to globals_path , which allows me to access global variables as follows:
browser.globals.someFunction(browser.globals.someVariable);
All Nightwatch API commands are also used here. Thus, to maximize the window of the current working environment, you can use:
browser.maximizeWindow();
before, say, pointing the browser to the URL you want to check:
browser.url(www.example.com);
The reason why the browser object may look a little strange in the above example is because Nightwatch supports and allows all of its commands to be clained (link to an example sequence of commands using jQuery - the same principles apply).
It looks awfully beautiful when riveted, right ?? But you do not need to bind your tests. You can just write browser. before each command that you want to send to the session.
The browser, by the way, is not a reserved word here. You can call it what you want. I really use the word โclientโ since I thought the word โbrowserโ was misleading since I also run tests on PhantomJS along with Chrome and Firefox.
Hope this helps!