Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 17 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
# wd-sync

**A synchronous version with a nice api of [wd](http://github.com/admc/wd),
the lightweight [WebDriver / Selenium2](http://seleniumhq.org/projects/webdriver/)
**A synchronous version with a nice api of [wd](http://github.com/admc/wd),
the lightweight [WebDriver / Selenium2](http://seleniumhq.org/projects/webdriver/)
client for node.js, built using [node-fibers](http://github.com/laverdet/node-fibers).**

[Site](http://sebv.github.io/node-wd-sync/)

Note: headless zombie was removed in 1.1.0

"Raw" fork: This version is a drop-in replacement for the official [node-wd-sync](https://travis-ci.org/sebv/node-wd-sync) with one additional feature: In node-wd-sync, elements returned from synchronized methods are wrapped in synchronization code as well. This fork provides access to the original, untouched element, which you can reference via the `.rawElement` property in cases where you need to access the unmodified element. E.g.:

```
var element = browser.elementByCssSelector('#myElement');
browser.execute('arguments[0].className += " hidden"', [element.rawElement]);
```

## status

[![Build Status](https://travis-ci.org/sebv/node-wd-sync.png)](https://travis-ci.org/sebv/node-wd-sync)
Expand Down Expand Up @@ -55,7 +62,7 @@ sync ->

@quit()

```
```

### JavaScript

Expand Down Expand Up @@ -94,9 +101,9 @@ sync( function() {

});

```
```

## doc
## doc

* [CoffeeScript](http://github.com/sebv/node-wd-sync/blob/master/doc/COFFEE-DOC.md)
* [JavaScript](http://github.com/sebv/node-wd-sync/blob/master/doc/JS-DOC.md)
Expand All @@ -115,10 +122,10 @@ Note: Doc and README modifications must be done in the doc/template directory.
[supported](http://github.com/sebv/node-wd-sync/blob/master/doc/jsonwire-mapping.md)

[full JsonWireProtocol mapping](http://github.com/sebv/node-wd-sync/blob/master/doc/jsonwire-full-mapping.md)

## available environments

### WebDriver
### WebDriver

local [WebDriver / Selenium2](http://seleniumhq.org/projects/webdriver/) server

Expand All @@ -128,7 +135,7 @@ Remote testing with [Sauce Labs](http://saucelabs.com).

## running tests

### local / selenium server:
### local / selenium server:

1/ Install and start Selenium server

Expand All @@ -140,10 +147,10 @@ Remote testing with [Sauce Labs](http://saucelabs.com).

2/ run tests
```
make test
make test
```

### remote / Sauce Labs
### remote / Sauce Labs

1/ configure sauce environment
```
Expand Down
13 changes: 10 additions & 3 deletions lib/wd-sync.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,26 @@ wrapSync = (target) ->
do ->
target[k] = makeSync target[k], mode:['mixed', 'args']

# wrapping methods to make returned elements synchronous
# wrapping methods to make returned elements synchronous while keeping a reference to the raw element
wrappedTarget = {}
for k,v of target when (typeof v) is 'function'
do ->
_v = v
wrappedTarget[k] = (args...) ->
res = _v.apply target, args
# single element returned
res = wrapSync res if isElement res
if isElement res
raw = res
res = wrapSync res
res.rawElement = raw
# array element returned
if _(res).isArray()
res = _.map res, (val) ->
if isElement val then wrapSync val else val
if isElement val
raw = val
val = wrapSync val
val.rawElement = raw
val
res
wrappedTarget

Expand Down
11 changes: 7 additions & 4 deletions lib/wd-sync.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 15 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
{
"name": "wd-sync",
"name": "wd-sync-raw",
"version": "1.2.5",
"description": "sync version of wd using fibers.",
"description": "sync version of wd using fibers with .rawElement work-around for compatibility with .execute methods.",
"keywords": [
"selenium",
"webdriver",
"test",
"fibers",
"sync"
],
"author": "Seb Vincent <seb.vincent@gmail.com>",
"author": "Daniel Smedegaard Buus <danielbuus@gmail.com>",
"repository": {
"type": "git",
"url": "https://github.com/sebv/node-wd-sync.git"
"url": "git+https://github.com/DanielSmedegaardBuus/node-wd-sync.git"
},
"main": "./index",
"engine": "node >= 0.6.1",
Expand All @@ -36,5 +36,15 @@
"chai": "~1.8.1",
"hbs": "~2.4.0",
"request": "~2.27.0"
}
},
"bugs": {
"url": "https://github.com/DanielSmedegaardBuus/node-wd-sync/issues"
},
"homepage": "https://github.com/DanielSmedegaardBuus/node-wd-sync#readme",
"directories": {
"doc": "doc",
"example": "examples",
"test": "test"
},
"license": "ISC"
}