web-driverify

1.1.3 • Public • Published

web-driverify

This is a common webdriver for any browser to provide Web Driver interface. Especially useful for browsers that does NOT support Web Driver API.

Web-driverify supports most of the Web Driver Commands, and can work without browser-specific binaries.

Get Started

Install

npm i -g web-driverify

Start Server

$ wd -h
  Usage: wd [options] [configFile]
 
  Options:
 
    -V, --version       output the version number
    -p, --port [num]    port number [8089]
    --proxy-port [num]  proxy port number [8088]
    --stub-port [num]   stub port number for debug use [8087]
    --host [hostname]   hostname for the server
    -h, --help          output usage information

configFile defaults to web-driverify.yaml in currrent work directory, here's an example. Here's a boilerplate project: https://github.com/web-driverify/wdio-boilerplate

Set DEBUG=wd:* to enable debug output. wd-phantom will attach a phantomjs (one of the brilliant headless browsers) instance automatically everytime NewSession requested.

Development

Download

git clone https://github.com/web-driverify/web-driverify.git

Install

# fibers in wdio requires -std=gnu++0x, thus make sure gcc4.3+ installed. 
cd web-driverify && npm install

Run test

# Run all test cases 
npm test
 
# run unit/e2e test cases separately 
# attach phantom.js 
npm run debug:phantom
# run cases, in another shell 
npm run test:unit
npm run test:e2e

Differences with WebDriver Protocol

Web-driverify is implemented in comformance to JSON Wire Protocol, the HTTP APIs exposed by web-driverify are just like Selenium 2, thus compliant with selenium-based test runners like Webdriverio.

Web-driverify cannot launch your browser by itself, you need set your browser's proxy to the Web-driverify server and open a session by visiting the given URL.

Due to limitaions of Javascript, we can't do the same things as selenium.

Implementation Status

APIs are categorized as WebDriver W3C Candidate Recommandation.

Sessions

Command Name API Endpoint wdio API Status
Status GET /status .status() 🕑
New Session POST /session .session()
Get Active Sessions GET /sessions .sessions() 🕑
Get Session GET /session/:sessionId .session(id) 🕑
Delete Session DELETE /session/:sessionId .session('delete')
Set Timeouts POST /session/:sessionId/timeouts .timeouts() 🕑
Set Timeout for Async Script POST /session/:sessionId/timeouts/async_script .timeoutsAsyncScript()
Set Timout for Implicit Wait POST /session/:sessionId/timeouts/implicit_wait .timeoutsImplicitWait() 🕑

Navigation

Command Name API Endpoint wdio API Status
Go POST /session/:sessionId/url .url()
Get Current URL GET /session/:sessionId/url .getUrl()
Back POST /session/:sessionId/back .back() 🕑
Forward POST /session/:sessionId/forward .forward()
Refresh POST /session/:sessionId/refresh .refresh()
Get Title GET /session/:sessionId/title .title()

Document Handling

Command Name API Endpoint wdio API Status
Getting Page Source GET /session/:sessionId/source .source() 🕑
Execute Script POST /session/:sessionId/execute .execute()
Excecute Async Script POST /session/:sessionId/execute_async .executeAsync() 🕑

Screen Capture

Command Name API Endpoint wdio API Status
Take Screenshot GET /session/:sessionId/screenshot .screenshot()

Notes:

  • Screenshots are taken by html2cavans, which may difference with real web page.

Input Sources

Command Name API Endpoint wdio API Status
Get Available Engines GET /session/:sessionId/ime/available_engines .imeAvailableEngines() 👎
Get Active Engine GET /session/:sessionId/ime/active_engine .imeActiveEngine() 👎
Is IME Activated GET /session/:sessionId/ime/activated .imeActivated() 👎
Deactivate IME POST /session/:sessionId/ime/deactivate .imeDeactivate() 👎
Activate IME POST /session/:sessionId/ime/activate .imeActivate() 👎

Notes:

Due to Javascript Limitaions, no input sources APIs will support.

Command Contexts

Command Name API Endpoint wdio API Status
Get Window Handle GET /session/:sessionId/window_handle .window() 👎
Get Window Handles GET /session/:sessionId/window_handles .windowHandles() 👎
Switch To Frame POST /session/:sessionId/frame .frame() 👎
Switch To Parent Frame POST /session/:sessionId/frame/parent .frameParent() 👎
Switch To Window POST /session/:sessionId/window .window() 👎
Close Window DELETE /session/:sessionId/window .close() 👎
Set Window Size POST /session/:sessionId/window/:windowHandle/size .windowHandleSize() 👎
Get Window Size GET /session/:sessionId/window/:windowHandle/size .windowHandleSize() 👎
Set Window Position POST /session/:sessionId/window/:windowHandle/position .windowHandlePosition() 👎
Get Window Position GET /session/:sessionId/window/:windowHandle/position .windowHandlePosition() 👎
Maximize Window POST /session/:sessionId/window/:windowHandle/maximize .windowMaximize() 👎

Notes:

  • Due to Javascript Limitaions, no window APIs will support.

Cookies

Command Name API Endpoint wdio API Status
Get All Cookies GET /session/:sessionId/cookie .cookie() 🕑
Add Cookie POST /session/:sessionId/cookie .setCookie() 🕑
Delete Cookie DELETE /session/:sessionId/cookie .deleteCookie() 🕑
Delete All Cookies DELETE /session/:sessionId/cookie/:name .deleteCookie() 🕑

Notes:

  • Http-only cookies will fetched from http proxy.

Elements

Command Name API Endpoint wdio API Status
Get Active Element POST /session/:sessionId/element/active .elementActive() 🕑
Is Elements Same GET /session/:sessionId/element/:id/equals/:other 🕑

Element Retrieval

Command Name API Endpoint wdio API Status
Find Element POST /session/:sessionId/element .element()
Find Elements POST /session/:sessionId/elements .elements()
Get Element By Id GET /session/:sessionId/element/:id 👎
Find Element From Element POST /session/:sessionId/element/:id/element .$(foo).$(bar)
Find Elements From Element POST /session/:sessionId/element/:id/elements .$(foo).$$(bar)

Notes:

Get element by id is a reserved api.

Element Interaction

Command Name API Endpoint wdio API Status
Element Click POST /session/:sessionId/element/:id/click .elementIdClick()
Element Clear POST /session/:sessionId/element/:id/clear .elementIdClear()
Element Send Keys POST /session/:sessionId/element/:id/value .elementIdValue()
Element Submit POST /session/:sessionId/element/:id/submit .submit()

Element State

Command Name API Endpoint wdio API Status
Is Element Selected GET /session/:sessionId/element/:id/selected .elementIdSelected() 🕑
Get Element Attribute GET /session/:sessionId/element/:id/attribute/:name .elementIdAttribute()
Get Element CSS Value GET /session/:sessionId/element/:id/css/:propertyName .elementIdCssProperty()
Get Element Text GET /session/:sessionId/element/:id/text .elementIdText()
Get Element Tag Name GET /session/:sessionId/element/:id/name .elementIdName() 🕑
Get Element Size GET /session/:sessionId/element/:id/size .elementIdSize()
Is Element Enabled GET /session/:sessionId/element/:id/enabled .elementIdEnabled() 🕑
Is Element Displayed GET /session/:sessionId/element/:id/displayed .elementIdDisplayed()
Get Element Location GET /session/:sessionId/element/:id/location .elementIdLocation()
Get Element Rect GET /session/:sessionId/element/:id/rect .elementIdRect()
Get Element Location In View GET /session/:sessionId/element/:id/location_in_view .elementIdLocationInView() 🕑

User Prompts

Command Name API Endpoint wdio API Status
Dismiss Alert POST /session/:sessionId/dismiss_alert .alertDismiss() 👎
Accept Alert POST /session/:sessionId/accept_alert .alertAccept() 👎
Get Alert Text GET /session/:sessionId/alert_text .alertText() 🕑
Send Alert Text POST /session/:sessionId/alert_text .alertText(text) 👎

Low-level Interactions

Command Name API Endpoint wdio API Status
Get Orientation GET /session/:sessionId/orientation .getOrientation() 🕑
Set Orientation POST /session/:sessionId/orientation .setOrientation() 👎
Move the Mouse POST /session/:sessionId/moveto .moveTo() 🕑
Click the Mouse Button POST /session/:sessionId/click .buttonPress() 🕑
Click and Hold the Mouse Button POST /session/:sessionId/buttondown .buttonDown() 🕑
Releases the Mouse Button POST /session/:sessionId/buttonup .buttonUp() 🕑
Double-click the Mouse Button POST /session/:sessionId/doubleclick .doDoubleClick() 🕑
Tap the Screen POST /session/:sessionId/touch/click .touchClick()
Finger Down POST /session/:sessionId/touch/down .touchDown() 🕑
Finger Up POST /session/:sessionId/touch/up .touchUp() 🕑
Finger Move POST session/:sessionId/touch/move .touchMove() 🕑
Finger Scroll POST session/:sessionId/touch/scroll .touchScroll() 🕑
Double Tap POST session/:sessionId/touch/doubleclick 🕑
Long Tap POST session/:sessionId/touch/longclick .touchLongClick() 🕑
Flick POST session/:sessionId/touch/flick .touchFlick() 🕑
Get Geo Location GET /session/:sessionId/location .getGeoLocation() 🕑
Set Geo Location POST /session/:sessionId/location .setGeoLocation() 👎

Notes:

  • Touch and cliks will simulated via Javascript and may not work.
  • Set geo locations are not possible when you are using real devices.

Storages

Command Name API Endpoint wdio API Status
Get Localstorage GET /session/:sessionId/local_storage .localStorage() 🕑
Set Localstorage POST /session/:sessionId/local_storage .localStorage() 🕑
Clear Localstorage DELETE /session/:sessionId/local_storage .localStorage() 🕑
Get Localstorage Item GET /session/:sessionId/local_storage/key/:key .localStorage() 🕑
Set Localstorage Item DELETE /session/:sessionId/local_storage/key/:key .localStorage() 🕑
Get Localstorage size GET /session/:sessionId/local_storage/size .localStorageSize() 🕑
Get Sessionstorage GET /session/:sessionId/session_storage .sessionStorage() 🕑
Set Sessionstorage POST /session/:sessionId/session_storage .sessionStorage() 🕑
Clear Sessionstorage DELETE /session/:sessionId/session_storage .sessionStorage() 🕑
Get Sessionstorage Item GET /session/:sessionId/session_storage/key/:key .sessionStorage() 🕑
Set Sessionstorage Item DELETE /session/:sessionId/session_storage/key/:key .sessionStorage() 🕑
Get Sessionstorage Size GET /session/:sessionId/session_storage/size .sessionStorageSize() 🕑

Logs

Command Name API Endpoint wdio API Status
Get Log POST /session/:sessionId/log .log() 🕑
Get Log Types GET /session/:sessionId/log/types .logTypes() 🕑

Application Cache

Command Name API Endpoint wdio API Status
Get Application Cache Status GET /session/:sessionId/application_cache/status .applicationCacheStatus() 🕑

Readme

Keywords

Package Sidebar

Install

npm i web-driverify

Weekly Downloads

2

Version

1.1.3

License

MIT

Last publish

Collaborators

  • harttle
  • oott123