webdriverio/webdriverio — pull request #281 by nickyout (2014-08-22 22:18:47+00:00)
Title: Client side selectors

Hey, I've created client-side selector functionality. The point is to be able to use all the selectors both in node.js and in the browser. If I recall, you had some functions that would only accept css selectors. So maybe this addition can straighten that up.

Furthermore, I believe this could make it much easier to compensate for lacking driver features with javascript on the client side. More specifically:
* I wanted to be able to scroll inside a div.
* I was still thinking about ways of simulating drag and drop. Perhaps using [jquery-simulate](https://github.com/jquery/jquery-simulate) with a heavily stripped down jquery build. Who knows, it might work.

It includes a polyfill for evaluate for IE, the smallest I could find. I haven't actually tested the polyfill in IE, but I suppose your Travis setup would take care of that, right? Anyway, I've made some tests and tried to mimic the documenting style you have laid down so far.

So I would like to discuss whether or not to add this, and what the API would look like. Or if you're still missing something here.

About the API, I'm not entirely sure what looks the best, but what I did now was the following: `client.selectorExecute(selectors, script, ...args)`

So, use cases:
```javascript
client.selectorExecute('//div', function(divs, message) {
return divs.length + message;
}, " divs on the page", callback);
// returns, for example, "45 divs on the page"

client.selectorExecute(['//div', '[class="navbar"]', function(divs, navbars, message1, message2) {
return divs.length + message1 + navbars.length + message2;
}, " divs on the page and ", " navbars on the page", callback);
// returns, for example, "45 divs on the page and 2 navbars on the page"
````

Seeing as selectors always go first, I put them before the function. However, seeing that all arguments always go after the function, perhaps it should go after it. Assuming you agree with the implementation. It also returns the result.value of execute as its result. So, while convenient, it's not very consistent.

Also, I kind of used tabs instead of spaces. If you insist, I can replace them for you.