title: Mocha and Selenium WebDriver error thrown while assertion
body: <p>I developing a web program with <a href="https://en.wikipedia.org/wiki/Test-driven_development" rel="nofollow">TDD</a> methodology. Therefore, tests are using <a href="http://www.seleniumhq.org/projects/webdriver/" rel="nofollow">Selenium WebDriver</a> library. But I wonder my program doesn't work correctly. Following is source codes.</p>
  
  <p>public/index.html:</p>
  
  <pre><code>&lt;h1 class="hello"&gt;Hello, world!&lt;/h1&gt;
  </code></pre>
  
  <p>test/test.js:</p>
  
  <pre><code>'use strict'
  var assert = require('assert')
  var webdriver = require('selenium-webdriver'),
      By = webdriver.By,
      until = webdriver.until
  
  var driver;
  
  before(() =&gt; {
      driver = new webdriver.Builder()
          .forBrowser('chrome')
          .build()
  })
  
  describe('Index page', () =&gt; {
      before(() =&gt; {
          driver.get('http://localhost:8080/')
      })
  
      it('should show hello greetings', () =&gt; {
          let hello = driver.findElement(By.css('h1.hello'))
          assert.equal(hello.getText(), 'Hello, world!')
      })
  })
  </code></pre>
  
  <p>package.json:</p>
  
  <pre><code>{
    "name": "foobar",
    "version": "1.0.0",
    "description": "",
    "main": "index.js",
    "devDependencies": {
      "mocha": "^2.5.3"
      "selenium-webdriver": "^2.53.2"
    },
    "scripts": {
      "start": "http-server public",
      "test": "mocha"
    },
    "author": "",
    "license": "ISC"
  }
  </code></pre>
  
  <p>And I've run following command.</p>
  
  <pre><code>C:\Projects\foobar&gt;npm install
  </code></pre>
  
  <p>So, when I run all tests with <code>npm test</code> command, it always failed regardless to <code>npm start</code> command was run or not.</p>
  
  <pre><code>C:\Projects\foobar&gt;npm test
  
  &gt; foobar@1.0.0 test C:\Projects\foobar
  &gt; mocha
  
  
  
    Index page
      1) should show hello greetings
  
  
    0 passing (62ms)
    1 failing
  
    1) Index page should show hello greetings:
       AssertionError: ManagedPromise {
    flow_:
     ControlFlow {
       propagateUnhandledRejections_: true,
       activeQueue_:
        TaskQueue {
       == 'Hello, world!'
        at Context.&lt;anonymous&gt; (C:\Projects\foobar\test\test.js:22:16)
        at callFn (C:\Projects\foobar\node_modules\mocha\lib\runnable.js:326:21)
        at Test.Runnable.run (C:\Projects\foobar\node_modules\mocha\lib\runnable.js:319:7)
        at Runner.runTest (C:\Projects\foobar\node_modules\mocha\lib\runner.js:422:10)
        at C:\Projects\foobar\node_modules\mocha\lib\runner.js:528:12
        at next (C:\Projects\foobar\node_modules\mocha\lib\runner.js:342:14)
        at C:\Projects\foobar\node_modules\mocha\lib\runner.js:352:7
        at next (C:\Projects\foobar\node_modules\mocha\lib\runner.js:284:14)
        at Immediate._onImmediate(C:\Projects\foobar\node_modules\mocha\lib\runner.js:320:5)
  
  
  npm ERR! Test failed.  See above for more details.
  </code></pre>
  
  <p>I think the main issue is in <code>hello.getText()</code> snippet. The <code>getText()</code> method couldn't get text of <em>hello</em> element.</p>