I started creating a base test case using Mocha and Selenium Webriver. I get the following error when I try and run
> mocha test
TypeError: describe is not a function
at Object.<anonymous> (/Users/<username>/projects/selenium-testing/test/website_test.js:6:5)
at Module._compile (internal/modules/cjs/loader.js:678:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:689:10)
at Module.load (internal/modules/cjs/loader.js:589:32)
at tryModuleLoad (internal/modules/cjs/loader.js:528:12)
at Function.Module._load (internal/modules/cjs/loader.js:520:3)
at Module.require (internal/modules/cjs/loader.js:626:17)
at require (internal/modules/cjs/helpers.js:20:18)
at /usr/local/lib/node_modules/mocha/lib/mocha.js:253:27
at Array.forEach (<anonymous>)
at Mocha.loadFiles (/usr/local/lib/node_modules/mocha/lib/mocha.js:250:14)
My code sample:
var webdriver = require('selenium-webdriver'),
{describe, before, after, it} = require('selenium-webdriver/testing');
By = webdriver.by,
until = webdriver.until;
describe('scenarios', function(){
beforeEach(function(){
var driver = new webdriver.Builder().forBrowser('chrome').build();
driver.get('http://google.com');
});
afterEach(function(){
driver.quit();
});
it('find google', function(){
});
});
I am not sure how to take care of this error since I tried all 1) globally and locally installing selenium-webdriver