October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk7 min

Monkey Testing with WebdriverIO: A Practical Guide

WebdriverIO has no built-in monkey-testing command, but its browser APIs can support a safe, bounded random-action loop. Learn how to record, replay, and turn discoveries into regression tests.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

WebdriverIO can drive monkey testing, but it does not provide a dedicated monkey-testing command. Build a bounded random-action loop on top of its browser automation APIs: restrict it to a safe staging site, record a seed and every action, check important invariants, and save evidence when a run fails. Then replay and reduce any useful failure as a deterministic regression test.

What monkey testing means in a WebdriverIO suite

Monkey testing explores an interface by sending randomized or otherwise unpredictable inputs—such as clicks, text entry, and scrolling—to see whether the application reaches a failure or violates an expected condition. The randomness is useful for discovering combinations a scripted journey may not cover, but it also makes a run harder to reproduce.

WebdriverIO supplies browser-control primitives, including element interaction and JavaScript execution in the current browsing context. Its official documentation describes automation APIs and test runners, not a packaged monkey-testing feature. The loop below is a practical implementation built from those primitives, not an official WebdriverIO recipe.

Use randomized exploration alongside deterministic journey tests, not instead of them. A new page state is not automatically a defect: decide what the application should guarantee, flag violations of those invariants, and review unfamiliar states in context.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.

Prerequisites and project setup

The WebdriverIO Getting Started documentation describes the current documentation set as applying to WebdriverIO 9.x and later, and lists Node.js 18.20.0 or higher as the oldest active LTS version in its requirements section. These version requirements can change; check the official Getting Started guide before setting up a new project.

Use the official starter flow to create a WebdriverIO project, then select a runner and test framework appropriate to your application. The WebdriverIO Runner supports Mocha, Jasmine, and Cucumber.js directly; other frameworks may be used through adapter packages. Keep randomized exploration in its own test file or scheduled job so its variable behavior does not obscure critical release checks.

Design the random run before writing it

Choose a safe target and a hard limit

Run only against a disposable test or staging environment with known-safe data. Set a maximum action count or elapsed time before the loop begins. Do not let a random test operate on production accounts, real payments, irreversible deletion, or other destructive actions.

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.

Define an allowlist of actions

Discover visible, enabled controls, but do not interact with every control indiscriminately. Limit the candidates to actions that are safe for the test environment, for example:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Click ordinary navigation links and buttons that do not trigger destructive or financial operations.
  • Enter generated text only into designated, non-sensitive fields.
  • Scroll the page.

Exclude controls that submit sensitive data, delete records, make purchases, change credentials, or trigger external side effects. A selector allowlist is generally safer than trying to guess which arbitrary controls are harmless.

Record enough to reproduce a failure

For each run, record the random seed, initial URL, timestamp, chosen action, target selector or element description, any generated input, and the resulting URL or error. A seed alone may not guarantee an identical run if the page changes between executions, so keep the ordered action trace as well.

Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.

Choose invariants that signal real failures

Useful checks are properties that should remain true across many interactions, such as the application staying responsive or a benign form submission producing one of its expected outcomes. Avoid treating every unexpected navigation or UI state as a bug without considering whether the behavior is valid.

Implement a bounded random-action loop

The following example shows the structure of a Mocha test using WebdriverIO browser and element APIs. Adapt selectors, safe actions, and the invariant to your application. It deliberately leaves destructive controls out of scope. The code is implementation guidance based on documented capabilities and has not been tested here in a live project.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
describe('bounded UI exploration', () => {
  it('keeps the application responsive during safe random actions', async () => {
    const seed = Number(process.env.MONKEY_SEED ?? Date.now());
    const maxActions = 40;
    let state = seed;

    // Small deterministic generator: preserve MONKEY_SEED to replay the sequence.
    const random = () => {
      state = (state * 48271) % 2147483647;
      return state / 2147483647;
    };

    const trace = [];
    const safeSelectors = [
      'a[data-monkey-safe="true"]',
      'button[data-monkey-safe="true"]',
      'input[data-monkey-text="true"]'
    ];

    try {
      await browser.url(process.env.TEST_BASE_URL);

      for (let i = 0; i < maxActions; i++) {
        const candidates = [];

        for (const selector of safeSelectors) {
          const elements = await $$(selector);
          for (const element of elements) {
            if (await element.isDisplayed() && await element.isEnabled()) {
              candidates.push({ selector, element });
            }
          }
        }

        const urlBefore = await browser.getUrl();
        const action = random();

        if (candidates.length && action < 0.75) {
          const candidate = candidates[Math.floor(random() * candidates.length)];
          const tagName = await candidate.element.getTagName();

          if (tagName.toLowerCase() === 'input') {
            const value = `probe-${Math.floor(random() * 100000)}`;
            await candidate.element.setValue(value);
            trace.push({ i, type: 'type', selector: candidate.selector, value, urlBefore });
          } else {
            await candidate.element.click();
            trace.push({ i, type: 'click', selector: candidate.selector, urlBefore });
          }
        } else {
          await browser.execute(() => window.scrollBy(0, Math.max(100, window.innerHeight * 0.7)));
          trace.push({ i, type: 'scroll', urlBefore });
        }

        // Replace this with a meaningful application-specific invariant.
        const readyState = await browser.execute(() => document.readyState);
        if (readyState === 'loading') {
          throw new Error('Application document remained in loading state');
        }

        trace[trace.length - 1].urlAfter = await browser.getUrl();
      }
    } catch (error) {
      const failure = {
        seed,
        url: await browser.getUrl().catch(() => 'unavailable'),
        error: String(error),
        trace
      };
      console.error(JSON.stringify(failure, null, 2));
      await browser.saveScreenshot('./monkey-failure.png').catch(() => {});
      throw error;
    }
  });
});

Set TEST_BASE_URL to the staging application and mark only safe controls with the example data attributes, or replace the selectors with an application-specific allowlist. The example logs a compact trace and saves a screenshot on failure; connect this output to the project’s normal test reporter or CI artifact storage as appropriate.

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft

Choose where the tests run

WebdriverIO offers local and browser runners. The local runner executes test files in worker processes, with isolated browser sessions per capability; the browser runner executes tests in an actual browser. Select based on the behavior and environment you need to exercise rather than assuming one mode covers every deployment.

Consideration What to decide
Isolation and runtime Use the local runner when its worker-process model and separate sessions fit your suite; use the browser runner when running in an actual browser is the relevant execution model.
Browser coverage Cover browsers and environments your application supports. Provider-specific browser availability and costs require checking with the chosen provider.
Reproducibility Save the seed and ordered action trace, and convert confirmed failures into deterministic tests.
Safety Use non-production data and keep destructive or financial actions outside the allowlist.
Signal quality Separate crashes and invariant violations from unfamiliar but valid UI states.

For network-controlled scenarios, WebdriverIO’s mock command can help alter responses, but it requires WebDriver BiDi support. Verify support in the selected browser or cloud-provider environment before depending on it.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Capture failure evidence and turn discoveries into tests

  1. Save the seed, action trace, failing URL, and error when an invariant fails.
  2. Capture a screenshot and, where useful, browser logs or additional state through the runner’s reporting and hooks. Exact hook configuration depends on the runner and project version.
  3. Replay the same seed and inspect whether the ordered actions still lead to the failure. If the page has changed, use the trace to reproduce the sequence manually or adapt it.
  4. Reduce the sequence to the shortest actions that still trigger the defect.
  5. Add a deterministic regression test with explicit setup, actions, and assertions. Keep randomized runs separate or scheduled so nondeterminism does not make release results opaque.

Execute JavaScript when a browser-side action helps

WebdriverIO’s browser.execute runs a JavaScript function in the current browsing context and returns its value. It can be useful for small browser-side operations such as scrolling or reading document state, as in the example. Prefer normal element APIs for user interactions so the test exercises the interface in the intended way.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

The API documentation recommends execute; the separate executeAsync API is marked deprecated. Do not base new examples on the deprecated command. See the execute API documentation and the executeAsync API page.

Troubleshoot common problems

  • The run cannot start: Confirm the installed Node.js version meets the current WebdriverIO requirement, the project setup completed successfully, and the selected runner and browser configuration are present.
  • The test clicks the wrong thing or causes side effects: Tighten the safe-selector allowlist, use a staging site with disposable data, and exclude controls with destructive or external consequences.
  • A failure cannot be repeated: Preserve both the seed and action trace, along with the starting URL and generated values. A seed without the same starting page and data may produce a different path.
  • The page changes but the test reports no defect: Add an application-specific invariant. Random exploration needs a defined failure condition; not every valid transition is erroneous.
  • Mocking is unavailable: The mock command requires WebDriver BiDi. Check BiDi support for the browser and provider in use, or test without relying on that feature.
  • The run is slow or noisy: Lower the action limit, narrow the allowlist, and run exploration separately from deterministic release checks. Preserve useful failure artifacts without treating every random state as a regression.

Or skip the browser setup

If you need a screenshot rather than randomized browser interaction, ScreenshotNeo provides a website screenshot API and MCP server. A single GET request can return a PNG, JPEG, WebP, or PDF; for example:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

See the ScreenshotNeo API documentation for request options. Cookie banners, popups, and chat widgets are removed before the shot; bot checks, blank pages, and failed loads are never billed. Its MCP server lets AI agents take screenshots. The free plan includes 1,000 screenshots a month with no card, and paid plans start at $5 for 3,000. This is a screenshot service, not a replacement for a WebdriverIO random-action test.

Sign up free for ScreenshotNeo.

Frequently Asked Questions

Can monkey testing prove that an application is bug-free?

No. It explores selected interactions and checks the invariants you define; it cannot establish correctness for every state or user journey.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Can the random test run against production?

Use a disposable test or staging environment instead. The method can trigger unintended actions, so its controls and data should be isolated.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. Shenzhen desk3 min
    HONOR Expands Beyond Smartphones With Humanoid Robot RevealHONOR said it unveiled its first humanoid robot at MWC 2026 and named shopping assistance, workplace inspections, and supportive companionship as intended uses. Later Robotics D1 claims and a reported…
  2. Cupertino desk5 min
    Apple Unveils AirPods Max 2: The Upgrade That Should Have Happened Years AgoAirPods Max 2 adds H2-powered audio features and Apple claims up to 1.5× more effective ANC, but its design, Smart Case, and 20-hour battery rating are unchanged. Wired lossless audio…
  3. Cupertino desk4 min
    Apple’s OLED Touch MacBooks Are Coming—but the Dynamic Island Is the Real GambleApple has not announced an OLED touchscreen MacBook, but reports point to high-end models arriving in late 2026 or early 2027. The reported Mac Dynamic Island could be useful, but…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.