Hi there,
I'm having issues running a simple test from Centos and have installed the following:
1. sudo yum install git
2. sudo yum install nodejs
3. sudo yum install chromedriver
4. git clone...
5. npm install
The clone from git retrieves the following files (see contents below):
package.json
|____tests/
|__ simpleTest.js
when I run
$ npm run test
I get the following error
> mocha tests/simpleTest.js --timeout 10000
/home/selenium/selenium/node_modules/mocha/lib/cli/run-helpers.js:102
const singleRun = async (mocha, {exit}, fileCollectParams) => {
^
SyntaxError: Unexpected token (
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:549:28)
at Object.Module._extensions..js (module.js:586:10)
at Module.load (module.js:494:32)
at tryModuleLoad (module.js:453:12)
at Function.Module._load (module.js:445:3)
at Module.require (module.js:504:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/home/selenium/selenium/node_modules/mocha/lib/cli/options.js:15:16)
npm ERR! Linux 3.10.0-514.el7.x86_64
npm ERR! argv "/usr/bin/node" "/bin/npm" "run" "test"
npm ERR! node v6.17.1
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! selenium-test@1.0.0 test: `mocha tests/simpleTest.js --timeout 10000`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the selenium-test@1.0.0 test script 'mocha tests/simpleTest.js --timeout 10000'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the selenium-test package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! mocha tests/simpleTest.js --timeout 10000
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs selenium-test
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls selenium-test
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /home/selenium/selenium/npm-debug.log
I've purposely not installed anything else as thought the npm install would grab everything it needs for the simple test.
Appreciate your help! Thanks.
package.json
{
"name": "selenium-test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "mocha Tests/simpleTest.js --timeout 10000"
},
"author": "",
"license": "ISC",
"dependencies": {
"chai": "^4.2.0",
"mocha": "^7.1.0",
"selenium-webdriver": "^4.0.0-alpha.5"
}
}
simpleTest.js
const {Builder, By, until, Key} = require('selenium-webdriver');
const { expect } = require('chai');
describe('Register Broker', () => {
const driver = new Builder().forBrowser('chrome').build();
it('perform a search', async () => {
await driver.get('https://www.google.com/');
await driver.findElement(By.name('q')).sendKeys('test search', Key.RETURN);
await driver.wait(until.titleContains('Google Search'));
const title = await driver.getTitle();
expect(title).to.contain('Google Search');
});
after(async () => driver.quit());
});