New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@netsells/simulate-user

Package Overview
Dependencies
Maintainers
9
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@netsells/simulate-user

Library for simulating user interactions using JavaScript in the browser

  • 1.1.0
  • npm
  • Socket score

Version published
Weekly downloads
4
decreased by-42.86%
Maintainers
9
Weekly downloads
 
Created
Source

npm version Build Status

@netsells/simulate-user

Library for simulating user interactions using JavaScript in the browser

Installation

yarn add @netsells/simulate-user

Usage

import SimulateUser from '@netsells/simulate-user';

const sim = new SimulateUser();

const el = await sim.find({ query: 'a', text: 'Click me' });
await el.click();

Documentation

Classes

SimulateUser

Simulate a user

Typedefs

SearchProperties : Object
ValueSelector : SearchProperties | String | Number

A generic value selector. For a textarea or input it should always be a string or number, for a select it can be a string or a SearchProperties

SimulateUser

Simulate a user

Kind: global class

new SimulateUser(node)

Create a SimulateUser class for a page element

ParamType
nodeHTMLElement

simulateUser.visible ⇒ Boolean

Check if the node is visible

Kind: instance property of SimulateUser

simulateUser.hidden ⇒ Boolean

Check if the node is hidden

Kind: instance property of SimulateUser

simulateUser.nextElementSibling ⇒ SimulateUser | null

nextElementSibling but returns a wrapper

Kind: instance property of SimulateUser

simulateUser.options ⇒ Array.<String>

Get all select option values

Kind: instance property of SimulateUser

simulateUser.text ⇒ String

Get trimmed text content

Kind: instance property of SimulateUser

simulateUser.directText ⇒ String

Get text content which is a direct child of this node

Kind: instance property of SimulateUser

simulateUser.parentElement ⇒ SimulateUser

Get the parentElement in a wrapper

Kind: instance property of SimulateUser

simulateUser.className ⇒ String

Proxy for className

Kind: instance property of SimulateUser

simulateUser.value ⇒ String

Proxy for value

Kind: instance property of SimulateUser

simulateUser.htmlFor ⇒ String

Proxy for htmlFor

Kind: instance property of SimulateUser

simulateUser.tag ⇒ String

tagName but lower case

Kind: instance property of SimulateUser

simulateUser.sleep(timeout) ⇒ Promise.<undefined>

Returns a promise which resolves in a certain amount of milliseconds

Kind: instance method of SimulateUser

ParamType
timeoutNumber

simulateUser.timeout(func, limit) ⇒ Promise.<*>

Returns a promise which times out if the passed in promise doesn't resolve in time

Kind: instance method of SimulateUser

ParamTypeDefault
funcfunction
limitNumber2000

simulateUser.getEventOptions(options) ⇒ Object

Get options for an event

Kind: instance method of SimulateUser

ParamType
optionsObject

simulateUser.querySelectorAll(query) ⇒ Array.<SimulateUser>

Proxy for querySelectorAll but returns an array of wrappers instead of nods

Kind: instance method of SimulateUser

ParamType
queryString | Array.<String>

simulateUser.getElementById(id) ⇒ SimulateUser | null

getElementById but returns a wrapper

Kind: instance method of SimulateUser

ParamType
idString

simulateUser.getElementsByName(name) ⇒ Array.<SimulateUser>

getElementsByName but returns an array of wrappers

Kind: instance method of SimulateUser

ParamType
nameString

simulateUser.closest() ⇒ SimulateUser | null

closest but returns a wrapper

Kind: instance method of SimulateUser

ParamType
...args*

simulateUser.all(options) ⇒ SimulateUser | null

Search through page elements as a user would, using text

Kind: instance method of SimulateUser

ParamType
optionsSearchProperties

simulateUser.first(options) ⇒ SimulateUser | null

Get the first element of a query to all

Kind: instance method of SimulateUser

ParamType
optionsSearchProperties

simulateUser.find(options, limit) ⇒ SimulateUser

Get the first element of a query to all, but throws an error if it's not found. Will wait for an element to appear (e.g. if a form is updating)

Kind: instance method of SimulateUser
Throws:

  • Error
ParamTypeDescription
optionsSearchProperties
[options.similar]BooleanIf no exact matches found, fall back to a fuzzy search
limitNumber

simulateUser.field(label) ⇒ SimulateUser | null

Get a field based on its label

Kind: instance method of SimulateUser
Throws:

  • Error
ParamType
labelString

simulateUser.fieldSet(legend) ⇒ SimulateUser | null

Get a fieldset based on its legend

Kind: instance method of SimulateUser
Throws:

  • Error
ParamType
legendString

simulateUser.dispatchEvent(event)

Proxy for dispatchEvent

Kind: instance method of SimulateUser

ParamType
eventEvent

simulateUser.click(search)

Click this node

Kind: instance method of SimulateUser

ParamTypeDefault
searchSearchProperties

simulateUser.attach(files)

Attach files to this input element

Kind: instance method of SimulateUser

ParamType
filesEnumerable.<Files>

simulateUser.check(checked)

Check this checkbox

Kind: instance method of SimulateUser

ParamTypeDefault
checkedBooleantrue

simulateUser.focus()

Focus this element

Kind: instance method of SimulateUser

simulateUser.blur()

Blur this element

Kind: instance method of SimulateUser

simulateUser.typeKey(key)

Type a single key on this element

Kind: instance method of SimulateUser

ParamType
keyString

simulateUser.type(text)

Type a string on this element

Kind: instance method of SimulateUser

ParamType
textString

simulateUser.typeValue(text)

Type into a fields value. Only simulates the final key press then triggers a single change event

Kind: instance method of SimulateUser

ParamType
textString | Number

simulateUser.fillIn(label, value) ⇒ SimulateUser

Find a field by its label then fill it in

Kind: instance method of SimulateUser
Returns: SimulateUser - - The field wrapper

ParamType
labelString
valueValueSelector

simulateUser.fill(value)

Fill in this node as a field

Kind: instance method of SimulateUser

ParamType
valueValueSelector

simulateUser.fillSelect(label, text, options) ⇒ SimulateUser

Deprecated

Find a select by its label then fill it in

Kind: instance method of SimulateUser
Returns: SimulateUser - - The field wrapper

ParamType
labelString
textString
optionsSearchProperties

simulateUser.select(value)

Change a value by the option text

Kind: instance method of SimulateUser

ParamType
valueValueSelector

simulateUser.sendChangeEvent()

Send a change event

Kind: instance method of SimulateUser

SimulateUser.build() ⇒ SimulateUser

Generate a instance using the same class constructor

Kind: static method of SimulateUser

ParamType
...args*

SearchProperties : Object

Kind: global typedef
Properties

NameTypeDescription
textStringText to search on
queryStringOptional query to filter on
caseSensitiveBooleanWhether text is case sensitive
exactBooleanWhether text match should be exact (not including trimmed white space)
predicatefunctionPredicate function wrappers must match
visibleBooleanIf element must be visible or not
directBooleanIf text should be a direct child or not

ValueSelector : SearchProperties | String | Number

A generic value selector. For a textarea or input it should always be a string or number, for a select it can be a string or a SearchProperties

Kind: global typedef

FAQs

Package last updated on 12 Sep 2019

Did you know?

Socket

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.

Install

Related posts

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