NV-Selenium-JavaScript Integration Samples

You can use the Network Virtualization JavaScript libraries to:

  • Write automated JavaScript tests using your preferred tool. These libraries integrate easily with Selenium and other third-party tools.
  • Insert Network Virtualization capabilities in your automated tests without using the NV Test Manager user interface.

The readme files included with the JavaScript libraries provide all the information you need to get started, including well-documented samples that walk you through each module.

You can access the JavaScript (hpe-nv-js) libraries from Hewlett Packard Enterprise – GitHub Repositories (https://github.com/HewlettPackard?tab=repositories).

Basic Network Virtualization test

This sample demonstrates the use of the most basic Network Virtualization methods in a test.

First, the sample creates a TestManager object and initializes it. The sample starts a Network Virtualization test over an emulated 3G Busy network. 3G Busy is one of Network Virtualization's built-in network profiles. A network profile specifies the network traffic behavior, including latency, packet loss, and incoming/outgoing bandwidth. Network profiles are used to emulate traffic over real-world networks. For more details, see Network Profile Overview.

Next, the sample navigates to the home page in the Network Virtualization website using the Selenium WebDriver.

Finally, the sample stops the Network Virtualization test.

URL: https://github.com/HewlettPackard/hpe-nv-java/blob/master/hpe-nv-java-samples/src/main/java/com/hpe/nv/samples/basic/BasicNVTest.java

Back to top

Commonly used methods

This sample demonstrates the use of the most basic Network Virtualization methods.

First, the sample creates a TestManager object and initializes it. The sample starts a Network Virtualization test over an emulated 3G Busy network.

Next, the sample navigates to the home page in the Network Virtualization website using the Selenium WebDriver.

Finally, the sample stops the Network Virtualization test, analyzes it, and prints the path of the analysis .zip file to the console.

URL: https://github.com/HewlettPackard/hpe-nv-js/blob/master/hpe-nv-js-samples/basic/basic_analyze_nv_test.js

Back to top

Transactions in a test

This sample demonstrates how to run transactions as part of a Network Virtualization test.

In this sample, the Network Virtualization test starts with the 3G Busy network scenario, running the transactions described below.

After the sample stops and analyzes the Network Virtualization test, it prints the analysis .zip file path to the console.

This sample runs the following Network Virtualization transactions:

  1. Home Page transaction. Navigates to the home page in the Network Virtualization website.

  2. Get Started transaction. Navigates to the Get Started Now page in the Network Virtualization website.

  3. Overview transaction. Navigates back to the home page in the Network Virtualization website.

URL: https://github.com/HewlettPackard/hpe-nv-js/blob/master/hpe-nv-js-samples/basic/basic_analyze_nv_transactions.js

Back to top

Network impact comparison

This sample demonstrates how Network Virtualization helps you test your application under various network conditions.

This test starts by navigating to the home page in the Network Virtualization website using the Selenium WebDriver.

This initial step runs without Network Virtualization emulation and provides a basis for comparison.

Next, the sample starts a Network Virtualization test configured with a 3G Busy network scenario. The same step runs as before - navigating to the home page in the Network Virtualization website - but this time, it does so over an emulated 3G Busy network as part of a Network Virtualization transaction.

When the sample finishes running, it prints a summary to the console. This summary displays a comparison of the time it took to navigate to the site both with and without Network Virtualization's network emulation. The results show that the slow 3G Busy network increases the time it takes to navigate to the site, as you would expect.

URL:https://github.com/HewlettPackard/hpe-nv-js/blob/master/hpe-nv-js-samples/basic/basic_comparison_without_nv.js

Back to top

Network scenario comparison

This sample demonstrates a comparison between two network scenarios—WiFi and 3G Busy.

In this sample, the Network Virtualization test starts with the WiFi network scenario, running the transactions listed below.

Then, the sample updates the Network Virtualization test's network scenario to 3G Busy using the real-time update API and runs the same transactions again.

After the sample analyzes the Network Virtualization test and extracts the transaction times from the analysis results, it prints a summary to the console. The summary displays the comparative network times for each transaction in both network scenarios.

This sample runs identical Network Virtualization transactions before and after the real-time update:

  1. Home Page transaction. Navigates to the home page in the Network Virtualization website.
  2. Get Started transaction. Navigates to the Get Started Now page in the Network Virtualization website.
  3. Overview transaction. Navigates back to the home page in the Network Virtualization website.

URL: https://github.com/HewlettPackard/hpe-nv-js/blob/master/hpe-nv-js-samples/basic/basic_analyze_2_scenarios.js

Back to top

Test module APIs

This sample demonstrates all of the Test module APIs except for the real-time update API, which is demonstrated in adv_realtime_update.js.

You can start the test in this sample using either the NTX or Custom modes.

URL: https://github.com/HewlettPackard/hpe-nv-js/blob/master/hpe-nv-js-samples/advanced/adv_all_test_class_methods.js

Back to top

TestManager module APIs

This sample demonstrates all of the TestManager module APIs. These APIs let you:

  • Initialize the TestManager object to pass logon credentials, the NV Test Manager IP, the port, and so on
  • Set/get the Network Virtualization configuration and active adapter
  • Get the running tests tokens
  • Start/stop packet list capture
  • Get packet list information
  • Stop a specified array of tests or all of the running tests
  • Analyze a .shunra file, which is a compressed file that includes an events file, metadata, and packet lists

URL: https://github.com/HewlettPackard/hpe-nv-js/blob/master/hpe-nv-js-samples/advanced/adv_all_testmanager_class_methods.js

Back to top

Sequential test runs

This sample shows how to run several tests sequentially with different network scenarios.

URL: https://github.com/HewlettPackard/hpe-nv-js/blob/master/hpe-nv-js-samples/advanced/adv_multiple_tests_sequential.js

Back to top

Concurrent test runs

This sample shows how to run several tests concurrently with different flow definitions.

When running Network Virtualization tests in parallel, make sure that:

  • each test is configured to use multi-user mode
  • the include/exclude IP ranges in the tests' flows do not overlap, ensuring data separation between the tests

URL: https://github.com/HewlettPackard/hpe-nv-js/blob/master/hpe-nv-js-samples/advanced/adv_multiple_tests_concurrent.js

Back to top

Real-time update API

This sample demonstrates the real-time update API. You can use this API to update the test during runtime. For example, you can update the network scenario to run several mini tests in a single test.

This sample starts by running a Network Virtualization test with a single transaction that uses the 3G Busy network scenario. Then the sample updates the network scenario to 3G Busy and reruns the transaction.

You can update the test in real time using either the NTX or Custom real-time update modes.

URL: https://github.com/HewlettPackard/hpe-nv-js/blob/master/hpe-nv-js-samples/advanced/adv_realtime_update.js

Back to top

See also: