
Product
Introducing .NET Support in Socket
Socket now supports .NET (Beta), bringing supply chain security and SBOM accuracy to NuGet and MSBuild-powered C# projects.
automagic-ui
Advanced tools
Automagic ui driver for web interfaces
User interface integration tests are notoriously brittle.
automagic-ui attempts to ease the pain by providing a descriptive api for user interactions.
var driver = require('automagic-ui');
driver.init({
// Scope to a different document or window such as inside an iframe
documentScope: // defaults to document
windowScope: // defaults to window
// Set a delay before executing commands, also sets a default for driver.wait
runDelay: // defaults to 0
// Set a delay between key-presses
keyPressDelay: // defaults to 50
});
Chain some simple interactions
driver()
.click('I am a button')
.pressKey('1')
.pressKey('a')
.click('I am a button')
//execute the sequence of interactions
.go(function(error, result) {
// This would be a good place to write some tests.
// result is the last element automagic-ui interacted with
});
Create some interactions and execute them later
function findLoginForm() {
driver()
.findUi('login', 'field'),
.findUi('password', 'field'),
.findUi('submit', 'button')
}
driver()
.do(findLoginForm())
.focus('login')
.pressKeys('admin')
.focus('password')
.pressKeys('drowssap')
.click('submit', 'button')
.go(function(error, result) {
// Check stuff
})
Target elements by RegExp
driver()
.findUi(/Welcome .*/)
.go(function(error, result) {
// Welcome message for some user found
})
automagic-ui acts like a human tester, you described things like you would describe them to a human. If automagic-ui can't test your UI, your UI might have some usability issues, especially for users that are sight-limited.
Muliple reasons:
display: none
, a person cannot click it, but your tests will still pass.Set's window.url to location.
Elements will first be filtered by type
where type
is one of:
<button>, <a>, ...
<label>, <span>, ...
[role=heading], <h1>, <h2>, ...
<img>, <svg>, [role=img] ...
<input>, <textarea>, <select>, <label>
And then filtered where they semantically match semanticLabel
where semanticLabel
can be the elements text
, title
, placeholder
, aria-label
, value
, or alt
if the element is an IMG
.
Also finds elements that have a referenced <label for="{elementName}">
by the same method.
A list of all the types can be found at elementTypes.js
Matched elements will then by sorted by how likely they are what you are after.
By default, returns the best-match element, but you can get all of the ordered elements by passing true
for returnArray
Get's window.location
Do findUi(semanticLabel[, type])
and .focus()
the matched element.
Blur the currently focused element.
findUi(semanticLabel[, type])
.click()
the matched element.Emulates a key-press on a keyboard.
Usually used after calling .focus()
Emulates multiple key-presses on a keyboard.
Usually used after calling .focus()
the delay between each keypress is configurable during initialisation.
.focus(semanticLabel[, type])
.pressKeys(text)
.blur()
.focus(semanticLabel[, type])
element.value = text
.focus(semanticLabel[, type])
element.value
if it has a value
property or otherwise element.textContent
Waits for time
execute all the actions from another driver
Do some custom action.
action
will be called with action(lastResult, callback)
Caution! This function is not inteded to be used for any case other than UI's that are specifically built with random interface elements, such as those used in security flows. It is not recommended that you use it to predict state based on the presence of UI.
findUi(semanticLabel[, type])
addSubTasks(newDriver)
findUi(semanticLabel[, type])
addSubTasks(newDriver)
findUi(semanticLabel[, type])
Execute the driver
.go(function(error, result){
if(error){
return console.log('one of the steps failed:', error);
}
console.log('Successfully completed all steps. Last result was:', result);
})
FAQs
Automagic ui driver for web interfaces
The npm package automagic-ui receives a total of 9 weekly downloads. As such, automagic-ui popularity was classified as not popular.
We found that automagic-ui demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports .NET (Beta), bringing supply chain security and SBOM accuracy to NuGet and MSBuild-powered C# projects.
Research
Malicious npm packages posing as Telegram bot libraries install SSH backdoors and exfiltrate data from Linux developer machines.
Security News
pip, PDM, pip-audit, and the packaging library are already adding support for Python’s new lock file format.