Socket
Socket
Sign inDemoInstall

percy-seleniumjs

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

percy-seleniumjs - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

36

lib/index.js

@@ -5,2 +5,5 @@ const PercyClient = require('percy-client');

const DEFAULT_DOCTYPE = '<!DOCTYPE html>';
// TODO(ethan): move over to PercyAgent once https://github.com/percy/percy-agent/pull/168 lands
class PercySeleniumClient {

@@ -58,3 +61,3 @@ constructor({ driver, assetLoaderOpts, ...clientOptions }) {

async createSnapshot(options) {
const source = await this.driver.getPageSource();
const source = await this.domSnapshot();
const rootResource = this.percyClient.makeResource({

@@ -81,4 +84,35 @@ resourceUrl: '/',

}
async domSnapshot() {
const docType = await this.getDoctype();
const dom = await this.driver.executeScript(
// eslint-disable-next-line
() => window.document.documentElement.outerHTML,
);
return docType + dom;
}
async getDoctype() {
const doctype = await this.driver.executeScript(
// eslint-disable-next-line
() => window.document.doctype,
);
return doctype ? this.doctypeToString(doctype) : DEFAULT_DOCTYPE;
}
doctypeToString(doctype) {
const publicDeclaration = doctype.publicId
? ` PUBLIC "${doctype.publicId}" `
: '';
const systemDeclaration = doctype.systemId
? ` SYSTEM "${doctype.systemId}" `
: '';
return `<!DOCTYPE ${
doctype.name
} ${publicDeclaration} ${systemDeclaration}>`;
}
}
module.exports = PercySeleniumClient;

2

package.json
{
"name": "percy-seleniumjs",
"version": "v0.1.0",
"version": "0.1.1",
"description": "Unofficial SeleniumJS SDK for Percy. Works with Protractor too.",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc