title: Most (but not all) Selenium functions don't do anything in node.js?
body: <p>I'm trying to set up a Selenium testing suite for a Node.js web application I've written. However, before I can write specific tests, I need to make sure I can get Selenium to work at all. I've taken a step back from test writing (though some imports etc. of it are still in my code) and have been following this tutorial: <a href="https://developer.mozilla.org/en-US/docs/Learn/Tools_and_testing/Cross_browser_testing/Your_own_automation_environment" rel="nofollow noreferrer">https://developer.mozilla.org/en-US/docs/Learn/Tools_and_testing/Cross_browser_testing/Your_own_automation_environment</a></p>
  
  <p>When I run the code below, Selenium will start up a window and type 'webdriver' into the search bar of Google as instructed. However, none of the commands other than <code>sendKeys()</code> seem to actually do anything. The button is not clicked, the form is not submitted by any of the other lines which ought to do so.</p>
  
  <p>If I comment out the middle two <code>await</code> lines, then the second <code>sendKeys</code> line will execute and submit the search that way, otherwise it must just hang forever on them. The thing I can't work out is why some methods work and why some seem to cause indefinite waiting. I've even tried simply copy pasting the mozilla tutorial above in and running it, but the same problem happens even with the <code>.then</code> rather than <code>await</code>.</p>
  
  <p>Any insight will be much appreciated!</p>
  
  <p>EDIT: I've tried writing the same scripts in Java and everything works as expected. However, I'd still prefer to have them in js so it's easier to package with my Node.js app.</p>
  
  <pre><code>
  const webdriver = require('selenium-webdriver'),
      Builder = webdriver.Builder,
      By = webdriver.By,
      until = webdriver.until;
  const chrome = require('selenium-webdriver/chrome');
  
  const chai = require('chai');
  const expect = chai.expect;
  const chaiAsPromised = require('chai-as-promised');
  chai.use(chaiAsPromised);
  
  process.on('unhandledRejection', () =&gt; {});
  
  let driver;
  
  (async function doTests() {
      try {
          describe ('Test that login with sample user works', async function () {
              this.timeout(20000);
              // let driver, page;
  
              driver = new Builder().forBrowser('chrome').build();
              await driver.get('http://www.google.com');
  
              let searchBox = await driver.findElement(By.name('q'));
              await searchBox.sendKeys('webdriver');
  
              await driver.findElement(By.name('btnK')).click();
              await driver.findElement(By.name('q')).submit();
  
              await searchBox.sendKeys(webdriver.Key.ENTER); 
          });
      } catch (ex) {
          console.log (new Error(ex.message));
      } finally {
  
      }
  })();```
  </code></pre>