Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript

Kenneth Huynh
Kenneth Huynh
4,712 Points

mocha not able to locate any WebDriver executable for testing

I get the following message when i run mocha.

[INFO] Searching for WebDriver executables installed on the current system... [WARNING] Unable to locate any WebDriver executables for testing [INFO] Running tests against []

0 passing (0ms)

It seems as if mocha isn't picking up the drivers but they are installed.

3 Answers

Hi! i had the same trouble and i tried to put the following command: require("chromedriver"); And it works for me.

Hope it works for you too.

Ari Misha
Ari Misha
19,286 Points

Hiya there! It seems like mocha can't find Selenium web driver. You might have to install either Selenium Webdriver or you could just go for headless PhantomJS which doesn't require any kinda drivers.

do this:

npm install chromedriver --save;

npm install geckodriver --save;

then add in invitee.js file:

require('geckodriver');

require('chromedriver');

Your code will look something like this:

const {Browser, By, Key, until} = require("selenium-webdriver");
const {suite} = require("selenium-webdriver/testing");
const assert = require('assert');
require('geckodriver');
require('chromedriver');

const url = "https://treehouse-projects.github.io/selenium-webdriver-intermediate/waits/app/index.html";

suite(function(env) {
    describe('RSVP site', function() {
        this.timeout(6000);

        it('has invitee list', async function() {
            let driver = await env.builder().build();
            await driver.get(url);
            let elements = await driver.findElements(By.id('invitedList'));
            assert(elements.length > 0);
            driver.quit();
        });
    });
});