Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the ideal location to install selenium-webdriver to work with NodeJS + Selenium + Mocha (On Windows)

What is the ideal location to install selenium-webdriver to work with NodeJS + Selenium + Mocha (On Windows)

I have just started to explore NodeJS with Selenium. Moving forward I will be working with NodeJS + Selenium + Mocha

  1. Installed node.js:

    C:\Users\AtechM_03>node -v
    v6.11.2
    
  2. Installed npm:

    C:\Users\AtechM_03>npm -v
    3.10.10
    
  3. Configured nodeclipse as per http://www.nodeclipse.org/updates/ and my Project structure looks like:

enter image description here

Now, I am not sure about the exact location to install selenium-webdriver

  1. Installed selenium-webdriver at the default location (through command-line) as per (http://www.nodeclipse.org/updates/)

    C:\Users\AtechM_03>npm install selenium-webdriver
    C:\Users\AtechM_03
    `-- [email protected]
      +-- [email protected]
      | +-- [email protected]
      | +-- [email protected]
      | +-- [email protected]
      | | `-- [email protected]
      | +-- [email protected]
      | `-- [email protected]
      |   +-- [email protected]
      |   +-- [email protected]
      |   +-- [email protected]
      |   +-- [email protected]
      |   +-- [email protected]
      |   `-- [email protected]
      +-- [email protected]
      | `-- [email protected]
      |   +-- [email protected]
      |   +-- [email protected]
      |   | `-- [email protected]
      |   +-- [email protected]
      |   | `-- [email protected]
      |   |   +-- [email protected]
      |   |   `-- [email protected]
      |   +-- [email protected]
      |   `-- [email protected]
      +-- [email protected]
      | `-- [email protected]
      `-- [email protected]
        +-- [email protected]
        `-- [email protected]
          `-- [email protected]
    
    npm WARN enoent ENOENT: no such file or directory, open 'C:\Users\AtechM_03\pack
    age.json'
    npm WARN AtechM_03 No description
    npm WARN AtechM_03 No repository field.
    npm WARN AtechM_03 No README data
    npm WARN AtechM_03 No license field.
    
  2. Installed selenium-webdriver at the current project directory (through command-line) as per (https://dzone.com/articles/selenium-nodejs-and-mocha)

    C:\Users\AtechM_03\LearnAutmation\NodeProject>npm install selenium-webdriver
    [email protected] C:\Users\AtechM_03\LearnAutmation\NodeProject
    `-- [email protected]
      +-- [email protected]
      | +-- [email protected]
      | +-- [email protected]
      | +-- [email protected]
      | | `-- [email protected]
      | +-- [email protected]
      | `-- [email protected]
      |   +-- [email protected]
      |   +-- [email protected]
      |   +-- [email protected]
      |   +-- [email protected]
      |   +-- [email protected]
      |   `-- [email protected]
      +-- [email protected]
      | `-- [email protected]
      |   +-- [email protected]
      |   +-- [email protected]
      |   | `-- [email protected]
      |   +-- [email protected]
      |   | `-- [email protected]
      |   |   +-- [email protected]
      |   |   `-- [email protected]
      |   +-- [email protected]
      |   `-- [email protected]
      +-- [email protected]
      | `-- [email protected]
      `-- [email protected]
        +-- [email protected]
        `-- [email protected]
    
    npm WARN [email protected] No repository field.
    
  3. Wrote my first program through NodeJS-Selenium as first_test.js and it executes well.

Code:

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

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

    driver.get('http://www.google.com');
    driver.findElement(webdriver.By.name('q')).sendKeys('simple programmer');
    driver.findElement(webdriver.By.name('q')).submit();
    driver.quit();

Execution :

    C:\Users\AtechM_03\LearnAutmation\NodeProject\Selenium>node first_test.js
    C:\Users\AtechM_03\LearnAutmation\NodeProject\Selenium>

My Question :

  • How can I know from which location of selenium-webdriver is Testcase getting executed?
  • How can I remove/uninstall the additional selenium-webdriver installation completely?
  • How can I generate some granular trace level logs to know whats happening within?

While with Selenium-Java binding I add the jars at project level where as with Selenium-Python binding PyDev module binded the Python Home to Eclipse by default.

Any suggestions/pointers will be helpful.

like image 644
undetected Selenium Avatar asked Sep 25 '17 08:09

undetected Selenium


People also ask

Which command is used to install Selenium WebDriver in node?

First, you'll need to decide on the OS and Device/Browser combination you'd like to test on. }var driver = new webdriver. Builder(). usingServer('http://hub-cloud.browserstack.com/wd/hub').

How do I run Selenium in node JS?

Set up the dependencies Before you can start running your Selenium tests with NodeJS , you need to have the NodeJS language bindings installed. Run the following command on your terminal/command-line to install the required dependencies.

What is Mocha Selenium?

Mocha is a feature-rich JavaScript test framework running on node. js and the browser, making asynchronous testing simple and fun. Mocha tests run serially, allowing for flexible and accurate reporting, while mapping uncaught exceptions to the correct test cases; Selenium: Web Browser Automation.


1 Answers

How can I know from which location of selenium-webdriver is Testcase getting executed

The package search location order of nodejs as below:

  1. project local packages, which at project_folder/node_modules
  2. nodejs global packages, which at NPM_global_package_install_folder/node_modules, you can get where is PM_global_package_install_folder by executing command:
    npm config get prefix it print out a folder path
  3. nodejs build-in module, which is inside node.exe

If your project local packages includes this package, nodejs will use it from local pacakges, otherwise use if from global package, if gloal packages not has this package, noejs will report module 'selenium-webdriver' not found error.

How can I remove/uninstall the additional selenium-webdriver installation completely

  1. In general, to uninstall project local package, execute npm uninstall selenium-webdriver under project folder, or npm uninstall selenium-webdriver -g to uninstall global package.

How can I generate some granular trace level logs to know whats happening within

Actually, selenium server supply a detail log of each selenium API call, not sure it's you wanted.
enter image description here

like image 53
yong Avatar answered Sep 20 '22 13:09

yong