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.0.6
  • 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

Members

visibleBoolean

Check if the node is visible

hiddenBoolean

Check if the node is hidden

nextElementSiblingSimulateUser | null

nextElementSibling but returns a wrapper

optionsArray.<String>

Get all select option values

textString

Get trimmed text content

valueString

Proxy for value

htmlForString

Proxy for htmlFor

tagString

tagName but lower case

Functions

build()SimulateUser

Generate a instance using the same class constructor

log()

Proxy for console.log

error()

Proxy for console.error

sleep(timeout)Promise.<undefined>

Returns a promise which resolves in a certain amount of milliseconds

timeout(func, limit)Promise.<*>

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

getEventOptions(options)Object

Get options for an event

querySelectorAll(query)Array.<SimulateUser>

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

getElementById(id)SimulateUser | null

getElementById but returns a wrapper

getElementsByName(name)Array.<SimulateUser>

getElementsByName but returns an array of wrappers

closest()SimulateUser | null

closest but returns a wrapper

all(options)SimulateUser | null

Search through page elements as a user would, using text

first(options)SimulateUser | null

Get the first element of a query to all

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)

field(label)SimulateUser | null

Get a field based on its label

fieldSet(legend)SimulateUser | null

Get a fieldset based on its legend

dispatchEvent(event)

Proxy for dispatchEvent

click()

Click this node

attach(files)

Attach files to this input element

check(checked)

Check this checkbox

focus()

Focus this element

blur()

Blur this element

typeKey(key)

Type a single key on this element

type(text)

Type a string on this element

typeValue(text)

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

fillIn(label, value)SimulateUser

Find a field by its label then fill it in

fill(text)

Fill in this node as a field

fillSelect(label, text, options)SimulateUser

Find a select by its label then fill it in

select(options)

Change a value by the option text

sendChangeEvent()

Send a change event

Typedefs

SearchProperties : Object

visible ⇒ Boolean

Check if the node is visible

Kind: global variable

hidden ⇒ Boolean

Check if the node is hidden

Kind: global variable

nextElementSibling ⇒ SimulateUser | null

nextElementSibling but returns a wrapper

Kind: global variable

options ⇒ Array.<String>

Get all select option values

Kind: global variable

text ⇒ String

Get trimmed text content

Kind: global variable

value ⇒ String

Proxy for value

Kind: global variable

htmlFor ⇒ String

Proxy for htmlFor

Kind: global variable

tag ⇒ String

tagName but lower case

Kind: global variable

build() ⇒ SimulateUser

Generate a instance using the same class constructor

Kind: global function

ParamType
...args*

log()

Proxy for console.log

Kind: global function

ParamType
...args*

error()

Proxy for console.error

Kind: global function

ParamType
...args*

sleep(timeout) ⇒ Promise.<undefined>

Returns a promise which resolves in a certain amount of milliseconds

Kind: global function

ParamType
timeoutNumber

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

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

Kind: global function

ParamTypeDefault
funcfunction
limitNumber2000

getEventOptions(options) ⇒ Object

Get options for an event

Kind: global function

ParamType
optionsObject

querySelectorAll(query) ⇒ Array.<SimulateUser>

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

Kind: global function

ParamType
queryString | Array.<String>

getElementById(id) ⇒ SimulateUser | null

getElementById but returns a wrapper

Kind: global function

ParamType
idString

getElementsByName(name) ⇒ Array.<SimulateUser>

getElementsByName but returns an array of wrappers

Kind: global function

ParamType
nameString

closest() ⇒ SimulateUser | null

closest but returns a wrapper

Kind: global function

ParamType
...args*

all(options) ⇒ SimulateUser | null

Search through page elements as a user would, using text

Kind: global function

ParamType
optionsSearchProperties

first(options) ⇒ SimulateUser | null

Get the first element of a query to all

Kind: global function

ParamType
optionsSearchProperties

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: global function
Throws:

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

field(label) ⇒ SimulateUser | null

Get a field based on its label

Kind: global function
Throws:

  • Error
ParamType
labelString

fieldSet(legend) ⇒ SimulateUser | null

Get a fieldset based on its legend

Kind: global function
Throws:

  • Error
ParamType
legendString

dispatchEvent(event)

Proxy for dispatchEvent

Kind: global function

ParamType
eventEvent

click()

Click this node

Kind: global function

attach(files)

Attach files to this input element

Kind: global function

ParamType
filesEnumerable.<Files>

check(checked)

Check this checkbox

Kind: global function

ParamTypeDefault
checkedBooleantrue

focus()

Focus this element

Kind: global function

blur()

Blur this element

Kind: global function

typeKey(key)

Type a single key on this element

Kind: global function

ParamType
keyString

type(text)

Type a string on this element

Kind: global function

ParamType
textString

typeValue(text)

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

Kind: global function

ParamType
textString

fillIn(label, value) ⇒ SimulateUser

Find a field by its label then fill it in

Kind: global function
Returns: SimulateUser - - The field wrapper

ParamType
labelString
valueString

fill(text)

Fill in this node as a field

Kind: global function

ParamType
textString

fillSelect(label, text, options) ⇒ SimulateUser

Find a select by its label then fill it in

Kind: global function
Returns: SimulateUser - - The field wrapper

ParamType
labelString
textString
optionsObject

select(options)

Change a value by the option text

Kind: global function

ParamType
optionsObject

sendChangeEvent()

Send a change event

Kind: global function

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
visiblefunctionIf element must be visible or not

FAQs

Package last updated on 11 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