Selenium JavaScript – A Full Fledged Test Case

Posted on Posted in Javascript Selenium

In this post we are going to automate a full fledged test case.

Manual Test Case Steps

Test Steps for this test cases are

  1. Open Browser [Chrome]
  2. Head over to web page about Selenium with Javascript.
  3. Locate and Click Download and Install NodeJS link on this page.
  4. This will take us to NodeJS download website.
  5. Locate the Active Menu in top menu of this downloads page.
  6. Verify that Text of this menu link is DOWNLOADS.

Coding the Test Case

To accomplish above steps, We’ll use assertions and Async APIs of WebDriver JS.  Here’s the complete code for above scenario.

Saving and Running the Test Code

Now Save Above Code in secondTest.js and run it using following command.

node secondTest.js


So we’ve accomplished the second step of executing our Javascript test with Selenium.  Next, We should move on to using Mocha (A TestNG equivalent in JavaScript).

Wish you happy Coding!!