2

I'm automating Chrome on Windows 8.1 with JavaScript using Selenium's WebDriverJS.

1) To get started with WebDriverJS for Node, I downloaded a copy of the ChromeDriver and selenium-server-standalone jar file and placed them in E:\Selenium directory.

2) I wrote the following 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();

3) Then I started Selenium Standalone Server, and tried to run my js code:

E:\Selenium> Node BrowserTest.js

But it throws the following error:

E:\Selenium> node BrowserTest.js

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.readFileSyn > (fs.js:352:15) at Object.Context.closure.goog.retrieveAndExecModule (E:\Selenium\node_modu les\selenium-webdriver_base.js:129:23) at :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)

Please tell me how to resolve the Error.

1 Answer 1

0

From your steps it seems you haven't installed selenium package for Node.js.

  1. Execute npm install selenium-webdriver
  2. Then run the test again
2
  • i have installed webdriver in the same folder from node.js command prompt. Commented Jun 12, 2015 at 7:56
  • 1
    @CodeUnderflow instead of manual installing of the webdriver I think you should try this and also install the chromedriver with npm: npmjs.com/package/chromedriver Commented Jun 12, 2015 at 11:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.