npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@astraload/asl-webdriver

v1.0.3

Published

A custom Selenium-webdriver dedicated to being used with Astraload SaaS

Downloads

232

Readme

AslWebDriver

AslWebDriver is a custom Selenium-webdriver dedicated to being used with Astraload SaaS.

Installation

npm install @astraload/asl-webdriver

Setup

Download and place on your system PATH an executable of chromedriver corresponding to a version of the Chrome browser installed on your system.

API

constructor(params)

params:

  1. isHeadless (boolean): Flag whether to run chrome in headless mode. Defaults to false. Set to true in order to run load test on Astraload SaaS.
  2. windowSize ({ height (number), width (number)} optional): Browser window size.
  3. logLevel (number optional): Level of extended logging of network activity. Can be set to LogLevel.Verbose and/or LogLevel.Debug. LogLevel.Verbose flag enables logging of dataReceived network events. LogLevel.Debug flag enables logging of unfinished network requests. Use Bitwise OR operator to combine both flags.

Example:

const { AslWebDriver } = require('@astraload/asl-webdriver');

const aslWebDriver = new AslWebDriver({
  isHeadless: true,
  windowSize: {
    widht: 1280,
    height: 960,
  },
  logLevel: AslWebDriver.LogLevel.Verbose | AslWebDriver.LogLevel.Debug,
});

loadBrowser() / async loadBrowserAsync()

Method takes no parameters. It loads Selenium WebDriver, wraps it for capturing performance data, and returns its instance.

Example:

There are 2 ways to integrate AslWebDriver with your tests, depending on whether you use async/await in your tests or not.

Using async/await:

let driver;

(async function() {
  try {
    driver = await aslWebDriver.loadBrowserAsync();
    await driver.get(url);
    await driver.wait(until.titleContains('SomeTitle'), timeout);
    await driver.quit();
  } catch (error) {
    await aslWebDriver.handleTestFail(error);

    // you need to call handleTestFail method to let the agent properly handle failed test,
    // otherwise the agent will considers this test as successfully passed.
    // handleTestFail method will automatically quit the browser after handling the failed test.
  }
})();

WITHOUT using async/await:

const driver = aslWebDriver.loadBrowser();
driver.get(url);
driver.wait(until.titleContains('SomeTitle'), timeout);
driver.quit();

// if error happens during the test execution
// AslWebDriver will catch it for you, properly handle it
// and then quit the browser.

async handleTestFail(error)

Method takes a single parameter - an error object. Method is intended to be used in tests which are written is async/await manner to let agent properly handle failed test. Method automatically closes the browser after handling failed test.

Example:

(async function() {
  try {
  	// your test steps
    // ...
  } catch (error) {
    await aslWebDriver.handleTestFail(error);
  }
})();

userId (number). Let's say you run a test for 100 users. In that case, each aslWebDriver instance will have its own unique userId which is a user index in a range from 0 to 99.

Example:

const { AslWebDriver } = require('@astraload/asl-webdriver');
const aslWebDriver = new AslWebDriver();
const { userId } = AslWebDriver;

Notes

The @astraload/asl-webdriver package mirrors all the exports of the selenium-webdriver package; so if you need to import anything from the selenium-webdriver package to use in your load test, import it from @astraload/asl-webdriver package instead:

const { AslWebDriver, By, Condition, until } = require("@astraload/asl-webdriver");