A Bootstrap for Selenium3.0 to run E2E Testing more conveniently.
I recommend to use this with manager of Selenium Standalone Server,
e.g.)
Features
Generator & Yield are supported
- If you specify generator function , it is run like co basically
Better APIs than Native Webdriver
- selenium.executeScript
- selenium.executeAsyncScript
- etc is under implementing...(real click api, wait api)
- of course, native webdriver api is fully inherited
fullAuto
options is set to true
, you don't need setup other specials for Selenium except for this
if Originally, below things is required to be worked Selenium.
When your script run...
- Required resources is downloaded & installed with
Selenium Standalone
(from NPM Module) at only first time. - Start and Stop
Selenium Standalone
automatically
Installation
yarn add selenium-bootstrap -D
or
npm i selenium-bootstrap -D
Usage
- Install with
yarn add selenium-bootstrap
ornpm i selenium-bootstrap -D
- Write and run code like below
- Selenium and Browser get started
index.js
const Selenium = ;const selenium = browserName: 'chrome';selenium;
node index.js
selenium.run()
is an simple API which launch Browser. Both of generator function
and normal function with prommise
are supported.(Below example is written generator function
)
And only argument is capabilities
which is able to be specified in the same way as native Webdriver for NodeJS
.
driver
argument is newed built instance fromselenium-webdriver
module.webdriver
argument is imported variable fromselenium-webdriver
module.
More examples
In most cases, Generator is better than Promise chain.
Custom Wrapper APIs (better then native Webdriver APIs)
driver.executeScript
and driver.executeAsyncScript
Problem of The problem is that they are should to be passed as string like below.
driver;driver
selenium.executeScript
selenium;
selenium;
selenium.executeAsyncScript
selenium;
selenium;
selenium.takeScreenshot
selenium;
selenium;// -> save screenshot into specified path
path
is optional. if not set, saved under cwd as filename which named based on url.- Emulating fullpage screenshot with scrolling page for browsers which is not support fullpage screenshot(e.g. chrome).
- Unnecessary to write
fs.writeFile' or
fs.writeFileSync` by yourself to save screenshot image..
options
port
By default, it is referred to selenium standalone server
const selenium = browserName: 'chrome' port: '9999';
port
is used selenium server(default port number is4444
)
fullAuto
const selenium = browserName: 'chrome' fullAuto: true;
When your script run...
- Required resources is downloaded & installed with
Selenium Standalone
(from NPM Module) at only first time. - Start and Stop
Selenium Standalone
automatically port
is available at the same time
direct
const selenium = browserName: 'chrome' direct: true;
- if
direct
is set totrue
, run webdriver directly(not using selenium standalone server)
Easy to use with Cloud Services for Remote or Multi Devices Testing
If you specify the service unique capability, then you can use these services.
They are awesome cloud testing services using real browsers and devices.
Change log
v0.3.0
- Support for Browsers on Windows OS
- Added
direct
Option for selecting whether to use webdriver for the browser directly(Default: false) - Added
fullAuto
Option for running with downloading and installing full automatically
v0.2.0
- Added
port
Option used by selenium standalone server
v0.1.0
- Launch this module
Dependencies
- Node.js (v7.5.0 is checked)
- JRE 1.8~
- Selenium Webdriver for NodeJS
- Selenium Standalone