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.

asked Jun 12, 2015 at 7:25

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
answered Jun 12, 2015 at 7:45
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

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.