Selenium WebDriver Java Framework Course Limited Time Offer for $20

Selenium WebDriver Java Framework Course Limited Time Offer for $20



Selenium JavaScript NodeJs Web Driver Simple Test

This article explains how to write a simple automated test using Selenium JavaScript node.js web driver. 

Test Case: authorized users can login Mahara ePortfolio demo site. 

Test Steps

(1) Navigate to the site "";

(2) Enter "student1" in the username field;

(3) Enter "Testing1" in the password field;

(4) Click on the Login button;

(5) Verify that user "Settings" link is displayed. 

Test Implementation

Open a text editor or JavaScript editor and write the following script and save it as "login_test.js" under a folder. In this example, the folder name is "C:\SeleniumNodeJsAutomation"

var webdriver = require('selenium-webdriver'),
    By = require('selenium-webdriver').By,
    until = require('selenium-webdriver').until;

var driver = new webdriver.Builder()


driver.findElement(By.linkText('Settings')).then(function(element) {
  console.log('Yes, found the element');
}, function(error) {
  console.log('The element was not found, as expected');

Run the script with node and see the result as shown below:

C:\SeleniumNodeJsAutomation>node login_test.js
Yes, found the element


The result showed that the test passed. This is a simple example about the usage of Selenium JavaScript node.js web-driver.