1

I've been doing selenium with Javafor years. However, now I'm trying to write Selenium scripts using javascript. I used following guide to learn JavaScript with Selenium.

Guide

However, when I tried npm install [email protected] in my command prompt, following error displays.

npm WARN saveError ENOENT: no such file or directory, open 'E:\Proffessional\FMClarity\Selenium\package.json'
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN enoent ENOENT: no such file or directory, open 'E:\Proffessional\FMClarity\Selenium\package.json'
npm WARN Selenium No description
npm WARN Selenium No repository field.
npm WARN Selenium No README data
npm WARN Selenium No license field.

+ [email protected]
added 30 packages from 69 contributors and audited 34 packages in 8.086s
found 0 vulnerabilities

And then I tried following simple script,

var webdriver = require('selenium-webdriver');

var driver = new webdriver.Builder().
                           withCapabilities(webdriver.Capabilities.firefox() 
                            .build();

driver.get('https://github.com/i18next/i18next-parser/issues/86');

I tried run this script using node sample.js. But following error shows,

SyntaxError: Unexpected token <
    at createScript (vm.js:80:10)
    at Object.runInThisContext (vm.js:139:10)
    at Module._compile (module.js:616:28)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Function.Module.runMain (module.js:693:10)
    at startup (bootstrap_node.js:191:16)
    at bootstrap_node.js:612:3

This might not be a very good question. However, even if I have years of experience in Java, I'm new to JavaScript.

Any kind of help may be appreciated Thanks in advance. :)

1 Answer 1

2

Seems you are missing the closing ) in the line:

var driver = new webdriver.Builder().
               withCapabilities(webdriver.Capabilities.firefox() 
                .build();

Change it to:

var driver = new webdriver.Builder().
               withCapabilities(webdriver.Capabilities.firefox()) 
                .build();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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.