@communicatehealth/browsertests
Advanced tools
Comparing version 1.2.0 to 1.3.0
# Changelog | ||
## 1.3.0 | ||
- Support jumplink testing (via options.jumplinks) | ||
- Better resolve tests in subdirectories | ||
## 1.2.0 | ||
@@ -4,0 +9,0 @@ |
@@ -109,5 +109,6 @@ /** | ||
test = require(dir + "/" + filenameBase + ".js"); | ||
} else if (fs.existsSync(__dirname + "/" + filenameBase + "/index.js")) { | ||
} else if (fs.existsSync(dir + "/" + filenameBase + "/index.js")) { | ||
test = require(dir + "/" + filenameBase + "/index.js"); | ||
} else { | ||
console.error("No tests in " + filenameBase); | ||
return; | ||
@@ -114,0 +115,0 @@ } |
{ | ||
"name": "@communicatehealth/browsertests", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"description": "Testing framework for testing Drupal sites using Selenium", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -43,2 +43,7 @@ // Load a page, trying a few times if a 403 error is encountered | ||
.then(() => { | ||
if (options.jumplinks) { | ||
return module.exports.checkJumpLinks(webdriver, driver, options); | ||
} | ||
}) | ||
.then(() => { | ||
if (options.accessibility) { | ||
@@ -154,2 +159,30 @@ return module.exports.checkAccessibility(webdriver, driver, options); | ||
module.exports.checkJumpLinks = function(webdriver, driver, options) { | ||
const By = webdriver.By; | ||
console.log("Checking internal jump links."); | ||
return driver.findElements(By.css('a[href^="#"]:not([href$="#"]')) | ||
.then((jumplinks) => { | ||
var promise = Promise.resolve(); | ||
jumplinks.forEach(jumplink => { | ||
promise = promise.then(() => jumplink.getAttribute("href")) | ||
.then((href) => { | ||
var id = decodeURIComponent(href).replace(/.*#/, ""); | ||
if (id === "top") { | ||
return; | ||
} | ||
return driver.findElements(By.css('*[id="' + id + '"]')) | ||
.then((elements) => { | ||
if (elements.length === 0) { | ||
module.exports.logError("Missing target for jumplink #" + id); | ||
} else if (elements.length > 1) { | ||
module.exports.logError("Multiple targets for jumplink #" + id); | ||
} | ||
}); | ||
}); | ||
}); | ||
return promise; | ||
}); | ||
} | ||
module.exports.checkAccessibility = function(webdriver, driver, options) { | ||
@@ -156,0 +189,0 @@ const { AxeBuilder } = require('@axe-core/webdriverjs'); |
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
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
47598
1138