Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
webdriverjs
Advanced tools
This library is a webdriver module for nodejs. It makes it possible to write super easy selenium tests in your favorite BDD or TDD test framework.
Have a look at the many examples.
Breaking 1.x API changes, see upgrading to 1.x.
npm install webdriverjs
webdriverjs
implements most of selenium's JsonWireProtocol.
Make sure you have a running selenium standalone/grid/hub.
Or use selenium-standalone package to run one easily.
var webdriverjs = require('../index');
var options = {
desiredCapabilities: {
browserName: 'chrome'
}
};
webdriverjs
.remote(options)
.init()
.url('http://www.google.com')
.title(function(err, res) {
console.log('Title was: ' + res.value);
})
.end();
See the full list of options you can pass to .remote(options)
See helpers and protocol methods.
Type: Object
Example:
browserName: 'chrome', // options: firefox, chrome, opera, safari
version: '27.0', // browser version
platform: 'XP', // OS platform
tags: ['tag1','tag2'], // specify some tags (e.g. if you use Sauce Labs)
name: 'my test' // set name for test (e.g. if you use Sauce Labs)
See the selenium documentation for a list of the available capabilities
.
Type: String
Default: silent
Options: verbose | silent | command | data | result
Saves a screenshot to a given path if selenium driver crashes
Type: String
|null
Default: null
Type: Boolean
Default: false
Set to true if you always want to reuse the same remote
The JsonWireProtocol provides several strategies to query an element. WebdriverJS simplifies these to make it more familiar with the common existing selector libraries like Sizzle. The following selector types are supported:
client.click('h2.subheading a', function(err,res) {...})
etc.<a href="http://webdriver.io">WebdriverJS</a>
)
query the text starting with an equal (=) sign. In this example use =WebdriverJS
*=
in front of the query string (e.g. *=driver
)<tag>
or <tag />
[name="some-name"]
as
selector parameter//BODY/DIV[6]/DIV[1]/SPAN[1]
In near future WebdriverJS will cover more selector features like form selector (e.g. :password
,:file
etc)
or positional selectors like :first
or :nth
.
If you which to extend with your own set of commands there is a method
called addCommand
available from the client object:
var client = require("webdriverjs").remote();
// create a command the returns the current url and title as one result
// just to show an example
client.addCommand("getUrlAndTitle", function(cb) {
this.url(function(err,urlResult) {
this.getTitle(function(err,titleResult) {
var specialResult = {url: urlResult.value, title: titleResult};
cb(err,specialResult);
})
});
});
client
.init()
.url('http://www.github.com')
.getUrlAndTitle(function(err,result){
assert.equal(null, err)
assert.strictEqual(result.url,'https://github.com/');
assert.strictEqual(result.title,'GitHub · Build software better, together.');
})
.end();
If you want to help us in developing webdriverjs, you can easily add mocha tests and run them locally:
npm install -g selenium-standalone http-server phantomjs
# start a local selenium instances
start-selenium
# serves the test directory holding the test files
http-server
# runs tests !
npm test
Webdriverjs supports
See the corresponding examples.
These are the current implemented helper methods. All methods take from 0 to a couple of parameters. Also all methods accept a callback so that we can assert values or have more logic when the callback is called.
String
selector, String|String[]
value, Function
callback)Left arrow
or Back space
. You'll find all supported characters here. To do that, the value has to correspond to a key from the table.String
selector, String
localFilePath, Function
callback)<input type=file>
, will upload the local file
to the browser machine and fill the form accordingly. It does not submit the form
for you.String
selector, Function
callback)String
selector, Function
callback)String
tab ID to focus on,] Function
callback)String
name, Function
callback)String
selector, Function
callback)String
selector, Number
startX, Number
startY, Number
endX, Number
endY, Number
touchCount, Number
duration, Function
callback)String
sourceCssSelector, String
destinationCssSelector, Function
callback)String
selector, Number
touchCount, Number
duration, Function
callback)String
selector, Number
touchCount, Number
duration, Function
callback)String
selector, Number
touchCount, Number
duration, Function
callback)String
selector, Number
touchCount, Number
duration, Function
callback)Function
callback)Function
callback)String
or Function
script, Array
arguments, Function
callback)Function
, arguments is required.String
selector, Number
startX, Number
startY, Number
endX, Number
endY, Number
touchCount, Function
callback)String
selector, String
attribute name, Function
callback)String
name, Function
callback)String
selector, String
css property name, Function
callback)Function
callback)String
selector, Function
callback)String
selector, Function
callback)String
selector, Function
callback)Function
callback)Function
callback)Function
callback)String
selector, Function
callback)String
selector, Function
callback)Function
callback)String
selector, Function
callback)String
selector, Function
callback)String
selector, Function
callback)String
selector, Function
callback)String
selector,Function
callback)String
selector, Function
callback)String
selector, Function
callback)String
url, String
name for the new window, String
new window features (e.g. size, position, scrollbars, etc.), Function
callback)Window.open()
in a browserInteger
milliseconds, Function
callback)Function
callback)String
selector, Function
callback)String
selector, Function
callback)String
path to file, Function
callback)String
selector, Function
callback)scroll(xoffset,yoffset,callback)
).Object
cookie, Function
callback)String
orientation, Function
callback)String
selector, String|String[]
value, Function
callback)Left arrow
or Back space
. You'll find all supported characters here. To do that, the value has to correspond to a key from the table.String
selector, Function
callback)String
tab ID)String
selector,Number
x,Number
y,Number
tapCount,Number
touchCount,Number
duration,Function
callback)String
selector, Function
callback)String
selector, Integer
milliseconds, Function
callback)Here are the implemented bindings (and links to the official json protocol binding)
The 1.x refactor was done to fix many bugs due to the chain API.
We also removed some features that were not well designed/fully functionning:
singleton
option defaults to false
webdriverjs.endAll
and webdriverjs.sessions
methods are gone. You must access them on the
client
instanceThe npm module for this library is maintained by:
FAQs
A nodejs bindings implementation for selenium 2.0/webdriver
The npm package webdriverjs receives a total of 36 weekly downloads. As such, webdriverjs popularity was classified as not popular.
We found that webdriverjs demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.