title: How do I fix a "browser.elements is not a function" error in Nightwatch.js?
body: <p>I'm trying to use page objects in Nightwatch js and am creating my own commands in that. For some reason now Nightwatch doesn't seem to recognise standard commands on browser and give me a type error on different commands. What am I doing wrong with my code?</p>
  
  <p>I'm tried different things here already, for example adding 'this' or 'browser' in front of the command, which didn't help. My code has gone through many versions already I am not even sure anymore what all I've tried after Googling the error.</p>
  
  <p>My pageObject:</p>
  
  <pre><code>const homePageCommands = {
      deleteAllListItems: function (browser) {
          browser
              .elements('css selector', '#mytodos img', function (res) {
                  res.value.forEach(elementObject =&gt; {
                      browser.elementIdClick(elementObject.ELEMENT);
                  });
              })
              .api.pause(1000)
  
          return this;
      }
  };
  
  module.exports = {
      url: "http://www.todolistme.net"
      },
      elements: {
          myTodoList: {
              selector: '#mytodos'
          },
          deleteItemButton: {
              selector: 'img'
          }
      },
      commands: [homePageCommands]
  };
  </code></pre>
  
  <p>My test:</p>
  
  <pre><code>require('../nightwatch.conf.js');
  
  module.exports = {
      'Validate all todo list items can be removed' : function(browser) {
          const homePage = browser.page.homePage();
  
          homePage.navigate()
              .deleteAllListItems(homePage)
  // I have not continued the test yet because of the error 
  // Should assert that there are no list items left
  
      }
  };
  </code></pre>
  
  <p>Expected behaviour of the custom command is to iterate over the element and click on it.
  Actual result:</p>
  
  <pre><code>TypeError: browser.elements is not a function
         at Page.deleteAllListItems (/pageObjects/homePage.js:18:14)
         at Object.Validate all todo list items can be removed (/specs/addToList.js:8:14)
         at processTicksAndRejections (internal/process/next_tick.js:81:5)
  
  </code></pre>
  
  <p>And also:
  <code>Error while running .navigateTo() protocol action: invalid session id</code></p>