Selenium WebDriver Error on Windows: logging.js not found

382 views Asked by At

I'm automating Chrome on Windows 8.1 with JavaScript using Selenium's WebDriverJS. I downloaded a copy of the ChromeDriver and Selenium Standalone Server jar file and placed in E:\Selenium directory. I started Selenium Standalone Server and tried to run my javascript code written in BrowserTest.js file with Node command prompt as

E:\Selenium> Node BrowserTest.js

the BrowserTest.js:

var driver = require("selenium-webdriver");
function createDriver() {
    var driver = new driver.Builder()
        .usingServer('http://localhost:4444/wd/hub')
        .withCapabilities(driver.Capabilities.chrome())
        .build();
    driver.manage().timeouts().setScriptTimeout(10000);
    return driver;
}
var driver = createDriver();
driver.get("http://www.google.com");
driver.getTitle().then(function (title) {
    console.log(title);
});
driver.quit();

But it throws error as:

 fs.js:500  return binding.open(pathModule._makeLong(path),
 stringToFlags(flags), mode);
                  ^ Error: ENOENT, no such file or directory 'E:\Selenium\webdriver\logging.js'
      at Error (native)
     at Object.fs.openSync (fs.js:500:18)
     at Object.fs.readFileSync (fs.js:352:15)
     at Object.Context.closure.goog.retrieveAndExecModule_ (E:\Selenium\node_modules\selenium-webdriver\_base.js:129:23)
     at <anonymous>:1:6
     at Object.exports.runInContext (vm.js:64:17)
     at Context.closure.closure.vm.createContext.CLOSURE_IMPORT_SCRIPT (E:\Selenium\node_modules\selenium-webdriver\_base.js:101:12)
     at Object.goog.importScript_ (E:\Selenium\node_modules\selenium-webdriver\lib\goog\base.js:873:9)
     at Object.goog.importModule_ (E:\Selenium\node_modules\selenium-webdriver\lib\goog\base.js:894:14)
     at Object.goog.writeScripts_ (E:\Selenium\node_modules\selenium-webdriver\lib\goog\base.js:1251:16)
3

There are 3 answers

0
LogicalDesk On BEST ANSWER

Problem was solved by updating to version - 2.46.1

0
Simon Hardman On

There appears to be a bug in v2.46.0 of Selenium on windows.

It has just been fixed in 2.46.1, so if you update it should solve your problem

0
mido On

Update

try changing the selenium-webdriver version to 2.46.1, it has been pushed to npm and in it, the bug has been fixed.


like @simon said, this bug is already been reported in github,

for now, one hack has been suggested as solution in it's comments,

go to node_modules\selenium-webdriver\_base.js, add below line between line 100 and line 101( as first line of if block):

opt_srcText = opt_srcText.replace(/\\/g,'/');

it fixed the problem for me.