percy-seleniumjs
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -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; |
{ | ||
"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", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
9778
186