protractor-xhr-interceptor-plugin

Protractor XHR/Fetch interceptor plugin

Usage no npm install needed!

<script type="module">
  import protractorXhrInterceptorPlugin from 'https://cdn.skypack.dev/protractor-xhr-interceptor-plugin';
</script>

README

protractor-xhr-interceptor-plugin

Introduction

This plugin was inspired by wdio-intercept-service and provide similar functionality but for protractor. Capture and assert HTTP ajax calls in protractortest.org

Installation

npm install protractor-xhr-interceptor-plugin -D

Usage

You can download sample project from sample

It should be as easy as adding protractor-xhr-interceptor-plugin to your protractor.conf.js:

exports.config = {
  plugins: [
    package: 'protractor-xhr-interceptor-plugin'
  ]
};

Once initialized, some related functions are added to your browser instance.

Example

await browser.get(`https://angular.io`);
await browser.addInterceptor();
await browser.expectRequest('GET', 'generated/docs/docs.json', 200);
await element(by.xpath('//a[contains(.,"Get Started")]')).click();
await browser.assertRequests();