selenium-extend
selenium-extend is an npm module that makes async selenium-webdriver code a lot more sane. It's most valuable when used in conjunction with the selenium chromedriver and makes working with chrome extensions in the context of the chromedriver much easier.
selenium-extend does not overwrite existing
driver functionality. selenium-extend adds
an object named extend
with various methods that
wrap selenium-webdriver functions into
functions that make sense in the context
of navigating a browser.
Installation
npm install --save selenium-extend
Initialization
Creating a new driver with extend methods:
var extend = ; // constructing raw chromevar driverPath = "path/to/chromedriver";var driver = extend; //returns a Chrome WebDriver // constructing chrome with an extensionvar extensionPath = "path/to/chrome/extension/folder"; //unpacked chrome extensionvar driverPath = "path/to/chromedriver";var driver = extend;
Adding extend methods to an existing driver:
var extend = ; extend;
You can also set the maximum wait time for async events:
extend; // sets maximum wait time to 10000ms // default WAITTIME is 10000ms
API
Enable incognito for chrome extensions/selenium web driver:
driverextend; // enables for both selenium and extension driverextend; // enables for up to n extensions, in order // from first to last, selenium is always // the first extension
Check is an element is clickable:
var clickable = driverextend; // returns boolean true or false // waits until WAITTIME // css is a css selector
Click on an element:
driverextend; //css is selector
Double click on an element (really useful for selecting all in input):
driverextend;
Check if an element exists:
driverextend;
Get the text value of an element:
driverextend;
Get the value of an element (input):
driverextend;
Emulate selecting text in DOM with a mouse pointer:
// offset1 and 2 are the character offsets of the text node to highlight text indriverextend;
Type text into an element:
driverextend;
Switch to the next window:
driverextend;
Scroll browser to element:
driverextend;
Future
The following are still to be done: --tests --constructors for other browsers --any other types of browser interactions (e.g. hover, scroll, double click, etc)
License
Created by Shri Ganeshram, please attribute in forks. Licensed under the MIT License.