mirror of
https://github.com/sstent/node.git
synced 2026-03-15 01:15:45 +00:00
first post
This commit is contained in:
2
Nodejs-Socketio-Mysql-Demo/node_modules/wd/.npmignore
generated
vendored
Normal file
2
Nodejs-Socketio-Mysql-Demo/node_modules/wd/.npmignore
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
node_modules
|
||||
.DS_Store
|
||||
15
Nodejs-Socketio-Mysql-Demo/node_modules/wd/LICENSE.APACHE2
generated
vendored
Normal file
15
Nodejs-Socketio-Mysql-Demo/node_modules/wd/LICENSE.APACHE2
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
Apache License, Version 2.0
|
||||
|
||||
Copyright (c) 2012 Sauce Labs
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
33
Nodejs-Socketio-Mysql-Demo/node_modules/wd/Makefile
generated
vendored
Normal file
33
Nodejs-Socketio-Mysql-Demo/node_modules/wd/Makefile
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
TEST_DIR = test/common test/unit test/saucelabs
|
||||
TEST_COFFEE_FILES = $(shell find test/common/*.coffee test/unit/*.coffee test/saucelabs/*.coffee)
|
||||
|
||||
DEFAULT:
|
||||
@echo
|
||||
@echo ' make test -> run the unit tests (start selenium with chromedriver first).'
|
||||
@echo ' make test_saucelabs -> run the saucelabs tests (configure username/access_key first).'
|
||||
@echo ' make compile2js -> compile coffee files to js.'
|
||||
@echo ' make compile2js_watch -> compile coffee files to js, watch for changes.'
|
||||
@echo ' make cleanGenJs -> clean js files generated from coffeescript.'
|
||||
@echo
|
||||
|
||||
|
||||
# run test, start selenium server first
|
||||
test:
|
||||
./node_modules/.bin/nodeunit test/unit/*-test.coffee
|
||||
|
||||
# run saucelabs test, configure username/key first
|
||||
test_saucelabs:
|
||||
./node_modules/.bin/nodeunit test/saucelabs/*-test.coffee
|
||||
|
||||
# remove all the generated js
|
||||
cleanGenJs:
|
||||
@rm -f test/common/*.js test/unit/*.js test/saucelabs/*.js
|
||||
|
||||
# compile once
|
||||
compile2js:
|
||||
@./node_modules/.bin/coffee --compile $(TEST_DIR)
|
||||
# compile, and then watch for changes
|
||||
compile2js_watch:
|
||||
./node_modules/.bin/coffee --compile --watch $(TEST_DIR)
|
||||
|
||||
.PHONY: test compile2js compile2js_watch cleanGenJs DEFAULT
|
||||
612
Nodejs-Socketio-Mysql-Demo/node_modules/wd/README.md
generated
vendored
Normal file
612
Nodejs-Socketio-Mysql-Demo/node_modules/wd/README.md
generated
vendored
Normal file
@@ -0,0 +1,612 @@
|
||||
# WD.js -- A light weight WebDriver/Se2 client for node.js
|
||||
|
||||
## Update node to latest
|
||||
|
||||
http://nodejs.org/#download
|
||||
|
||||
## Install
|
||||
|
||||
<pre>
|
||||
npm install wd
|
||||
</pre>
|
||||
|
||||
## Authors
|
||||
|
||||
- Adam Christian ([admc](http://github.com/admc))
|
||||
- Ruben Daniels ([javruben](https://github.com/javruben))
|
||||
- Peter Braden ([peterbraden](https://github.com/peterbraden))
|
||||
- Seb Vincent ([sebv](https://github.com/sebv))
|
||||
|
||||
## License
|
||||
|
||||
* License - Apache 2: http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
## Usage
|
||||
|
||||
<pre>
|
||||
): wd shell
|
||||
> x = wd.remote() or wd.remote("ondemand.saucelabs.com", 80, "username", "apikey")
|
||||
|
||||
> x.init() or x.init({desired capabilities ovveride})
|
||||
> x.get("http://www.url.com")
|
||||
> x.eval("window.location.href", function(e, o) { console.log(o) })
|
||||
> x.quit()
|
||||
</pre>
|
||||
|
||||
|
||||
## Writing a test!
|
||||
|
||||
<pre>
|
||||
var webdriver = require('wd')
|
||||
, assert = require('assert');
|
||||
|
||||
var browser = webdriver.remote();
|
||||
|
||||
browser.on('status', function(info){
|
||||
console.log('\x1b[36m%s\x1b[0m', info);
|
||||
});
|
||||
browser.on('command', function(meth, path){
|
||||
console.log(' > \x1b[33m%s\x1b[0m: %s', meth, path);
|
||||
});
|
||||
|
||||
desired = {
|
||||
browserName:'chrome'
|
||||
, tags: ["examples"]
|
||||
, name = "This is an example test"
|
||||
}
|
||||
|
||||
browser.init(desired, function() {
|
||||
browser.get("http://saucelabs.com/test/guinea-pig", function() {
|
||||
browser.title(function(err, title) {
|
||||
assert.ok(~title.indexOf('I am a page title - Sauce Labs'), 'Wrong title!');
|
||||
browser.elementById('submit', function(err, el) {
|
||||
browser.clickElement(el, function() {
|
||||
browser.eval("window.location.href", function(err, title) {
|
||||
assert.ok(~title.indexOf('#'), 'Wrong title!');
|
||||
browser.quit()
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
</pre>
|
||||
|
||||
## Supported Methods
|
||||
|
||||
<table class="wikitable">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td width="50%" style="border: 1px solid #ccc; padding: 5px;">
|
||||
<strong>JsonWireProtocol</strong>
|
||||
</td>
|
||||
<td width="50%" style="border: 1px solid #ccc; padding: 5px;">
|
||||
<strong>wd</strong>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
GET <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#GET_/status">/status</a><br>
|
||||
Query the server's current status.
|
||||
</td>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
status(cb) -> cb(err, status)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
POST <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#POST_/session">/session</a><br>
|
||||
Create a new session.
|
||||
</td>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
init(desired, cb) -> cb(err, sessionID)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
GET <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#GET_/sessions">/sessions</a><br>
|
||||
Returns a list of the currently active sessions.
|
||||
</td>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
<ul>
|
||||
<li>all sessions: sessions(cb) -> cb(err, sessions)</li>
|
||||
<li>
|
||||
current session: <br>
|
||||
altSessionCapabilities(cb) -> cb(err, capabilities)
|
||||
</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
GET <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#GET_/session/:sessionId">/session/:sessionId</a><br>
|
||||
Retrieve the capabilities of the specified session.
|
||||
</td>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
sessionCapabilities(cb) -> cb(err, capabilities)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
DELETE <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#DELETE_/session/:sessionId">/session/:sessionId</a><br>
|
||||
Delete the session.
|
||||
</td>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
quit(cb) -> cb(err)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
POST <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#POST_/session/:sessionId/timeouts">/session/:sessionId/timeouts</a><br>
|
||||
Configure the amount of time that a particular type of operation can execute for before they are aborted and a |Timeout| error is returned to the client.
|
||||
</td>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
<ul>
|
||||
<li>
|
||||
configurable type: NA (but setImplicitWaitTimeout and
|
||||
setAsyncScriptTimeout do the same)
|
||||
</li>
|
||||
<li>
|
||||
page load timeout: <br>
|
||||
setPageLoadTimeout(ms, cb) -> cb(err)
|
||||
</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
POST <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#POST_/session/:sessionId/timeouts/async_script">/session/:sessionId/timeouts/async_script</a><br>
|
||||
Set the amount of time, in milliseconds, that asynchronous scripts executed by <tt>/session/:sessionId/execute_async</tt> are permitted to run before they are aborted and a |Timeout| error is returned to the client.
|
||||
</td>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
setAsyncScriptTimeout(ms, cb) -> cb(err)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
POST <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#POST_/session/:sessionId/timeouts/implicit_wait">/session/:sessionId/timeouts/implicit_wait</a><br>
|
||||
Set the amount of time the driver should wait when searching for elements.
|
||||
</td>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
setImplicitWaitTimeout(ms, cb) -> cb(err)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
GET <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#GET_/session/:sessionId/url">/session/:sessionId/url</a><br>
|
||||
Retrieve the URL of the current page.
|
||||
</td>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
url(cb) -> cb(err, url)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
POST <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#POST_/session/:sessionId/url">/session/:sessionId/url</a><br>
|
||||
Navigate to a new URL.
|
||||
</td>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
get(url,cb) -> cb(err)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
POST <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#POST_/session/:sessionId/forward">/session/:sessionId/forward</a><br>
|
||||
Navigate forwards in the browser history, if possible.
|
||||
</td>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
forward(cb) -> cb(err)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
POST <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#POST_/session/:sessionId/back">/session/:sessionId/back</a><br>
|
||||
Navigate backwards in the browser history, if possible.
|
||||
</td>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
back(cb) -> cb(err)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
POST <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#POST_/session/:sessionId/refresh">/session/:sessionId/refresh</a><br>
|
||||
Refresh the current page.
|
||||
</td>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
refresh(cb) -> cb(err)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
POST <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#POST_/session/:sessionId/execute">/session/:sessionId/execute</a><br>
|
||||
Inject a snippet of JavaScript into the page for execution in the context of the currently selected frame.
|
||||
</td>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
<ul>
|
||||
<li>
|
||||
execute script: <br>
|
||||
execute(code, args, cb) -> cb(err, value returned)
|
||||
<ul>
|
||||
<li>args is an optional Array</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
execute script within try/catch using eval(code): <br>
|
||||
safeExecute(code, args, cb) -> cb(err, value returned)
|
||||
<ul>
|
||||
<li>args is an optional Array</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
evaluate expression (using execute): <br>
|
||||
eval(code, cb) -> cb(err, value)
|
||||
</li>
|
||||
<li>
|
||||
evaluate expression (using safeExecute): <br>
|
||||
safeEval(code, cb) -> cb(err, value)
|
||||
</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
POST <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#POST_/session/:sessionId/execute_async">/session/:sessionId/execute_async</a><br>
|
||||
Inject a snippet of JavaScript into the page for execution in the context of the currently selected frame.
|
||||
</td>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
<ul>
|
||||
<li>
|
||||
execute async script: <br>
|
||||
executeAsync(code, args, cb) -> cb(err, value returned)
|
||||
<ul>
|
||||
<li>args is an optional Array</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
execute async script within try/catch using eval(code): <br>
|
||||
safeExecuteAsync(code, args, cb) -> cb(err, value returned)
|
||||
<ul>
|
||||
<li>args is an optional Array</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
DELETE <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#DELETE_/session/:sessionId/window">/session/:sessionId/window</a><br>
|
||||
Close the current window.
|
||||
</td>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
close(cb) -> cb(err)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
GET <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#GET_/session/:sessionId/cookie">/session/:sessionId/cookie</a><br>
|
||||
Retrieve all cookies visible to the current page.
|
||||
</td>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
allCookies() -> cb(err, cookies)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
POST <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#POST_/session/:sessionId/cookie">/session/:sessionId/cookie</a><br>
|
||||
Set a cookie.
|
||||
</td>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
setCookie(cookie, cb) -> cb(err)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
DELETE <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#DELETE_/session/:sessionId/cookie">/session/:sessionId/cookie</a><br>
|
||||
Delete all cookies visible to the current page.
|
||||
</td>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
deleteAllCookies(cb) -> cb(err)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
DELETE <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#DELETE_/session/:sessionId/cookie/:name">/session/:sessionId/cookie/:name</a><br>
|
||||
Delete the cookie with the given name.
|
||||
</td>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
deleteCookie(name, cb) -> cb(err)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
GET <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#GET_/session/:sessionId/title">/session/:sessionId/title</a><br>
|
||||
Get the current page title.
|
||||
</td>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
title(cb) -> cb(err, title)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
POST <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#POST_/session/:sessionId/element">/session/:sessionId/element</a><br>
|
||||
Search for an element on the page, starting from the document root.
|
||||
</td>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
<ul>
|
||||
<li>
|
||||
element(using, value, cb) -> cb(err, element) <br>
|
||||
</li>
|
||||
<li>
|
||||
element<i>suffix</i>(value, cb) -> cb(err, element) <br>
|
||||
<i>suffix:
|
||||
ByClassName, ByCssSelector, ById,
|
||||
ByName, ByLinkText, ByPartialLinkText,
|
||||
ByTagName, ByXPath, ByCss</i>
|
||||
</li>
|
||||
<li>
|
||||
see also hasElement, hasElement<i>suffix</i>, elementOrNull, element<i>suffix</i>OrNull,
|
||||
elementIfExists, element<i>suffix</i>IfExists, in the elements section.
|
||||
</li>
|
||||
<ul>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
POST <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#POST_/session/:sessionId/elements">/session/:sessionId/elements</a><br>
|
||||
Search for multiple elements on the page, starting from the document root.
|
||||
</td>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
<ul>
|
||||
<li>
|
||||
elements(using, value, cb) -> cb(err, elements) <br>
|
||||
</li>
|
||||
<li>
|
||||
elements<i>suffix</i>(value, cb) -> cb(err, elements) <br>
|
||||
<i>suffix:
|
||||
ByClassName, ByCssSelector, ById,
|
||||
ByName, ByLinkText, ByPartialLinkText,
|
||||
ByTagName, ByXPath, ByCss</i>
|
||||
</li>
|
||||
<li>
|
||||
hasElement(using, value, cb) -> cb(err, boolean) <br>
|
||||
</li>
|
||||
<li>
|
||||
hasElement<i>suffix</i>(value, cb) -> cb(err, boolean) <br>
|
||||
<i>suffix:
|
||||
ByClassName, ByCssSelector, ById,
|
||||
ByName, ByLinkText, ByPartialLinkText,
|
||||
ByTagName, ByXPath, ByCss</i>
|
||||
</li>
|
||||
<li>
|
||||
elementOrNull(using, value, cb) -> cb(err, element) <br>
|
||||
(avoids not found error throw and returns null instead)
|
||||
</li>
|
||||
<li>
|
||||
element<i>suffix</i>OrNull(value, cb) -> cb(err, element) <br>
|
||||
(avoids not found error throw and returns null instead) <br>
|
||||
<i>suffix:
|
||||
ByClassName, ByCssSelector, ById,
|
||||
ByName, ByLinkText, ByPartialLinkText,
|
||||
ByTagName, ByXPath, ByCss</i>
|
||||
</li>
|
||||
<li>
|
||||
elementIfExists(using, value, cb) -> cb(err, element) <br>
|
||||
(avoids not found error throw and returns undefined instead)
|
||||
</li>
|
||||
<li>
|
||||
element<i>suffix</i>IfExists(value, cb) -> cb(err, element) <br>
|
||||
(avoids not found error throw and returns undefined instead) <br>
|
||||
<i>suffix:
|
||||
ByClassName, ByCssSelector, ById,
|
||||
ByName, ByLinkText, ByPartialLinkText,
|
||||
ByTagName, ByXPath, ByCss</i>
|
||||
</li>
|
||||
<ul>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
POST <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#POST_/session/:sessionId/element/active">/session/:sessionId/element/active</a><br>
|
||||
Get the element on the page that currently has focus.
|
||||
</td>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
active(cb) -> cb(err, element)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
POST <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#POST_/session/:sessionId/element/:id/click">/session/:sessionId/element/:id/click</a><br>
|
||||
Click on an element.
|
||||
</td>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
clickElement(element, cb) -> cb(err)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
GET <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#GET_/session/:sessionId/element/:id/text">/session/:sessionId/element/:id/text</a><br>
|
||||
Returns the visible text for the element.
|
||||
</td>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
<ul>
|
||||
<li>
|
||||
text(element, cb) -> (err, text)
|
||||
</li>
|
||||
<li>
|
||||
textPresent(searchText, element, cb) -> (err, boolean)
|
||||
</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
POST <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#POST_/session/:sessionId/element/:id/value">/session/:sessionId/element/:id/value</a><br>
|
||||
Send a sequence of key strokes to an element.
|
||||
</td>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
<ul>
|
||||
<li>
|
||||
type(element, keys, cb) -> cb(err)
|
||||
</li>
|
||||
<li>
|
||||
special key map: wd.SPECIAL_KEYS (see lib/special-keys.js)
|
||||
</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
POST <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#POST_/session/:sessionId/keys">/session/:sessionId/keys</a><br>
|
||||
Send a sequence of key strokes to the active element.
|
||||
</td>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
<ul>
|
||||
<li>
|
||||
keys(keys, cb) -> cb(err)
|
||||
</li>
|
||||
<li>
|
||||
special key map: wd.SPECIAL_KEYS (see lib/special-keys.js)
|
||||
</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
POST <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#POST_/session/:sessionId/element/:id/clear">/session/:sessionId/element/:id/clear</a><br>
|
||||
Clear a <tt>TEXTAREA</tt> or <tt>text INPUT</tt> element's value.
|
||||
</td>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
clear(element, cb) -> cb(err)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
GET <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#GET_/session/:sessionId/element/:id/attribute/:name">/session/:sessionId/element/:id/attribute/:name</a><br>
|
||||
Get the value of an element's attribute.
|
||||
</td>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
<ul>
|
||||
<li>
|
||||
getAttribute(element, attrName, cb) -> cb(err, value)
|
||||
</li>
|
||||
<li>
|
||||
getValue(element, cb) -> cb(err, value)
|
||||
</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
POST <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#POST_/session/:sessionId/accept_alert">/session/:sessionId/accept_alert</a><br>
|
||||
Accepts the currently displayed alert dialog.
|
||||
</td>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
acceptAlert(cb) -> cb(err)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
POST <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#POST_/session/:sessionId/dismiss_alert">/session/:sessionId/dismiss_alert</a><br>
|
||||
Dismisses the currently displayed alert dialog.
|
||||
</td>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
dismissAlert(cb) -> cb(err)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
POST <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#POST_/session/:sessionId/moveto">/session/:sessionId/moveto</a><br>
|
||||
Move the mouse by an offset of the specificed element.
|
||||
</td>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
moveTo(element, xoffset, yoffset, cb) -> cb(err)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
POST <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#POST_/session/:sessionId/click">/session/:sessionId/click</a><br>
|
||||
Click any mouse button (at the coordinates set by the last moveto command).
|
||||
</td>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
click(button, cb) -> cb(err) <br>
|
||||
buttons: {left: 0, middle: 1 , right: 2}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
POST <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#POST_/session/:sessionId/buttondown">/session/:sessionId/buttondown</a><br>
|
||||
Click and hold the left mouse button (at the coordinates set by the last moveto command).
|
||||
</td>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
buttonDown(cb) -> cb(err)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
POST <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#POST_/session/:sessionId/buttonup">/session/:sessionId/buttonup</a><br>
|
||||
Releases the mouse button previously held (where the mouse is currently at).
|
||||
</td>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
buttonUp(cb) -> cb(err)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
POST <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#POST_/session/:sessionId/doubleclick">/session/:sessionId/doubleclick</a><br>
|
||||
Double-clicks at the current mouse coordinates (set by moveto).
|
||||
</td>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
doubleclick(cb) -> cb(err) <br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
EXTRA: waitForCondition<br>
|
||||
Waits for JavaScript condition to be true (polling within wd client).
|
||||
</td>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
waitForCondition(conditionExpr, timeout, pollFreq, cb) -> cb(err, boolean)
|
||||
<ul>
|
||||
<li>conditionExpr should return a boolean</li>
|
||||
<li>timeout and pollFreq are optional (default: 1000, 100).</li>
|
||||
<li>return true if condition satisfied, error otherwise.</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
EXTRA: waitForConditionInBrowser<br>
|
||||
Waits for JavaScript condition to be true. (async script polling within browser)
|
||||
</td>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
waitForConditionInBrowser(conditionExpr, timeout, pollFreq, cb) -> cb(err, boolean)
|
||||
<ul>
|
||||
<li>setAsyncScriptTimeout must be set to value higher than timeout</li>
|
||||
<li>conditionExpr should return a boolean</li>
|
||||
<li>timeout and pollFreq are optional (default: 1000, 100).</li>
|
||||
<li>return true if condition satisfied, error otherwise.</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
### Full JsonWireProtocol mapping:
|
||||
|
||||
[full mapping](https://github.com/sebv/wd/blob/master/doc/jsonwiremap-all.md)
|
||||
|
||||
## More docs!
|
||||
<pre>
|
||||
WD is simply implementing the Selenium JsonWireProtocol, for more details see the official docs:
|
||||
- <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol">http://code.google.com/p/selenium/wiki/JsonWireProtocol</a>
|
||||
</pre>
|
||||
|
||||
## Run the tests!
|
||||
<pre>
|
||||
- Run the selenium server with chromedriver:
|
||||
java -jar selenium-server-standalone-2.21.0.jar -Dwebdriver.chrome.driver=<PATH>/chromedriver
|
||||
- cd wd
|
||||
- npm install .
|
||||
- make test
|
||||
- look at the results!
|
||||
</pre>
|
||||
1029
Nodejs-Socketio-Mysql-Demo/node_modules/wd/doc/jsonwiremap-all.md
generated
vendored
Normal file
1029
Nodejs-Socketio-Mysql-Demo/node_modules/wd/doc/jsonwiremap-all.md
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
516
Nodejs-Socketio-Mysql-Demo/node_modules/wd/doc/jsonwiremap-supported.md
generated
vendored
Normal file
516
Nodejs-Socketio-Mysql-Demo/node_modules/wd/doc/jsonwiremap-supported.md
generated
vendored
Normal file
@@ -0,0 +1,516 @@
|
||||
<table class="wikitable">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td width="50%" style="border: 1px solid #ccc; padding: 5px;">
|
||||
<strong>JsonWireProtocol</strong>
|
||||
</td>
|
||||
<td width="50%" style="border: 1px solid #ccc; padding: 5px;">
|
||||
<strong>wd</strong>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
GET <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#GET_/status">/status</a><br>
|
||||
Query the server's current status.
|
||||
</td>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
status(cb) -> cb(err, status)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
POST <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#POST_/session">/session</a><br>
|
||||
Create a new session.
|
||||
</td>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
init(desired, cb) -> cb(err, sessionID)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
GET <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#GET_/sessions">/sessions</a><br>
|
||||
Returns a list of the currently active sessions.
|
||||
</td>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
<ul>
|
||||
<li>all sessions: sessions(cb) -> cb(err, sessions)</li>
|
||||
<li>
|
||||
current session: <br>
|
||||
altSessionCapabilities(cb) -> cb(err, capabilities)
|
||||
</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
GET <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#GET_/session/:sessionId">/session/:sessionId</a><br>
|
||||
Retrieve the capabilities of the specified session.
|
||||
</td>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
sessionCapabilities(cb) -> cb(err, capabilities)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
DELETE <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#DELETE_/session/:sessionId">/session/:sessionId</a><br>
|
||||
Delete the session.
|
||||
</td>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
quit(cb) -> cb(err)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
POST <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#POST_/session/:sessionId/timeouts">/session/:sessionId/timeouts</a><br>
|
||||
Configure the amount of time that a particular type of operation can execute for before they are aborted and a |Timeout| error is returned to the client.
|
||||
</td>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
<ul>
|
||||
<li>
|
||||
configurable type: NA (but setImplicitWaitTimeout and
|
||||
setAsyncScriptTimeout do the same)
|
||||
</li>
|
||||
<li>
|
||||
page load timeout: <br>
|
||||
setPageLoadTimeout(ms, cb) -> cb(err)
|
||||
</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
POST <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#POST_/session/:sessionId/timeouts/async_script">/session/:sessionId/timeouts/async_script</a><br>
|
||||
Set the amount of time, in milliseconds, that asynchronous scripts executed by <tt>/session/:sessionId/execute_async</tt> are permitted to run before they are aborted and a |Timeout| error is returned to the client.
|
||||
</td>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
setAsyncScriptTimeout(ms, cb) -> cb(err)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
POST <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#POST_/session/:sessionId/timeouts/implicit_wait">/session/:sessionId/timeouts/implicit_wait</a><br>
|
||||
Set the amount of time the driver should wait when searching for elements.
|
||||
</td>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
setImplicitWaitTimeout(ms, cb) -> cb(err)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
GET <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#GET_/session/:sessionId/url">/session/:sessionId/url</a><br>
|
||||
Retrieve the URL of the current page.
|
||||
</td>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
url(cb) -> cb(err, url)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
POST <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#POST_/session/:sessionId/url">/session/:sessionId/url</a><br>
|
||||
Navigate to a new URL.
|
||||
</td>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
get(url,cb) -> cb(err)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
POST <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#POST_/session/:sessionId/forward">/session/:sessionId/forward</a><br>
|
||||
Navigate forwards in the browser history, if possible.
|
||||
</td>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
forward(cb) -> cb(err)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
POST <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#POST_/session/:sessionId/back">/session/:sessionId/back</a><br>
|
||||
Navigate backwards in the browser history, if possible.
|
||||
</td>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
back(cb) -> cb(err)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
POST <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#POST_/session/:sessionId/refresh">/session/:sessionId/refresh</a><br>
|
||||
Refresh the current page.
|
||||
</td>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
refresh(cb) -> cb(err)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
POST <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#POST_/session/:sessionId/execute">/session/:sessionId/execute</a><br>
|
||||
Inject a snippet of JavaScript into the page for execution in the context of the currently selected frame.
|
||||
</td>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
<ul>
|
||||
<li>
|
||||
execute script: <br>
|
||||
execute(code, args, cb) -> cb(err, value returned)
|
||||
<ul>
|
||||
<li>args is an optional Array</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
execute script within try/catch using eval(code): <br>
|
||||
safeExecute(code, args, cb) -> cb(err, value returned)
|
||||
<ul>
|
||||
<li>args is an optional Array</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
evaluate expression (using execute): <br>
|
||||
eval(code, cb) -> cb(err, value)
|
||||
</li>
|
||||
<li>
|
||||
evaluate expression (using safeExecute): <br>
|
||||
safeEval(code, cb) -> cb(err, value)
|
||||
</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
POST <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#POST_/session/:sessionId/execute_async">/session/:sessionId/execute_async</a><br>
|
||||
Inject a snippet of JavaScript into the page for execution in the context of the currently selected frame.
|
||||
</td>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
<ul>
|
||||
<li>
|
||||
execute async script: <br>
|
||||
executeAsync(code, args, cb) -> cb(err, value returned)
|
||||
<ul>
|
||||
<li>args is an optional Array</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
execute async script within try/catch using eval(code): <br>
|
||||
safeExecuteAsync(code, args, cb) -> cb(err, value returned)
|
||||
<ul>
|
||||
<li>args is an optional Array</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
DELETE <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#DELETE_/session/:sessionId/window">/session/:sessionId/window</a><br>
|
||||
Close the current window.
|
||||
</td>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
close(cb) -> cb(err)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
GET <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#GET_/session/:sessionId/cookie">/session/:sessionId/cookie</a><br>
|
||||
Retrieve all cookies visible to the current page.
|
||||
</td>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
allCookies() -> cb(err, cookies)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
POST <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#POST_/session/:sessionId/cookie">/session/:sessionId/cookie</a><br>
|
||||
Set a cookie.
|
||||
</td>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
setCookie(cookie, cb) -> cb(err)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
DELETE <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#DELETE_/session/:sessionId/cookie">/session/:sessionId/cookie</a><br>
|
||||
Delete all cookies visible to the current page.
|
||||
</td>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
deleteAllCookies(cb) -> cb(err)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
DELETE <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#DELETE_/session/:sessionId/cookie/:name">/session/:sessionId/cookie/:name</a><br>
|
||||
Delete the cookie with the given name.
|
||||
</td>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
deleteCookie(name, cb) -> cb(err)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
GET <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#GET_/session/:sessionId/title">/session/:sessionId/title</a><br>
|
||||
Get the current page title.
|
||||
</td>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
title(cb) -> cb(err, title)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
POST <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#POST_/session/:sessionId/element">/session/:sessionId/element</a><br>
|
||||
Search for an element on the page, starting from the document root.
|
||||
</td>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
<ul>
|
||||
<li>
|
||||
element(using, value, cb) -> cb(err, element) <br>
|
||||
</li>
|
||||
<li>
|
||||
element<i>suffix</i>(value, cb) -> cb(err, element) <br>
|
||||
<i>suffix:
|
||||
ByClassName, ByCssSelector, ById,
|
||||
ByName, ByLinkText, ByPartialLinkText,
|
||||
ByTagName, ByXPath, ByCss</i>
|
||||
</li>
|
||||
<li>
|
||||
see also hasElement, hasElement<i>suffix</i>, elementOrNull, element<i>suffix</i>OrNull,
|
||||
elementIfExists, element<i>suffix</i>IfExists, in the elements section.
|
||||
</li>
|
||||
<ul>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
POST <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#POST_/session/:sessionId/elements">/session/:sessionId/elements</a><br>
|
||||
Search for multiple elements on the page, starting from the document root.
|
||||
</td>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
<ul>
|
||||
<li>
|
||||
elements(using, value, cb) -> cb(err, elements) <br>
|
||||
</li>
|
||||
<li>
|
||||
elements<i>suffix</i>(value, cb) -> cb(err, elements) <br>
|
||||
<i>suffix:
|
||||
ByClassName, ByCssSelector, ById,
|
||||
ByName, ByLinkText, ByPartialLinkText,
|
||||
ByTagName, ByXPath, ByCss</i>
|
||||
</li>
|
||||
<li>
|
||||
hasElement(using, value, cb) -> cb(err, boolean) <br>
|
||||
</li>
|
||||
<li>
|
||||
hasElement<i>suffix</i>(value, cb) -> cb(err, boolean) <br>
|
||||
<i>suffix:
|
||||
ByClassName, ByCssSelector, ById,
|
||||
ByName, ByLinkText, ByPartialLinkText,
|
||||
ByTagName, ByXPath, ByCss</i>
|
||||
</li>
|
||||
<li>
|
||||
elementOrNull(using, value, cb) -> cb(err, element) <br>
|
||||
(avoids not found error throw and returns null instead)
|
||||
</li>
|
||||
<li>
|
||||
element<i>suffix</i>OrNull(value, cb) -> cb(err, element) <br>
|
||||
(avoids not found error throw and returns null instead) <br>
|
||||
<i>suffix:
|
||||
ByClassName, ByCssSelector, ById,
|
||||
ByName, ByLinkText, ByPartialLinkText,
|
||||
ByTagName, ByXPath, ByCss</i>
|
||||
</li>
|
||||
<li>
|
||||
elementIfExists(using, value, cb) -> cb(err, element) <br>
|
||||
(avoids not found error throw and returns undefined instead)
|
||||
</li>
|
||||
<li>
|
||||
element<i>suffix</i>IfExists(value, cb) -> cb(err, element) <br>
|
||||
(avoids not found error throw and returns undefined instead) <br>
|
||||
<i>suffix:
|
||||
ByClassName, ByCssSelector, ById,
|
||||
ByName, ByLinkText, ByPartialLinkText,
|
||||
ByTagName, ByXPath, ByCss</i>
|
||||
</li>
|
||||
<ul>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
POST <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#POST_/session/:sessionId/element/active">/session/:sessionId/element/active</a><br>
|
||||
Get the element on the page that currently has focus.
|
||||
</td>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
active(cb) -> cb(err, element)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
POST <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#POST_/session/:sessionId/element/:id/click">/session/:sessionId/element/:id/click</a><br>
|
||||
Click on an element.
|
||||
</td>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
clickElement(element, cb) -> cb(err)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
GET <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#GET_/session/:sessionId/element/:id/text">/session/:sessionId/element/:id/text</a><br>
|
||||
Returns the visible text for the element.
|
||||
</td>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
<ul>
|
||||
<li>
|
||||
text(element, cb) -> (err, text)
|
||||
</li>
|
||||
<li>
|
||||
textPresent(searchText, element, cb) -> (err, boolean)
|
||||
</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
POST <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#POST_/session/:sessionId/element/:id/value">/session/:sessionId/element/:id/value</a><br>
|
||||
Send a sequence of key strokes to an element.
|
||||
</td>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
<ul>
|
||||
<li>
|
||||
type(element, keys, cb) -> cb(err)
|
||||
</li>
|
||||
<li>
|
||||
special key map: wd.SPECIAL_KEYS (see lib/special-keys.js)
|
||||
</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
POST <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#POST_/session/:sessionId/keys">/session/:sessionId/keys</a><br>
|
||||
Send a sequence of key strokes to the active element.
|
||||
</td>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
<ul>
|
||||
<li>
|
||||
keys(keys, cb) -> cb(err)
|
||||
</li>
|
||||
<li>
|
||||
special key map: wd.SPECIAL_KEYS (see lib/special-keys.js)
|
||||
</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
POST <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#POST_/session/:sessionId/element/:id/clear">/session/:sessionId/element/:id/clear</a><br>
|
||||
Clear a <tt>TEXTAREA</tt> or <tt>text INPUT</tt> element's value.
|
||||
</td>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
clear(element, cb) -> cb(err)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
GET <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#GET_/session/:sessionId/element/:id/attribute/:name">/session/:sessionId/element/:id/attribute/:name</a><br>
|
||||
Get the value of an element's attribute.
|
||||
</td>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
<ul>
|
||||
<li>
|
||||
getAttribute(element, attrName, cb) -> cb(err, value)
|
||||
</li>
|
||||
<li>
|
||||
getValue(element, cb) -> cb(err, value)
|
||||
</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
POST <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#POST_/session/:sessionId/accept_alert">/session/:sessionId/accept_alert</a><br>
|
||||
Accepts the currently displayed alert dialog.
|
||||
</td>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
acceptAlert(cb) -> cb(err)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
POST <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#POST_/session/:sessionId/dismiss_alert">/session/:sessionId/dismiss_alert</a><br>
|
||||
Dismisses the currently displayed alert dialog.
|
||||
</td>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
dismissAlert(cb) -> cb(err)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
POST <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#POST_/session/:sessionId/moveto">/session/:sessionId/moveto</a><br>
|
||||
Move the mouse by an offset of the specificed element.
|
||||
</td>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
moveTo(element, xoffset, yoffset, cb) -> cb(err)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
POST <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#POST_/session/:sessionId/click">/session/:sessionId/click</a><br>
|
||||
Click any mouse button (at the coordinates set by the last moveto command).
|
||||
</td>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
click(button, cb) -> cb(err) <br>
|
||||
buttons: {left: 0, middle: 1 , right: 2}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
POST <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#POST_/session/:sessionId/buttondown">/session/:sessionId/buttondown</a><br>
|
||||
Click and hold the left mouse button (at the coordinates set by the last moveto command).
|
||||
</td>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
buttonDown(cb) -> cb(err)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
POST <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#POST_/session/:sessionId/buttonup">/session/:sessionId/buttonup</a><br>
|
||||
Releases the mouse button previously held (where the mouse is currently at).
|
||||
</td>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
buttonUp(cb) -> cb(err)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
POST <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#POST_/session/:sessionId/doubleclick">/session/:sessionId/doubleclick</a><br>
|
||||
Double-clicks at the current mouse coordinates (set by moveto).
|
||||
</td>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
doubleclick(cb) -> cb(err) <br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
EXTRA: waitForCondition<br>
|
||||
Waits for JavaScript condition to be true (polling within wd client).
|
||||
</td>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
waitForCondition(conditionExpr, timeout, pollFreq, cb) -> cb(err, boolean)
|
||||
<ul>
|
||||
<li>conditionExpr should return a boolean</li>
|
||||
<li>timeout and pollFreq are optional (default: 1000, 100).</li>
|
||||
<li>return true if condition satisfied, error otherwise.</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
EXTRA: waitForConditionInBrowser<br>
|
||||
Waits for JavaScript condition to be true. (async script polling within browser)
|
||||
</td>
|
||||
<td style="border: 1px solid #ccc; padding: 5px;">
|
||||
waitForConditionInBrowser(conditionExpr, timeout, pollFreq, cb) -> cb(err, boolean)
|
||||
<ul>
|
||||
<li>setAsyncScriptTimeout must be set to value higher than timeout</li>
|
||||
<li>conditionExpr should return a boolean</li>
|
||||
<li>timeout and pollFreq are optional (default: 1000, 100).</li>
|
||||
<li>return true if condition satisfied, error otherwise.</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
24
Nodejs-Socketio-Mysql-Demo/node_modules/wd/doc/supported-methods-old.md
generated
vendored
Normal file
24
Nodejs-Socketio-Mysql-Demo/node_modules/wd/doc/supported-methods-old.md
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
From previous version of README
|
||||
|
||||
## Supported Methods
|
||||
|
||||
<pre>
|
||||
- 'close': Close the browser
|
||||
- 'quit': Quit the session
|
||||
- 'eval': Eval JS and return the value (takes a code string)
|
||||
- 'execute': Eval JS (takes a code string)
|
||||
- 'executeAsync': Execute JS in an async way (takes a code string)
|
||||
- 'get': Navigate the browser to the provided url (takes a URL)
|
||||
- 'setWaitTimeout': Set the implicit wait timeout in milliseonds (takes wait time in ms)
|
||||
- 'element': Access an element in the page (takes 'using' and 'value' so ex: 'id', 'idofelement')
|
||||
- 'moveTo': Move an element on the page (takes element, xoffset and yoffset'
|
||||
- 'scroll': Scroll on an element (takes element, xoffset, yoffset)
|
||||
- 'buttonDown': Click and hold the left mouse button down, at the coords of the last moveTo
|
||||
- 'buttonUp': Release the left mouse button
|
||||
- 'click': Click a mouse button, at the coords of the last moveTo (takes a button param for {LEFT = 0, MIDDLE = 1 , RIGHT = 2})
|
||||
- 'doubleClick': Double click a mouse button, same coords as click
|
||||
- 'type': Type! (takes an element, a key character, or an array of char keys)
|
||||
- 'active': Get the element on the page currently with focus
|
||||
- 'keyToggle': Press a keyboard key (takes an element and a key character'
|
||||
- 'setCookie': Sets a <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#Cookie_JSON_Object">cookie</a>
|
||||
</pre>
|
||||
37
Nodejs-Socketio-Mysql-Demo/node_modules/wd/examples/example.chrome.js
generated
vendored
Normal file
37
Nodejs-Socketio-Mysql-Demo/node_modules/wd/examples/example.chrome.js
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
var webdriver;
|
||||
try {
|
||||
webdriver = require('wd');
|
||||
} catch( err ) {
|
||||
webdriver = require('../lib/main');
|
||||
}
|
||||
var assert = require('assert');
|
||||
var browser = webdriver.remote();
|
||||
|
||||
browser.on('status', function(info){
|
||||
console.log('\x1b[36m%s\x1b[0m', info);
|
||||
});
|
||||
|
||||
browser.on('command', function(meth, path){
|
||||
console.log(' > \x1b[33m%s\x1b[0m: %s', meth, path);
|
||||
});
|
||||
|
||||
browser.init({
|
||||
browserName:'chrome'
|
||||
, tags : ["examples"]
|
||||
, name: "This is an example test"
|
||||
}, function() {
|
||||
|
||||
browser.get("http://saucelabs.com/test/guinea-pig", function() {
|
||||
browser.title(function(err, title) {
|
||||
assert.ok(~title.indexOf('I am a page title - Sauce Labs'), 'Wrong title!');
|
||||
browser.elementById('submit', function(err, el) {
|
||||
browser.clickElement(el, function() {
|
||||
browser.eval("window.location.href", function(err, title) {
|
||||
assert.ok(~title.indexOf('#'), 'Wrong title!');
|
||||
browser.quit()
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
44
Nodejs-Socketio-Mysql-Demo/node_modules/wd/examples/example.ondemand.ie.js
generated
vendored
Normal file
44
Nodejs-Socketio-Mysql-Demo/node_modules/wd/examples/example.ondemand.ie.js
generated
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
// CONFIGURE SAUCE CREDENTIALS HERE
|
||||
var username = "<USERNAME>",
|
||||
accessKey = "<ACCESS_KEY>";
|
||||
|
||||
var webdriver;
|
||||
try {
|
||||
webdriver = require('wd');
|
||||
} catch( err ) {
|
||||
webdriver = require('../lib/main');
|
||||
}
|
||||
var assert = require('assert');
|
||||
var browser = webdriver.remote("ondemand.saucelabs.com", 80, username, accessKey);
|
||||
|
||||
browser.on('status', function(info){
|
||||
console.log('\x1b[36m%s\x1b[0m', info);
|
||||
});
|
||||
|
||||
browser.on('command', function(meth, path){
|
||||
console.log(' > \x1b[33m%s\x1b[0m: %s', meth, path);
|
||||
});
|
||||
|
||||
var desired = {
|
||||
browserName:'iexplore'
|
||||
, version:'9'
|
||||
, platform:'Windows 2008'
|
||||
, tags: ["examples"]
|
||||
, name: "This is an example test"
|
||||
}
|
||||
|
||||
browser.init( desired, function() {
|
||||
browser.get("http://saucelabs.com/test/guinea-pig", function() {
|
||||
browser.title(function(err, title) {
|
||||
assert.ok(~title.indexOf('I am a page title - Sauce Labs'), 'Wrong title!');
|
||||
browser.elementById('submit', function(err, el) {
|
||||
browser.clickElement(el, function() {
|
||||
browser.eval("window.location.href", function(err, title) {
|
||||
assert.ok(~title.indexOf('#'), 'Wrong title!');
|
||||
browser.quit()
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
42
Nodejs-Socketio-Mysql-Demo/node_modules/wd/examples/example.ondemand.js
generated
vendored
Normal file
42
Nodejs-Socketio-Mysql-Demo/node_modules/wd/examples/example.ondemand.js
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
// CONFIGURE SAUCE CREDENTIALS HERE
|
||||
var username = "<USERNAME>",
|
||||
accessKey = "<ACCESS_KEY>";
|
||||
|
||||
var webdriver;
|
||||
try {
|
||||
webdriver = require('wd');
|
||||
} catch( err ) {
|
||||
webdriver = require('../lib/main');
|
||||
}
|
||||
var assert = require('assert');
|
||||
|
||||
var browser = webdriver.remote("ondemand.saucelabs.com", 80, username, accessKey);
|
||||
|
||||
browser.on('status', function(info){
|
||||
console.log('\x1b[36m%s\x1b[0m', info);
|
||||
});
|
||||
|
||||
browser.on('command', function(meth, path){
|
||||
console.log(' > \x1b[33m%s\x1b[0m: %s', meth, path);
|
||||
});
|
||||
|
||||
var desired = {
|
||||
tags: ["examples"]
|
||||
, name: "This is an example test"
|
||||
}
|
||||
|
||||
browser.init(desired, function() {
|
||||
browser.get("http://saucelabs.com/test/guinea-pig", function() {
|
||||
browser.title(function(err, title) {
|
||||
assert.ok(~title.indexOf('I am a page title - Sauce Labs'), 'Wrong title!');
|
||||
browser.elementById('submit', function(err, el) {
|
||||
browser.clickElement(el, function() {
|
||||
browser.eval("window.location.href", function(err, title) {
|
||||
assert.ok(~title.indexOf('#'), 'Wrong title!');
|
||||
browser.quit()
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
26
Nodejs-Socketio-Mysql-Demo/node_modules/wd/lib/bin.js
generated
vendored
Normal file
26
Nodejs-Socketio-Mysql-Demo/node_modules/wd/lib/bin.js
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
var net = require('net')
|
||||
, repl = require('repl')
|
||||
, assert = require('assert')
|
||||
, wd = require('./main')
|
||||
;
|
||||
|
||||
var startRepl = function() {
|
||||
var r = repl.start('(wd): ');
|
||||
r.context.assert = assert;
|
||||
r.context.wd = wd;
|
||||
r.context.help = function() {
|
||||
console.log("WD - Shell.");
|
||||
console.log("Access the webdriver object via the object: 'wd'");
|
||||
};
|
||||
|
||||
net.createServer(function (socket) {
|
||||
connections += 1;
|
||||
repl.start("(wd): ", socket);
|
||||
}).listen("/tmp/node-repl-sock");
|
||||
};
|
||||
|
||||
if (process.argv[2] == "shell") {
|
||||
startRepl()
|
||||
}
|
||||
10
Nodejs-Socketio-Mysql-Demo/node_modules/wd/lib/browser-scripts/safe-execute-async.js
generated
vendored
Normal file
10
Nodejs-Socketio-Mysql-Demo/node_modules/wd/lib/browser-scripts/safe-execute-async.js
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
var code = arguments[0], args = arguments[1], done = arguments[2];
|
||||
var wrap = function() {
|
||||
return eval(code);
|
||||
};
|
||||
try {
|
||||
args.push(done);
|
||||
return wrap.apply(this, args);
|
||||
} catch (err) {
|
||||
throw err;
|
||||
}
|
||||
9
Nodejs-Socketio-Mysql-Demo/node_modules/wd/lib/browser-scripts/safe-execute.js
generated
vendored
Normal file
9
Nodejs-Socketio-Mysql-Demo/node_modules/wd/lib/browser-scripts/safe-execute.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
var code = arguments[0], args = arguments[1];
|
||||
var wrap = function() {
|
||||
return eval(code);
|
||||
};
|
||||
try {
|
||||
return wrap.apply(this, args);
|
||||
} catch (err) {
|
||||
throw err;
|
||||
}
|
||||
32
Nodejs-Socketio-Mysql-Demo/node_modules/wd/lib/browser-scripts/wait-for-cond-in-browser.js
generated
vendored
Normal file
32
Nodejs-Socketio-Mysql-Demo/node_modules/wd/lib/browser-scripts/wait-for-cond-in-browser.js
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
// run in the browser
|
||||
|
||||
//parse arguments
|
||||
var condExpr = arguments[0], timeout = arguments[1],
|
||||
poll = arguments[2], cb = arguments[3];
|
||||
|
||||
// recursive implementation
|
||||
waitForConditionImpl = function(conditionExpr, limit, poll, cb) {
|
||||
|
||||
// timeout check
|
||||
if (Date.now() < limit) {
|
||||
// condition check
|
||||
res = eval(conditionExpr);
|
||||
if (res == true ) {
|
||||
// condition ok
|
||||
return cb(res);
|
||||
} else {
|
||||
// wait for poll and try again
|
||||
setTimeout(function() {
|
||||
waitForConditionImpl(conditionExpr, limit, poll, cb);
|
||||
}, poll);
|
||||
}
|
||||
} else {
|
||||
// try one last time
|
||||
res = eval(conditionExpr);
|
||||
return cb(res);
|
||||
}
|
||||
};
|
||||
|
||||
// calling impl
|
||||
limit = Date.now() + timeout;
|
||||
waitForConditionImpl(condExpr, limit, poll, cb);
|
||||
316
Nodejs-Socketio-Mysql-Demo/node_modules/wd/lib/builder.js
generated
vendored
Normal file
316
Nodejs-Socketio-Mysql-Demo/node_modules/wd/lib/builder.js
generated
vendored
Normal file
@@ -0,0 +1,316 @@
|
||||
var http = require('http')
|
||||
, __slice = Array.prototype.slice;
|
||||
|
||||
var strip = function strip(str) {
|
||||
var x = [];
|
||||
for (var i = 0; i < str.length; i++) {
|
||||
if (str.charCodeAt(i)) {
|
||||
x.push(str.charAt(i));
|
||||
}
|
||||
}
|
||||
return x.join('');
|
||||
};
|
||||
|
||||
var newError = function(opts)
|
||||
{
|
||||
var err = new Error();
|
||||
for (var k in opts) {
|
||||
err[k] = opts[k]
|
||||
}
|
||||
// nicer error output
|
||||
err.inspect = function() {
|
||||
var res = "";
|
||||
for (var k in this) {
|
||||
var _this = this;
|
||||
(function() {
|
||||
var v = _this[k];
|
||||
if (typeof v === 'object') {
|
||||
if ((v["class"] != null) && v["class"].match(/org.openqa.selenium.remote.Response/)) {
|
||||
// for selenium classes, hidding long fields or field with
|
||||
// duplicate information
|
||||
var vAsStr = JSON.stringify(v, function(key, value) {
|
||||
if (key === 'screen' || key === 'stackTrace' || key === 'buildInformation' || key === 'localizedMessage') {
|
||||
return '[hidden]';
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
}, " ");
|
||||
res = res + k + ": " + vAsStr + "\n";
|
||||
} else {
|
||||
// for other objects making sure output is not too long
|
||||
var vAsStr = JSON.stringify(v, undefined, " ");
|
||||
var maxLength = 1000;
|
||||
if (vAsStr.length > maxLength) {
|
||||
vAsStr = vAsStr.substr(0, maxLength) + "\n...";
|
||||
}
|
||||
res = res + k + ": " + vAsStr + "\n";
|
||||
}
|
||||
} else if (typeof v != 'function')
|
||||
{
|
||||
// printing non object types without modif
|
||||
res = res + k + ": " + v + "\n";
|
||||
}
|
||||
})();
|
||||
};
|
||||
return res;
|
||||
};
|
||||
return err;
|
||||
};
|
||||
|
||||
var isWebDriverException = function(res) {
|
||||
var _ref;
|
||||
if ((typeof res !== "undefined" && res !== null ?
|
||||
(_ref = res["class"]) != null ? _ref.indexOf('WebDriverException') :
|
||||
void 0 : void 0) > 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// just calls the callback when there is no result
|
||||
var simpleCallback = function(cb) {
|
||||
return function(res) {
|
||||
if(res==null) {
|
||||
// expected behaviour for quit
|
||||
if(cb!=null){ return cb();}
|
||||
}else{
|
||||
res.setEncoding('utf8');
|
||||
var data = '';
|
||||
res.on('data', function(chunk) { data += chunk.toString(); });
|
||||
res.on('end', function() {
|
||||
if(data == '') {
|
||||
// expected behaviour
|
||||
return cb()
|
||||
} else {
|
||||
// something wrong
|
||||
if(cb!=null){
|
||||
return cb(new Error(
|
||||
{message:'Unexpected data in simpleCallback.', data:data}) );
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
// base for all callback handling data
|
||||
var callbackWithDataBase = function(cb) {
|
||||
return function(res) {
|
||||
res.setEncoding('utf8');
|
||||
var data = '';
|
||||
res.on('data', function(chunk) { data += chunk.toString(); });
|
||||
res.on('end', function() {
|
||||
var obj;
|
||||
try {
|
||||
obj = JSON.parse(strip(data));
|
||||
} catch (e) {
|
||||
return cb(newError({message:'Not JSON response', data:data}));
|
||||
}
|
||||
if (obj.status > 0) {
|
||||
cb(newError(
|
||||
{message:'Error response status.',status:obj.status,cause:obj}));
|
||||
} else {
|
||||
cb(null, obj);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// retrieves field value from result
|
||||
var callbackWithData = function(cb) {
|
||||
return callbackWithDataBase(function(err,obj) {
|
||||
if(err != null) {return cb(err);}
|
||||
if(isWebDriverException(obj.value)) {return cb(newError(
|
||||
{message:obj.value.message,cause:obj.value}));}
|
||||
cb(null, obj.value);
|
||||
});
|
||||
};
|
||||
|
||||
// retrieves ONE element
|
||||
var elementCallback = function(cb) {
|
||||
return callbackWithDataBase(function(err, obj) {
|
||||
if(err != null) {return cb(err);}
|
||||
if(isWebDriverException(obj.value)) {return cb(newError(
|
||||
{message:obj.value.message,cause:obj.value}));}
|
||||
if (!obj.value.ELEMENT) {
|
||||
cb(newError(
|
||||
{message:"no ELEMENT in response value field.",cause:obj}));
|
||||
} else {
|
||||
cb(null, obj.value.ELEMENT);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// retrieves SEVERAL elements
|
||||
var elementsCallback = function(cb) {
|
||||
return callbackWithDataBase(function(err, obj) {
|
||||
if(err != null) {return cb(err);}
|
||||
if(isWebDriverException(obj.value)) {return cb(newError(
|
||||
{message:obj.value.message,cause:obj.value}));}
|
||||
if (!(obj.value instanceof Array)) {return cb(newError(
|
||||
{message:"Response value field is not an Array.", cause:obj.value}));}
|
||||
var i, elements = [];
|
||||
for (i = 0; i < obj.value.length; i++) {
|
||||
elements.push(obj.value[i].ELEMENT);
|
||||
}
|
||||
cb(null, elements);
|
||||
});
|
||||
};
|
||||
|
||||
var newHttpOpts = function(method) {
|
||||
var opts = new Object();
|
||||
opts.method = method;
|
||||
for (var o in this.options) {
|
||||
opts[o] = this.options[o];
|
||||
}
|
||||
opts.headers = {};
|
||||
opts.headers['Connection'] = 'keep-alive';
|
||||
if (opts.method === 'POST' || opts.method === 'GET')
|
||||
opts.headers['Accept'] = 'application/json';
|
||||
if (opts.method == 'POST')
|
||||
opts.headers['Content-Type'] = 'application/json; charset=UTF-8';
|
||||
return opts;
|
||||
};
|
||||
|
||||
// session initialization
|
||||
var init = function(desired, cb) {
|
||||
var _this = this;
|
||||
|
||||
//allow desired ovveride to be left out
|
||||
if (typeof desired == 'function') {
|
||||
cb = desired;
|
||||
desired = {};
|
||||
}
|
||||
|
||||
// making copy
|
||||
var _desired = {};
|
||||
for (var k in desired) {
|
||||
_desired[k] = desired[k];
|
||||
}
|
||||
|
||||
// defaulting capabilities when necessary
|
||||
for (var k in this.defaultCapabilities) {
|
||||
_desired[k] = _desired[k] || this.defaultCapabilities[k];
|
||||
}
|
||||
|
||||
// http options
|
||||
var httpOpts = newHttpOpts.apply(this, ['POST']);
|
||||
|
||||
// authentication (for saucelabs)
|
||||
if ((_this.username != null) && (_this.accessKey != null)) {
|
||||
var authString = _this.username + ':' + _this.accessKey;
|
||||
var buf = new Buffer(authString);
|
||||
httpOpts['headers'] = {
|
||||
'Authorization': 'Basic ' + buf.toString('base64')
|
||||
};
|
||||
}
|
||||
|
||||
// building request
|
||||
var req = http.request(httpOpts, function(res) {
|
||||
var data = '';
|
||||
res.on('data', function(chunk) {
|
||||
data += chunk;
|
||||
});
|
||||
res.on('end', function() {
|
||||
if (res.headers.location == undefined) {
|
||||
console.log('\x1b[31mError\x1b[0m: The environment you requested was unavailable.\n');
|
||||
console.log('\x1b[33mReason\x1b[0m:\n');
|
||||
console.log(data);
|
||||
console.log('\nFor the available values please consult the WebDriver JSONWireProtocol,');
|
||||
console.log('located at: \x1b[33mhttp://code.google.com/p/selenium/wiki/JsonWireProtocol#/session\x1b[0m');
|
||||
if (cb)
|
||||
cb({ message: 'The environment you requested was unavailable.' });
|
||||
return;
|
||||
}
|
||||
var locationArr = res.headers.location.split('/');
|
||||
_this.sessionID = locationArr[locationArr.length - 1];
|
||||
_this.emit('status', '\nDriving the web on session: ' + _this.sessionID + '\n');
|
||||
|
||||
if (cb) { cb(null, _this.sessionID) }
|
||||
});
|
||||
});
|
||||
req.on('error', function(e) { cb(e); });
|
||||
|
||||
// writting data
|
||||
req.write(JSON.stringify({desiredCapabilities: _desired}));
|
||||
|
||||
// sending
|
||||
req.end();
|
||||
};
|
||||
|
||||
// used to build all the methods except init
|
||||
var methodBuilder = function(builderOpt) {
|
||||
// by default we call simpleCallBack(cb) assuming cb is the last argument
|
||||
var defaultCb = function() {
|
||||
var args, cb, _i;
|
||||
args = 2 <= arguments.length ? __slice.call(arguments, 0,
|
||||
_i = arguments.length - 1) : (_i = 0, []), cb = arguments[_i++];
|
||||
return simpleCallback(cb);
|
||||
};
|
||||
|
||||
return function(cb) {
|
||||
var _this = this;
|
||||
|
||||
// parsing arguments
|
||||
var args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
|
||||
|
||||
// http options init
|
||||
var httpOpts = newHttpOpts.apply(this, [builderOpt.method]);
|
||||
|
||||
// retrieving path information
|
||||
var relPath = builderOpt.relPath;
|
||||
if (typeof relPath === 'function') { relPath = relPath.apply(this, args) }
|
||||
var absPath = builderOpt.absPath;
|
||||
if (typeof absPath === 'function') { absPath = absPath.apply(this, args) }
|
||||
|
||||
// setting path in http options
|
||||
if (this.sessionID != null) { httpOpts['path'] += '/' + this.sessionID; }
|
||||
if (relPath) { httpOpts['path'] += relPath; }
|
||||
if (absPath) { httpOpts['path'] = absPath;}
|
||||
|
||||
// building callback
|
||||
cb = (builderOpt.cb || defaultCb).apply(this, args);
|
||||
|
||||
// wrapping cb if we need to emit a message
|
||||
if (builderOpt.emit != null) {
|
||||
var _cb = cb;
|
||||
cb = function(res) {
|
||||
if (builderOpt.emit != null) {
|
||||
_this.emit(builderOpt.emit.event, builderOpt.emit.message);
|
||||
}
|
||||
if (_cb) { _cb(); }
|
||||
};
|
||||
}
|
||||
|
||||
// logging
|
||||
_this.emit('command', httpOpts['method'],
|
||||
httpOpts['path'].replace(this.sessionID, ':sessionID')
|
||||
.replace(this.basePath, '')
|
||||
);
|
||||
|
||||
// building request
|
||||
var req = http.request(httpOpts, cb);
|
||||
req.on('error', function(e) { cb(e); });
|
||||
|
||||
// writting data
|
||||
var data = '';
|
||||
if (builderOpt.data != null) {
|
||||
data = builderOpt.data.apply(this, args);
|
||||
}
|
||||
if (typeof data === 'object') {
|
||||
data = JSON.stringify(data);
|
||||
}
|
||||
req.write(data);
|
||||
|
||||
//sending
|
||||
req.end();
|
||||
};
|
||||
};
|
||||
|
||||
exports.simpleCallback = simpleCallback;
|
||||
exports.callbackWithData = callbackWithData;
|
||||
exports.elementCallback = elementCallback;
|
||||
exports.elementsCallback = elementsCallback;
|
||||
exports.init = init;
|
||||
exports.methodBuilder = methodBuilder;
|
||||
|
||||
83
Nodejs-Socketio-Mysql-Demo/node_modules/wd/lib/main.js
generated
vendored
Normal file
83
Nodejs-Socketio-Mysql-Demo/node_modules/wd/lib/main.js
generated
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
var EventEmitter = require('events').EventEmitter
|
||||
, __slice = Array.prototype.slice
|
||||
, protocol = require('./protocol'),
|
||||
SPECIAL_KEYS = require('./special-keys');
|
||||
|
||||
// webdriver client main class
|
||||
// remoteWdConfig is an option object containing the following fields:
|
||||
// host,port, username, accessKey
|
||||
var webdriver = function(remoteWdConfig) {
|
||||
this.sessionID = null;
|
||||
this.username = remoteWdConfig.username;
|
||||
this.accessKey = remoteWdConfig.accessKey;
|
||||
this.basePath = (remoteWdConfig.path || '/wd/hub');
|
||||
// default
|
||||
this.options = {
|
||||
host: remoteWdConfig.host || '127.0.0.1'
|
||||
, port: remoteWdConfig.port || 4444
|
||||
, path: (this.basePath + '/session').replace('//', '/')
|
||||
};
|
||||
this.defaultCapabilities = {
|
||||
browserName: 'firefox'
|
||||
, version: ''
|
||||
, javascriptEnabled: true
|
||||
, platform: 'ANY'
|
||||
};
|
||||
|
||||
// saucelabs default
|
||||
if ((this.username != null) && (this.accessKey != null)) {
|
||||
this.defaultCapabilities.platform = 'VISTA';
|
||||
}
|
||||
|
||||
EventEmitter.call(this);
|
||||
};
|
||||
|
||||
// wraps protocol methods to hide implementation
|
||||
var wrap = function(f) {
|
||||
return function() {
|
||||
var args;
|
||||
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
|
||||
return f.apply(this, args);
|
||||
};
|
||||
};
|
||||
|
||||
// adding protocol methods
|
||||
var k, v;
|
||||
for (k in protocol) {
|
||||
v = protocol[k];
|
||||
if (typeof v === 'function') {
|
||||
webdriver.prototype[k] = wrap(v);
|
||||
}
|
||||
}
|
||||
|
||||
webdriver.prototype.__proto__ = EventEmitter.prototype;
|
||||
|
||||
// parses server parameters
|
||||
var parseRemoteWdConfig = function(args) {
|
||||
var accessKey, host, path, port, username, _ref;
|
||||
if (typeof (args != null ? args[0] : void 0) === 'object') {
|
||||
return args[0];
|
||||
} else {
|
||||
host = args[0], port = args[1], username = args[2], accessKey = args[3];
|
||||
return {
|
||||
host: host,
|
||||
port: port,
|
||||
username: username,
|
||||
accessKey: accessKey
|
||||
};
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
// creates the webdriver object
|
||||
// server parameters can be passed in 2 ways
|
||||
// - as a list of arguments host,port, username, accessKey
|
||||
// - as an option object containing the fields above
|
||||
exports.remote = function() {
|
||||
var args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
|
||||
var rwc = parseRemoteWdConfig(args);
|
||||
return new webdriver(rwc);
|
||||
};
|
||||
|
||||
exports.SPECIAL_KEYS = SPECIAL_KEYS
|
||||
|
||||
604
Nodejs-Socketio-Mysql-Demo/node_modules/wd/lib/protocol.js
generated
vendored
Normal file
604
Nodejs-Socketio-Mysql-Demo/node_modules/wd/lib/protocol.js
generated
vendored
Normal file
@@ -0,0 +1,604 @@
|
||||
fs = require('fs');
|
||||
var builder = require('./builder');
|
||||
|
||||
var methodBuilder = builder.methodBuilder
|
||||
, callbackWithData = builder.callbackWithData
|
||||
, elementCallback = builder.elementCallback
|
||||
, elementsCallback = builder.elementsCallback
|
||||
, __slice = Array.prototype.slice;
|
||||
|
||||
var protocol = {};
|
||||
|
||||
protocol.init = builder.init;
|
||||
|
||||
protocol.status = methodBuilder({
|
||||
method: 'GET'
|
||||
, absPath: function() { return this.basePath + '/status' }
|
||||
, cb: function(cb) { return callbackWithData(cb); }
|
||||
});
|
||||
|
||||
protocol.sessions = methodBuilder({
|
||||
method: 'GET'
|
||||
, absPath: function() { return this.basePath + '/sessions' }
|
||||
, cb: function(cb) { return callbackWithData(cb); }
|
||||
});
|
||||
|
||||
|
||||
// alternate strategy to get session capabilities
|
||||
// extract session capabilities from session list
|
||||
protocol.altSessionCapabilities = function(cb) {
|
||||
var _this = this;
|
||||
// looking for the current session
|
||||
protocol.sessions.apply(this, [function(err, sessions) {
|
||||
if (err == null) {
|
||||
sessions = sessions.filter(function(session) {
|
||||
return session.id === _this.sessionID;
|
||||
});
|
||||
var _ref;
|
||||
return cb(null, (_ref = sessions[0]) != null ? _ref.capabilities : void 0);
|
||||
} else {
|
||||
return cb(err, sessions);
|
||||
}
|
||||
}]);
|
||||
};
|
||||
|
||||
protocol.sessionCapabilities = methodBuilder({
|
||||
method: 'GET'
|
||||
// default url
|
||||
, cb: function(cb) { return callbackWithData(cb); }
|
||||
});
|
||||
|
||||
protocol.close = methodBuilder({
|
||||
method: 'DELETE'
|
||||
, relPath: '/window'
|
||||
});
|
||||
|
||||
protocol.quit = methodBuilder({
|
||||
method: 'DELETE'
|
||||
// default url
|
||||
, emit: {event: 'status', message: '\nEnding your web drivage..\n'}
|
||||
});
|
||||
|
||||
protocol.eval = function(code, cb) {
|
||||
code = "return " + code + ";"
|
||||
protocol.execute.apply( this, [code, function(err, res) {
|
||||
if(err!=null) {return cb(err);}
|
||||
cb(null, res);
|
||||
}]);
|
||||
};
|
||||
|
||||
protocol.safeEval = function(code, cb) {
|
||||
protocol.safeExecute.apply( this, [code, function(err, res) {
|
||||
if(err!=null) {return cb(err);}
|
||||
cb(null, res);
|
||||
}]);
|
||||
};
|
||||
|
||||
protocol.execute = methodBuilder({
|
||||
method: 'POST'
|
||||
, relPath: '/execute'
|
||||
, cb: function() {
|
||||
// parsing args, cb at the end
|
||||
var cb, _args, _i;
|
||||
_args = 2 <= arguments.length ? __slice.call(arguments, 0,
|
||||
_i = arguments.length - 1) : (_i = 0, []), cb = arguments[_i++];
|
||||
|
||||
return callbackWithData(cb);
|
||||
}
|
||||
, data: function() {
|
||||
// parsing arguments (code,args,cb) with optional args
|
||||
var args, cb, code, _args, _i;
|
||||
_args = 2 <= arguments.length ? __slice.call(arguments, 0,
|
||||
_i = arguments.length - 1) : (_i = 0, []), cb = arguments[_i++];
|
||||
code = _args[0], args = _args[1];
|
||||
|
||||
//args default
|
||||
if (typeof args === "undefined" || args === null) {
|
||||
args = [];
|
||||
}
|
||||
|
||||
return {script: code, args: args};
|
||||
}
|
||||
});
|
||||
|
||||
// script to be executed in browser
|
||||
var safeExecuteJsScript = fs.readFileSync( __dirname + "/browser-scripts/safe-execute.js", 'utf8');
|
||||
|
||||
protocol.safeExecute = methodBuilder({
|
||||
method: 'POST'
|
||||
, relPath: '/execute'
|
||||
, cb: function() {
|
||||
// parsing args, cb at the end
|
||||
var cb, _args, _i;
|
||||
_args = 2 <= arguments.length ? __slice.call(arguments, 0,
|
||||
_i = arguments.length - 1) : (_i = 0, []), cb = arguments[_i++];
|
||||
return callbackWithData(cb);
|
||||
}
|
||||
, data: function() {
|
||||
// parsing arguments (code,args,cb) with optional args
|
||||
var args, cb, code, _args, _i;
|
||||
_args = 2 <= arguments.length ? __slice.call(arguments, 0,
|
||||
_i = arguments.length - 1) : (_i = 0, []), cb = arguments[_i++];
|
||||
code = _args[0], args = _args[1];
|
||||
|
||||
//args default
|
||||
if (typeof args === "undefined" || args === null) {
|
||||
args = [];
|
||||
}
|
||||
|
||||
return {script: safeExecuteJsScript, args: [code, args]};
|
||||
}
|
||||
});
|
||||
|
||||
protocol.executeAsync = methodBuilder({
|
||||
method: 'POST'
|
||||
, relPath: '/execute_async'
|
||||
, cb: function() {
|
||||
// parsing args, cb at the end
|
||||
var cb, _args, _i;
|
||||
_args = 2 <= arguments.length ? __slice.call(arguments, 0,
|
||||
_i = arguments.length - 1) : (_i = 0, []), cb = arguments[_i++];
|
||||
|
||||
return callbackWithData(cb);
|
||||
}
|
||||
, data: function(code) {
|
||||
// parsing arguments (code,args,cb) with optional args
|
||||
var args, cb, code, _args, _i;
|
||||
_args = 2 <= arguments.length ? __slice.call(arguments, 0,
|
||||
_i = arguments.length - 1) : (_i = 0, []), cb = arguments[_i++];
|
||||
code = _args[0], args = _args[1];
|
||||
|
||||
//args default
|
||||
if (typeof args === "undefined" || args === null) {
|
||||
args = [];
|
||||
}
|
||||
|
||||
return {script: code, args: args};
|
||||
}
|
||||
});
|
||||
|
||||
// script to be executed in browser
|
||||
var safeExecuteAsyncJsScript = fs.readFileSync( __dirname + "/browser-scripts/safe-execute-async.js", 'utf8');
|
||||
|
||||
protocol.safeExecuteAsync = methodBuilder({
|
||||
method: 'POST'
|
||||
, relPath: '/execute_async'
|
||||
, cb: function() {
|
||||
// parsing args, cb at the end
|
||||
var cb, _args, _i;
|
||||
_args = 2 <= arguments.length ? __slice.call(arguments, 0,
|
||||
_i = arguments.length - 1) : (_i = 0, []), cb = arguments[_i++];
|
||||
|
||||
return callbackWithData(cb);
|
||||
}
|
||||
, data: function(code) {
|
||||
// parsing arguments (code,args,cb) with optional args
|
||||
var args, cb, code, _args, _i;
|
||||
_args = 2 <= arguments.length ? __slice.call(arguments, 0,
|
||||
_i = arguments.length - 1) : (_i = 0, []), cb = arguments[_i++];
|
||||
code = _args[0], args = _args[1];
|
||||
|
||||
//args default
|
||||
if (typeof args === "undefined" || args === null) {
|
||||
args = [];
|
||||
}
|
||||
|
||||
return {script: safeExecuteAsyncJsScript , args: [code, args]};
|
||||
}
|
||||
});
|
||||
|
||||
protocol.get = methodBuilder({
|
||||
method: 'POST'
|
||||
, relPath: '/url'
|
||||
, data: function(url) { return {'url': url}; }
|
||||
});
|
||||
|
||||
protocol.refresh = methodBuilder({
|
||||
method: 'POST'
|
||||
, relPath: '/refresh'
|
||||
});
|
||||
|
||||
protocol.forward = methodBuilder({
|
||||
method: 'POST'
|
||||
, relPath: '/forward'
|
||||
});
|
||||
|
||||
protocol.back = methodBuilder({
|
||||
method: 'POST'
|
||||
, relPath: '/back'
|
||||
});
|
||||
|
||||
protocol.setImplicitWaitTimeout = methodBuilder({
|
||||
method: 'POST'
|
||||
, relPath: '/timeouts/implicit_wait'
|
||||
, data: function(ms) { return {ms: ms}; }
|
||||
});
|
||||
|
||||
// for backward compatibility
|
||||
protocol.setWaitTimeout = protocol.setImplicitWaitTimeout;
|
||||
|
||||
protocol.setAsyncScriptTimeout = methodBuilder({
|
||||
method: 'POST'
|
||||
, relPath: '/timeouts/async_script'
|
||||
, data: function(ms) { return {ms: ms}; }
|
||||
});
|
||||
|
||||
protocol.setPageLoadTimeout = methodBuilder({
|
||||
method: 'POST'
|
||||
, relPath: '/timeouts/timeouts'
|
||||
, data: function(ms) { return {type: 'page load', ms: ms}; }
|
||||
});
|
||||
|
||||
protocol.element = methodBuilder({
|
||||
method: 'POST'
|
||||
, relPath: '/element'
|
||||
, cb: function(using, value, cb) { return elementCallback(cb); }
|
||||
, data: function(using, value) { return {using: using, value: value}; }
|
||||
});
|
||||
|
||||
// avoid not found exception and return null instead
|
||||
protocol.elementOrNull = function(using, value, cb) {
|
||||
protocol.elements.apply(this, [using, value,
|
||||
function(err, elements) {
|
||||
if(err == null)
|
||||
if(elements.length>0) {cb(null,elements[0]);} else {cb(null,null);}
|
||||
else
|
||||
cb(err);
|
||||
}
|
||||
]);
|
||||
};
|
||||
|
||||
// avoid not found exception and return undefined instead
|
||||
protocol.elementIfExists = function(using, value, cb) {
|
||||
protocol.elements.apply(this, [using, value,
|
||||
function(err, elements) {
|
||||
if(err == null)
|
||||
if(elements.length>0) {cb(null,elements[0]);} else {cb(null,undefined);}
|
||||
else
|
||||
cb(err);
|
||||
}
|
||||
]);
|
||||
};
|
||||
|
||||
protocol.elements = methodBuilder({
|
||||
method: 'POST'
|
||||
, relPath: '/elements'
|
||||
, cb: function(using, value, cb) { return elementsCallback(cb); }
|
||||
, data: function(using, value) { return {using: using, value: value}; }
|
||||
});
|
||||
|
||||
protocol.hasElement = function(using, value, cb){
|
||||
protocol.elements.apply( this, [using, value, function(err, elements){
|
||||
if(err==null)
|
||||
cb(null, elements.length > 0 )
|
||||
else
|
||||
cb(err);
|
||||
}]);
|
||||
}
|
||||
|
||||
// convert to type to something like ById, ByCssSelector, etc...
|
||||
var elFuncSuffix = function(type){
|
||||
res = (' by ' + type).replace(/(\s[a-z])/g,
|
||||
function($1){return $1.toUpperCase().replace(' ','');});
|
||||
return res.replace('Xpath', 'XPath');
|
||||
};
|
||||
|
||||
// return correct jsonwire type
|
||||
var elFuncFullType = function(type){
|
||||
if(type == 'css') {return 'css selector'} // shortcut for css
|
||||
return type;
|
||||
};
|
||||
|
||||
// from JsonWire spec + shortcuts
|
||||
var elementFuncTypes = ['class name', 'css selector','id','name','link text',
|
||||
'partial link text','tag name', 'xpath', 'css' ];
|
||||
|
||||
// adding all elementBy... , elementsBy... function
|
||||
|
||||
for (var i = 0; i < elementFuncTypes.length; i++) {
|
||||
|
||||
(function() {
|
||||
var type = elementFuncTypes[i];
|
||||
|
||||
protocol['element' + elFuncSuffix(type)] = function(value, cb) {
|
||||
protocol.element.apply(this, [elFuncFullType(type), value, cb]);
|
||||
};
|
||||
|
||||
// avoid not found exception and return null instead
|
||||
protocol['element' + elFuncSuffix(type)+ 'OrNull'] = function(value, cb) {
|
||||
protocol.elements.apply(this, [elFuncFullType(type), value,
|
||||
function(err, elements) {
|
||||
if(err == null)
|
||||
if(elements.length>0) {cb(null,elements[0]);} else {cb(null,null);}
|
||||
else
|
||||
cb(err);
|
||||
}
|
||||
]);
|
||||
};
|
||||
|
||||
// avoid not found exception and return undefined instead
|
||||
protocol['element' + elFuncSuffix(type)+ 'IfExists'] = function(value, cb) {
|
||||
protocol.elements.apply(this, [elFuncFullType(type), value,
|
||||
function(err, elements) {
|
||||
if(err == null)
|
||||
if(elements.length>0) {cb(null,elements[0]);} else {cb(null,undefined);}
|
||||
else
|
||||
cb(err);
|
||||
}
|
||||
]);
|
||||
};
|
||||
|
||||
protocol['hasElement' + elFuncSuffix(type)] = function(value, cb) {
|
||||
protocol.hasElement.apply(this, [elFuncFullType(type), value, cb]);
|
||||
};
|
||||
|
||||
protocol['elements' + elFuncSuffix(type)] = function(value, cb) {
|
||||
protocol.elements.apply(this, [elFuncFullType(type), value, cb]);
|
||||
};
|
||||
|
||||
})();
|
||||
|
||||
}
|
||||
|
||||
protocol.getAttribute = methodBuilder({
|
||||
method: 'GET'
|
||||
, relPath: function(element, attrName) {
|
||||
return '/element/' + element + '/attribute/' + attrName; }
|
||||
, cb: function(element, attrName, cb) { return callbackWithData(cb); }
|
||||
});
|
||||
|
||||
protocol.getValue = function(element, cb) {
|
||||
protocol.getAttribute.apply(this, [element, 'value', cb]);
|
||||
};
|
||||
|
||||
protocol.clickElement = methodBuilder({
|
||||
method: 'POST'
|
||||
, relPath: function(element, attrName) {
|
||||
return '/element/' + element + '/click'; }
|
||||
});
|
||||
|
||||
protocol.moveTo = methodBuilder({
|
||||
method: 'POST'
|
||||
, relPath: '/moveto'
|
||||
, data: function(element, xoffset, yoffset) {
|
||||
return { element: element, xoffset: xoffset, yoffset: yoffset }; }
|
||||
});
|
||||
|
||||
//@todo simulate the scroll event using dispatchEvent and browser.execute
|
||||
/* it's not implemented so taking it out
|
||||
protocol.scroll = methodBuilder({
|
||||
method: 'POST'
|
||||
, relPath:'/moveto'
|
||||
, data: function(element, xoffset, yoffset) {
|
||||
return { element : element, xoffset : xoffset, yoffset : yoffset }; }
|
||||
});
|
||||
*/
|
||||
|
||||
protocol.buttonDown = methodBuilder({
|
||||
method: 'POST'
|
||||
, relPath: '/buttondown'
|
||||
});
|
||||
|
||||
protocol.buttonUp = methodBuilder({
|
||||
method: 'POST'
|
||||
, relPath: '/buttonup'
|
||||
});
|
||||
|
||||
//{LEFT = 0, MIDDLE = 1 , RIGHT = 2}
|
||||
protocol.click = methodBuilder({
|
||||
method: 'POST'
|
||||
, relPath: '/click'
|
||||
, data: function(button) { return {button: button}; }
|
||||
});
|
||||
|
||||
|
||||
protocol.doubleclick = methodBuilder({
|
||||
method: 'POST'
|
||||
, relPath: '/doubleclick'
|
||||
});
|
||||
|
||||
//All keys are up at end of command
|
||||
protocol.type = methodBuilder({
|
||||
method: 'POST'
|
||||
, relPath: function(element, keys) {
|
||||
return '/element/' + element + '/value'; }
|
||||
, data: function(element, keys) {
|
||||
if (!(keys instanceof Array)) {keys = [keys];}
|
||||
return {value: keys};
|
||||
}
|
||||
});
|
||||
|
||||
protocol.keys = methodBuilder({
|
||||
method: 'POST'
|
||||
, relPath: '/keys'
|
||||
, data: function(keys) {
|
||||
if (!(keys instanceof Array)) {keys = [keys];}
|
||||
return {value: keys};
|
||||
}
|
||||
});
|
||||
|
||||
protocol.clear = methodBuilder({
|
||||
method: 'POST'
|
||||
, relPath: function(element) { return '/element/' + element + '/clear'; }
|
||||
});
|
||||
|
||||
protocol.title = methodBuilder({
|
||||
method: 'GET'
|
||||
, relPath: '/title'
|
||||
, cb: function(cb) { return callbackWithData(cb); }
|
||||
});
|
||||
|
||||
// element must be specified
|
||||
_rawText = methodBuilder({
|
||||
method: 'GET'
|
||||
, relPath: function(element) { return '/element/' + element + '/text'; }
|
||||
, cb: function(element, cb) { return callbackWithData(cb); }
|
||||
});
|
||||
|
||||
// element is specific element, 'body', or undefined
|
||||
protocol.text = function(element, cb) {
|
||||
var _this = this;
|
||||
if (typeof element === 'undefined' || element == 'body' || element === null) {
|
||||
protocol.element.apply(this, ['tag name', 'body', function(err, bodyEl) {
|
||||
if (err == null) {_rawText.apply(_this, [bodyEl, cb]);} else {cb(err);}
|
||||
}]);
|
||||
}else {
|
||||
_rawText.apply(_this, [element, cb]);
|
||||
}
|
||||
};
|
||||
|
||||
// element is specific element, 'body', or undefined
|
||||
protocol.textPresent = function(searchText, element, cb) {
|
||||
protocol.text.apply(this, [element, function(err, text) {
|
||||
if (err) {
|
||||
cb(err, null);
|
||||
} else {
|
||||
cb(err, text.indexOf(searchText) >= 0);
|
||||
}
|
||||
}]);
|
||||
};
|
||||
|
||||
protocol.acceptAlert = methodBuilder({
|
||||
method: 'POST'
|
||||
, relPath: '/accept_alert'
|
||||
});
|
||||
|
||||
protocol.dismissAlert = methodBuilder({
|
||||
method: 'POST'
|
||||
, relPath: '/dismiss_alert'
|
||||
});
|
||||
|
||||
protocol.active = methodBuilder({
|
||||
method: 'POST'
|
||||
, relPath: '/element/active'
|
||||
, cb: function(cb) {
|
||||
return callbackWithData(function(e, o) { cb(null, o['ELEMENT'])});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.url = methodBuilder({
|
||||
method: 'GET'
|
||||
, relPath: '/url'
|
||||
, cb: function(cb) { return callbackWithData(cb); }
|
||||
});
|
||||
|
||||
|
||||
protocol.allCookies = methodBuilder({
|
||||
method: 'GET'
|
||||
, relPath: '/cookie'
|
||||
, cb: function(cb) { return callbackWithData(cb); }
|
||||
});
|
||||
|
||||
/*
|
||||
cookie like the following:
|
||||
{name:'fruit', value:'apple'}
|
||||
optional fields: path, domain, secure, expiry
|
||||
check the JsonWire doc for details
|
||||
*/
|
||||
protocol.setCookie = methodBuilder({
|
||||
method: 'POST'
|
||||
, relPath: '/cookie'
|
||||
, data: function(cookie) {
|
||||
// setting secure otherwise selenium server throws
|
||||
if ((typeof cookie !== 'undefined' && cookie !== null) &&
|
||||
!((typeof cookie !== 'undefined' &&
|
||||
cookie !== null ? cookie.secure : void 0) != null)) {
|
||||
cookie.secure = false;
|
||||
}
|
||||
return { cookie: cookie };
|
||||
}
|
||||
});
|
||||
|
||||
protocol.deleteAllCookies = methodBuilder({
|
||||
method: 'DELETE'
|
||||
, relPath: '/cookie'
|
||||
});
|
||||
|
||||
protocol.deleteCookie = methodBuilder({
|
||||
method: 'DELETE'
|
||||
, relPath: function(name) {
|
||||
return '/cookie/' + encodeURIComponent(name); }
|
||||
});
|
||||
|
||||
|
||||
// waitForCondition recursive implementation
|
||||
var waitForConditionImpl = function(conditionExpr, limit, poll, cb) {
|
||||
var _this = this;
|
||||
|
||||
// timeout check
|
||||
if (Date.now() < limit) {
|
||||
// condition check
|
||||
protocol.eval.apply( _this , [conditionExpr, function(err, res) {
|
||||
if(err != null) {return cb(err);}
|
||||
if (res == true) {
|
||||
// condition ok
|
||||
return cb(null, true);
|
||||
} else {
|
||||
// wait for poll and try again
|
||||
setTimeout(function() {
|
||||
waitForConditionImpl.apply(_this, [conditionExpr, limit, poll, cb]);
|
||||
}, poll);
|
||||
}
|
||||
}]);
|
||||
} else {
|
||||
// try one last time
|
||||
protocol.eval.apply( _this, [conditionExpr, function(err, res) {
|
||||
if(err != null) {return cb(err);}
|
||||
if (res == true) {
|
||||
return cb(null, true);
|
||||
} else {
|
||||
// condition nok within timeout
|
||||
return cb("waitForCondition failure for: " + conditionExpr);
|
||||
}
|
||||
}]);
|
||||
}
|
||||
};
|
||||
|
||||
// args: (conditionExpr, timeout, poll, cb)
|
||||
// timeout and poll are optional
|
||||
protocol.waitForCondition = function() {
|
||||
// parsing args
|
||||
var args, cb, conditionExpr, limit, poll, timeout, _i;
|
||||
args = 2 <= arguments.length ? __slice.call(arguments, 0,
|
||||
_i = arguments.length - 1) : (_i = 0, []),
|
||||
cb = arguments[_i++];
|
||||
conditionExpr = args[0], timeout = args[1], poll = args[2];
|
||||
|
||||
//defaults
|
||||
timeout = timeout || 1000;
|
||||
poll = poll || 100;
|
||||
|
||||
// calling implementation
|
||||
limit = Date.now() + timeout;
|
||||
waitForConditionImpl.apply(this, [conditionExpr, limit, poll, cb]);
|
||||
};
|
||||
|
||||
// script to be executed in browser
|
||||
var waitForConditionInBrowserJsScript = fs.readFileSync( __dirname + "/browser-scripts/wait-for-cond-in-browser.js", 'utf8');
|
||||
|
||||
// args: (conditionExpr, timeout, poll, cb)
|
||||
// timeout and poll are optional
|
||||
protocol.waitForConditionInBrowser = function() {
|
||||
var _this = this;
|
||||
// parsing args
|
||||
var args, cb, conditionExpr, limit, poll, timeout, _i;
|
||||
args = 2 <= arguments.length ? __slice.call(arguments, 0,
|
||||
_i = arguments.length - 1) : (_i = 0, []),
|
||||
cb = arguments[_i++];
|
||||
conditionExpr = args[0], timeout = args[1], poll = args[2];
|
||||
|
||||
//defaults
|
||||
timeout = timeout || 1000;
|
||||
poll = poll || 100;
|
||||
|
||||
// calling script
|
||||
protocol.executeAsync.apply( _this, [waitForConditionInBrowserJsScript,
|
||||
[conditionExpr,timeout,poll], function(err,res) {
|
||||
if(err != null) {return cb(err);}
|
||||
if(res != true) {return cb("waitForConditionInBrowser failure for: " + conditionExpr);}
|
||||
cb(null, res);
|
||||
}
|
||||
]);
|
||||
};
|
||||
|
||||
module.exports = protocol;
|
||||
61
Nodejs-Socketio-Mysql-Demo/node_modules/wd/lib/special-keys.js
generated
vendored
Normal file
61
Nodejs-Socketio-Mysql-Demo/node_modules/wd/lib/special-keys.js
generated
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
var SPECIAL_KEYS = {
|
||||
'NULL': '\uE000',
|
||||
'Cancel': '\uE001',
|
||||
'Help': '\uE002',
|
||||
'Back space': '\uE003',
|
||||
'Tab': '\uE004',
|
||||
'Clear': '\uE005',
|
||||
'Return': '\uE006',
|
||||
'Enter': '\uE007',
|
||||
'Shift': '\uE008',
|
||||
'Control': '\uE009',
|
||||
'Alt': '\uE00A',
|
||||
'Pause': '\uE00B',
|
||||
'Escape': '\uE00C',
|
||||
'Key': 'Code',
|
||||
'Space': '\uE00D',
|
||||
'Pageup': '\uE00E',
|
||||
'Pagedown': '\uE00F',
|
||||
'End': '\uE010',
|
||||
'Home': '\uE011',
|
||||
'Left arrow': '\uE012',
|
||||
'Up arrow': '\uE013',
|
||||
'Right arrow': '\uE014',
|
||||
'Down arrow': '\uE015',
|
||||
'Insert': '\uE016',
|
||||
'Delete': '\uE017',
|
||||
'Semicolon': '\uE018',
|
||||
'Equals': '\uE019',
|
||||
'Numpad 0': '\uE01A',
|
||||
'Numpad 1': '\uE01B',
|
||||
'Numpad 2': '\uE01C',
|
||||
'Numpad 3': '\uE01D',
|
||||
'Numpad 4': '\uE01E',
|
||||
'Numpad 5': '\uE01F',
|
||||
'Numpad 6': '\uE020',
|
||||
'Numpad 7': '\uE021',
|
||||
'Numpad 8': '\uE022',
|
||||
'Numpad 9': '\uE023',
|
||||
'Multiply': '\uE024',
|
||||
'Add': '\uE025',
|
||||
'Separator': '\uE026',
|
||||
'Subtract': '\uE027',
|
||||
'Decimal': '\uE028',
|
||||
'Divide': '\uE029',
|
||||
'F1': '\uE031',
|
||||
'F2': '\uE032',
|
||||
'F3': '\uE033',
|
||||
'F4': '\uE034',
|
||||
'F5': '\uE035',
|
||||
'F6': '\uE036',
|
||||
'F7': '\uE037',
|
||||
'F8': '\uE038',
|
||||
'F9': '\uE039',
|
||||
'F10': '\uE03A',
|
||||
'F11': '\uE03B',
|
||||
'F12': '\uE03C',
|
||||
'Command': '\uE03D',
|
||||
'Meta': '\uE03D'
|
||||
};
|
||||
|
||||
module.exports = SPECIAL_KEYS;
|
||||
47
Nodejs-Socketio-Mysql-Demo/node_modules/wd/package.json
generated
vendored
Normal file
47
Nodejs-Socketio-Mysql-Demo/node_modules/wd/package.json
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
{
|
||||
"name": "wd",
|
||||
"description": "WebDriver/Selenium 2 node.js client",
|
||||
"tags": [
|
||||
"web",
|
||||
"automation",
|
||||
"browser",
|
||||
"javascript"
|
||||
],
|
||||
"version": "0.0.17",
|
||||
"author": {
|
||||
"name": "Adam Christian",
|
||||
"email": "adam.christian@gmail.com"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/admc/wd.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/admc/wd/issues"
|
||||
},
|
||||
"engines": [
|
||||
"node"
|
||||
],
|
||||
"main": "./lib/main",
|
||||
"bin": {
|
||||
"wd": "./lib/bin.js"
|
||||
},
|
||||
"directories": {
|
||||
"lib": "./lib"
|
||||
},
|
||||
"devDependencies": {
|
||||
"nodeunit": "latest",
|
||||
"should": "latest",
|
||||
"coffee-script": "latest",
|
||||
"express": "latest",
|
||||
"async": "latest"
|
||||
},
|
||||
"_id": "wd@0.0.17",
|
||||
"dependencies": {},
|
||||
"optionalDependencies": {},
|
||||
"_engineSupported": true,
|
||||
"_npmVersion": "1.1.21",
|
||||
"_nodeVersion": "v0.6.18",
|
||||
"_defaultsLoaded": true,
|
||||
"_from": "wd"
|
||||
}
|
||||
48
Nodejs-Socketio-Mysql-Demo/node_modules/wd/test/common/basic-test-base.coffee
generated
vendored
Normal file
48
Nodejs-Socketio-Mysql-Demo/node_modules/wd/test/common/basic-test-base.coffee
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
# nodeunit test
|
||||
|
||||
wd = require '../../lib/main'
|
||||
should = require 'should'
|
||||
assert = require 'assert'
|
||||
|
||||
runTestWith = (remoteWdConfig, desired) ->
|
||||
remoteWdConfig = remoteWdConfig() if typeof remoteWdConfig is 'function'
|
||||
|
||||
browser = null
|
||||
{
|
||||
remote: (test) ->
|
||||
browser = wd.remote remoteWdConfig
|
||||
should.exist browser
|
||||
browser.on "status", (info) ->
|
||||
console.log "\u001b[36m%s\u001b[0m", info
|
||||
browser.on "command", (meth, path) ->
|
||||
console.log " > \u001b[33m%s\u001b[0m: %s", meth, path
|
||||
test.done()
|
||||
|
||||
init: (test) ->
|
||||
browser.init desired, ->
|
||||
test.done()
|
||||
|
||||
browsing:
|
||||
'getting page': (test) ->
|
||||
browser.get "http://saucelabs.com/test/guinea-pig", ->
|
||||
browser.title (err, title) ->
|
||||
assert.ok ~title.indexOf("I am a page title - Sauce Labs"), "Wrong title!"
|
||||
test.done()
|
||||
|
||||
clicking: (test) ->
|
||||
browser.elementById "submit", (err, el) ->
|
||||
browser.clickElement el, ->
|
||||
browser.eval "window.location.href", (err, title) ->
|
||||
assert.ok ~title.indexOf("#"), "Wrong title!"
|
||||
test.done()
|
||||
|
||||
leaving: (test) ->
|
||||
browser.quit ->
|
||||
test.done()
|
||||
}
|
||||
|
||||
|
||||
|
||||
exports.runTestWith = runTestWith
|
||||
|
||||
|
||||
64
Nodejs-Socketio-Mysql-Demo/node_modules/wd/test/common/basic-test-base.js
generated
vendored
Normal file
64
Nodejs-Socketio-Mysql-Demo/node_modules/wd/test/common/basic-test-base.js
generated
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
// Generated by CoffeeScript 1.3.2
|
||||
(function() {
|
||||
var assert, runTestWith, should, wd;
|
||||
|
||||
wd = require('../../lib/main');
|
||||
|
||||
should = require('should');
|
||||
|
||||
assert = require('assert');
|
||||
|
||||
runTestWith = function(remoteWdConfig, desired) {
|
||||
var browser;
|
||||
if (typeof remoteWdConfig === 'function') {
|
||||
remoteWdConfig = remoteWdConfig();
|
||||
}
|
||||
browser = null;
|
||||
return {
|
||||
remote: function(test) {
|
||||
browser = wd.remote(remoteWdConfig);
|
||||
should.exist(browser);
|
||||
browser.on("status", function(info) {
|
||||
return console.log("\u001b[36m%s\u001b[0m", info);
|
||||
});
|
||||
browser.on("command", function(meth, path) {
|
||||
return console.log(" > \u001b[33m%s\u001b[0m: %s", meth, path);
|
||||
});
|
||||
return test.done();
|
||||
},
|
||||
init: function(test) {
|
||||
return browser.init(desired, function() {
|
||||
return test.done();
|
||||
});
|
||||
},
|
||||
browsing: {
|
||||
'getting page': function(test) {
|
||||
return browser.get("http://saucelabs.com/test/guinea-pig", function() {
|
||||
return browser.title(function(err, title) {
|
||||
assert.ok(~title.indexOf("I am a page title - Sauce Labs"), "Wrong title!");
|
||||
return test.done();
|
||||
});
|
||||
});
|
||||
},
|
||||
clicking: function(test) {
|
||||
return browser.elementById("submit", function(err, el) {
|
||||
return browser.clickElement(el, function() {
|
||||
return browser["eval"]("window.location.href", function(err, title) {
|
||||
assert.ok(~title.indexOf("#"), "Wrong title!");
|
||||
return test.done();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
},
|
||||
leaving: function(test) {
|
||||
return browser.quit(function() {
|
||||
return test.done();
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
exports.runTestWith = runTestWith;
|
||||
|
||||
}).call(this);
|
||||
3
Nodejs-Socketio-Mysql-Demo/node_modules/wd/test/saucelabs/.npmignore
generated
vendored
Normal file
3
Nodejs-Socketio-Mysql-Demo/node_modules/wd/test/saucelabs/.npmignore
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
config.coffee
|
||||
config.js
|
||||
|
||||
5
Nodejs-Socketio-Mysql-Demo/node_modules/wd/test/saucelabs/README
generated
vendored
Normal file
5
Nodejs-Socketio-Mysql-Demo/node_modules/wd/test/saucelabs/README
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
In order to run the saucelabs tests, first copy config-sample.coffee
|
||||
to config.coffee, and then configure your sauce username and access-key in
|
||||
config.coffee.
|
||||
|
||||
config.coffee and config.js are in .gitignore.
|
||||
31
Nodejs-Socketio-Mysql-Demo/node_modules/wd/test/saucelabs/basic-test.coffee
generated
vendored
Normal file
31
Nodejs-Socketio-Mysql-Demo/node_modules/wd/test/saucelabs/basic-test.coffee
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
# nodeunit test
|
||||
|
||||
{runTestWith} = require '../common/basic-test-base'
|
||||
configHelper = require './config-helper'
|
||||
|
||||
remoteWdConfig= configHelper.getRemoteWdConfig()
|
||||
|
||||
nameBase = "saucelabs basic test - ";
|
||||
|
||||
chromeDesired =
|
||||
name: nameBase + 'chrome'
|
||||
browserName:'chrome'
|
||||
|
||||
firefoxDesired =
|
||||
name: nameBase + 'firefox'
|
||||
browserName:'firefox'
|
||||
|
||||
explorerDesired =
|
||||
name: nameBase + 'explorer'
|
||||
browserName:'iexplore'
|
||||
version:'9'
|
||||
platform:'Windows 2008'
|
||||
|
||||
exports.wd =
|
||||
|
||||
chrome: runTestWith( remoteWdConfig , chromeDesired)
|
||||
|
||||
firefox: runTestWith(remoteWdConfig, firefoxDesired)
|
||||
|
||||
explorer: runTestWith(remoteWdConfig, explorerDesired)
|
||||
|
||||
36
Nodejs-Socketio-Mysql-Demo/node_modules/wd/test/saucelabs/basic-test.js
generated
vendored
Normal file
36
Nodejs-Socketio-Mysql-Demo/node_modules/wd/test/saucelabs/basic-test.js
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
// Generated by CoffeeScript 1.3.2
|
||||
(function() {
|
||||
var chromeDesired, configHelper, explorerDesired, firefoxDesired, nameBase, remoteWdConfig, runTestWith;
|
||||
|
||||
runTestWith = require('../common/basic-test-base').runTestWith;
|
||||
|
||||
configHelper = require('./config-helper');
|
||||
|
||||
remoteWdConfig = configHelper.getRemoteWdConfig();
|
||||
|
||||
nameBase = "saucelabs basic test - ";
|
||||
|
||||
chromeDesired = {
|
||||
name: nameBase + 'chrome',
|
||||
browserName: 'chrome'
|
||||
};
|
||||
|
||||
firefoxDesired = {
|
||||
name: nameBase + 'firefox',
|
||||
browserName: 'firefox'
|
||||
};
|
||||
|
||||
explorerDesired = {
|
||||
name: nameBase + 'explorer',
|
||||
browserName: 'iexplore',
|
||||
version: '9',
|
||||
platform: 'Windows 2008'
|
||||
};
|
||||
|
||||
exports.wd = {
|
||||
chrome: runTestWith(remoteWdConfig, chromeDesired),
|
||||
firefox: runTestWith(remoteWdConfig, firefoxDesired),
|
||||
explorer: runTestWith(remoteWdConfig, explorerDesired)
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
99
Nodejs-Socketio-Mysql-Demo/node_modules/wd/test/saucelabs/browser-init-test.coffee
generated
vendored
Normal file
99
Nodejs-Socketio-Mysql-Demo/node_modules/wd/test/saucelabs/browser-init-test.coffee
generated
vendored
Normal file
@@ -0,0 +1,99 @@
|
||||
# nodeunit test
|
||||
|
||||
wd = require '../../lib/main'
|
||||
should = require 'should'
|
||||
configHelper = require './config-helper'
|
||||
|
||||
remoteWdConfig= configHelper.getRemoteWdConfig()
|
||||
|
||||
exports.wd =
|
||||
'browser init test':
|
||||
default: (test) ->
|
||||
browser = wd.remote remoteWdConfig
|
||||
browser.defaultCapabilities.should.eql {
|
||||
browserName: 'firefox',
|
||||
version: '',
|
||||
javascriptEnabled: true,
|
||||
platform: 'VISTA' }
|
||||
browser.init (err) ->
|
||||
should.not.exist err
|
||||
browser.sessionCapabilities (err, capabilities) ->
|
||||
should.not.exist err
|
||||
capabilities.browserName.should.equal 'firefox'
|
||||
browser.quit (err) ->
|
||||
should.not.exist err
|
||||
test.done()
|
||||
|
||||
'using browser.defaultCapabilities': (test) ->
|
||||
browser = wd.remote remoteWdConfig
|
||||
browser.defaultCapabilities.browserName = 'chrome'
|
||||
browser.defaultCapabilities.platform = 'LINUX'
|
||||
browser.defaultCapabilities.javascriptEnabled = false
|
||||
browser.defaultCapabilities.name = 'browser init using defaultCapabilities'
|
||||
browser.defaultCapabilities.tags = ['wd','test']
|
||||
browser.defaultCapabilities.should.eql {
|
||||
browserName: 'chrome',
|
||||
version: '',
|
||||
javascriptEnabled: false,
|
||||
platform: 'LINUX',
|
||||
name: 'browser init using defaultCapabilities'
|
||||
tags: ['wd','test']
|
||||
}
|
||||
browser.init (err) ->
|
||||
should.not.exist err
|
||||
browser.sessionCapabilities (err, capabilities) ->
|
||||
should.not.exist err
|
||||
capabilities.browserName.should.equal 'chrome'
|
||||
capabilities.platform.should.equal 'LINUX'
|
||||
browser.quit (err) ->
|
||||
should.not.exist err
|
||||
test.done()
|
||||
|
||||
'desired only': (test) ->
|
||||
browser = wd.remote remoteWdConfig
|
||||
browser.defaultCapabilities.should.eql {
|
||||
browserName: 'firefox',
|
||||
version: '',
|
||||
javascriptEnabled: true,
|
||||
platform: 'VISTA' }
|
||||
desired =
|
||||
browserName:'iexplore'
|
||||
platform: 'Windows 2008'
|
||||
name: 'browser init using desired'
|
||||
tags: ['wd','test']
|
||||
|
||||
browser.init desired, (err) ->
|
||||
should.not.exist err
|
||||
browser.sessionCapabilities (err, capabilities) ->
|
||||
should.not.exist err
|
||||
capabilities.browserName.should.include 'explorer'
|
||||
capabilities.platform.should.equal 'WINDOWS'
|
||||
browser.quit (err) ->
|
||||
should.not.exist err
|
||||
test.done()
|
||||
|
||||
'desired overiding defaultCapabilities': (test) ->
|
||||
browser = wd.remote remoteWdConfig
|
||||
browser.defaultCapabilities.browserName = 'chrome'
|
||||
browser.defaultCapabilities.name = 'browser init overide'
|
||||
browser.defaultCapabilities.tags = ['wd','test']
|
||||
browser.defaultCapabilities.should.eql {
|
||||
browserName: 'chrome',
|
||||
version: '',
|
||||
javascriptEnabled: true,
|
||||
platform: 'VISTA',
|
||||
name: 'browser init overide'
|
||||
tags: ['wd','test']
|
||||
}
|
||||
browser.init {browserName: 'firefox'}, (err) ->
|
||||
should.not.exist err
|
||||
browser.sessionCapabilities (err, capabilities) ->
|
||||
should.not.exist err
|
||||
capabilities.browserName.should.equal 'firefox'
|
||||
browser.quit (err) ->
|
||||
should.not.exist err
|
||||
test.done()
|
||||
|
||||
|
||||
|
||||
|
||||
124
Nodejs-Socketio-Mysql-Demo/node_modules/wd/test/saucelabs/browser-init-test.js
generated
vendored
Normal file
124
Nodejs-Socketio-Mysql-Demo/node_modules/wd/test/saucelabs/browser-init-test.js
generated
vendored
Normal file
@@ -0,0 +1,124 @@
|
||||
// Generated by CoffeeScript 1.3.2
|
||||
(function() {
|
||||
var configHelper, remoteWdConfig, should, wd;
|
||||
|
||||
wd = require('../../lib/main');
|
||||
|
||||
should = require('should');
|
||||
|
||||
configHelper = require('./config-helper');
|
||||
|
||||
remoteWdConfig = configHelper.getRemoteWdConfig();
|
||||
|
||||
exports.wd = {
|
||||
'browser init test': {
|
||||
"default": function(test) {
|
||||
var browser;
|
||||
browser = wd.remote(remoteWdConfig);
|
||||
browser.defaultCapabilities.should.eql({
|
||||
browserName: 'firefox',
|
||||
version: '',
|
||||
javascriptEnabled: true,
|
||||
platform: 'VISTA'
|
||||
});
|
||||
return browser.init(function(err) {
|
||||
should.not.exist(err);
|
||||
return browser.sessionCapabilities(function(err, capabilities) {
|
||||
should.not.exist(err);
|
||||
capabilities.browserName.should.equal('firefox');
|
||||
return browser.quit(function(err) {
|
||||
should.not.exist(err);
|
||||
return test.done();
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
'using browser.defaultCapabilities': function(test) {
|
||||
var browser;
|
||||
browser = wd.remote(remoteWdConfig);
|
||||
browser.defaultCapabilities.browserName = 'chrome';
|
||||
browser.defaultCapabilities.platform = 'LINUX';
|
||||
browser.defaultCapabilities.javascriptEnabled = false;
|
||||
browser.defaultCapabilities.name = 'browser init using defaultCapabilities';
|
||||
browser.defaultCapabilities.tags = ['wd', 'test'];
|
||||
browser.defaultCapabilities.should.eql({
|
||||
browserName: 'chrome',
|
||||
version: '',
|
||||
javascriptEnabled: false,
|
||||
platform: 'LINUX',
|
||||
name: 'browser init using defaultCapabilities',
|
||||
tags: ['wd', 'test']
|
||||
});
|
||||
return browser.init(function(err) {
|
||||
should.not.exist(err);
|
||||
return browser.sessionCapabilities(function(err, capabilities) {
|
||||
should.not.exist(err);
|
||||
capabilities.browserName.should.equal('chrome');
|
||||
capabilities.platform.should.equal('LINUX');
|
||||
return browser.quit(function(err) {
|
||||
should.not.exist(err);
|
||||
return test.done();
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
'desired only': function(test) {
|
||||
var browser, desired;
|
||||
browser = wd.remote(remoteWdConfig);
|
||||
browser.defaultCapabilities.should.eql({
|
||||
browserName: 'firefox',
|
||||
version: '',
|
||||
javascriptEnabled: true,
|
||||
platform: 'VISTA'
|
||||
});
|
||||
desired = {
|
||||
browserName: 'iexplore',
|
||||
platform: 'Windows 2008',
|
||||
name: 'browser init using desired',
|
||||
tags: ['wd', 'test']
|
||||
};
|
||||
return browser.init(desired, function(err) {
|
||||
should.not.exist(err);
|
||||
return browser.sessionCapabilities(function(err, capabilities) {
|
||||
should.not.exist(err);
|
||||
capabilities.browserName.should.include('explorer');
|
||||
capabilities.platform.should.equal('WINDOWS');
|
||||
return browser.quit(function(err) {
|
||||
should.not.exist(err);
|
||||
return test.done();
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
'desired overiding defaultCapabilities': function(test) {
|
||||
var browser;
|
||||
browser = wd.remote(remoteWdConfig);
|
||||
browser.defaultCapabilities.browserName = 'chrome';
|
||||
browser.defaultCapabilities.name = 'browser init overide';
|
||||
browser.defaultCapabilities.tags = ['wd', 'test'];
|
||||
browser.defaultCapabilities.should.eql({
|
||||
browserName: 'chrome',
|
||||
version: '',
|
||||
javascriptEnabled: true,
|
||||
platform: 'VISTA',
|
||||
name: 'browser init overide',
|
||||
tags: ['wd', 'test']
|
||||
});
|
||||
return browser.init({
|
||||
browserName: 'firefox'
|
||||
}, function(err) {
|
||||
should.not.exist(err);
|
||||
return browser.sessionCapabilities(function(err, capabilities) {
|
||||
should.not.exist(err);
|
||||
capabilities.browserName.should.equal('firefox');
|
||||
return browser.quit(function(err) {
|
||||
should.not.exist(err);
|
||||
return test.done();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
17
Nodejs-Socketio-Mysql-Demo/node_modules/wd/test/saucelabs/config-helper.coffee
generated
vendored
Normal file
17
Nodejs-Socketio-Mysql-Demo/node_modules/wd/test/saucelabs/config-helper.coffee
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
should = require 'should'
|
||||
try config = require './config' catch err
|
||||
|
||||
exports.getRemoteWdConfig = ->
|
||||
should.exist config, \
|
||||
"""
|
||||
Missing config!
|
||||
You need to copy config-sample.coffee to config.coffee,
|
||||
and then configure your sauce username and access-key in
|
||||
config.coffee
|
||||
"""
|
||||
{
|
||||
host: "ondemand.saucelabs.com"
|
||||
port: 80
|
||||
username: config.saucelabs?.username
|
||||
accessKey: config.saucelabs?.accessKey
|
||||
}
|
||||
24
Nodejs-Socketio-Mysql-Demo/node_modules/wd/test/saucelabs/config-helper.js
generated
vendored
Normal file
24
Nodejs-Socketio-Mysql-Demo/node_modules/wd/test/saucelabs/config-helper.js
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
// Generated by CoffeeScript 1.3.2
|
||||
(function() {
|
||||
var config, should;
|
||||
|
||||
should = require('should');
|
||||
|
||||
try {
|
||||
config = require('./config');
|
||||
} catch (err) {
|
||||
|
||||
}
|
||||
|
||||
exports.getRemoteWdConfig = function() {
|
||||
var _ref, _ref1;
|
||||
should.exist(config, "Missing config!\nYou need to copy config-sample.coffee to config.coffee,\nand then configure your sauce username and access-key in\nconfig.coffee");
|
||||
return {
|
||||
host: "ondemand.saucelabs.com",
|
||||
port: 80,
|
||||
username: (_ref = config.saucelabs) != null ? _ref.username : void 0,
|
||||
accessKey: (_ref1 = config.saucelabs) != null ? _ref1.accessKey : void 0
|
||||
};
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
5
Nodejs-Socketio-Mysql-Demo/node_modules/wd/test/saucelabs/config.sample.coffee
generated
vendored
Normal file
5
Nodejs-Socketio-Mysql-Demo/node_modules/wd/test/saucelabs/config.sample.coffee
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
module.exports =
|
||||
saucelabs:
|
||||
username: '<USERNAME>'
|
||||
accessKey: '<KEY>'
|
||||
|
||||
11
Nodejs-Socketio-Mysql-Demo/node_modules/wd/test/saucelabs/config.sample.js
generated
vendored
Normal file
11
Nodejs-Socketio-Mysql-Demo/node_modules/wd/test/saucelabs/config.sample.js
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
// Generated by CoffeeScript 1.3.2
|
||||
(function() {
|
||||
|
||||
module.exports = {
|
||||
saucelabs: {
|
||||
username: '<USERNAME>',
|
||||
accessKey: '<KEY>'
|
||||
}
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
96
Nodejs-Socketio-Mysql-Demo/node_modules/wd/test/unit/assets/test-page.html
generated
vendored
Normal file
96
Nodejs-Socketio-Mysql-Demo/node_modules/wd/test/unit/assets/test-page.html
generated
vendored
Normal file
@@ -0,0 +1,96 @@
|
||||
<!DOCTYPE html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>TEST PAGE</title>
|
||||
|
||||
<script src="http://code.jquery.com/jquery-latest.js"></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<div class="elementByClassName">Hello World!</div>
|
||||
<div id="elementByCssSelector">Hello World!</div>
|
||||
<div id="elementById">Hello World!</div>
|
||||
<div name="elementByName">Hello World!</div>
|
||||
<div id="elementByLinkText"><a>click elementByLinkText</a></div>
|
||||
<div id="elementByPartialLinkText"><a>click elementByPartialLinkText</a></div>
|
||||
<div id="elementByTagName"><span>Hello World!</span></div>
|
||||
<div id="elementByXPath"/><input></div>
|
||||
<div id="elementByCss">Hello World!</div>
|
||||
|
||||
<div>
|
||||
<div class="elementsByClassName">Hello World!</div>
|
||||
<div class="elementsByClassName">Hello World!</div>
|
||||
<div class="elementsByClassName">Hello World!</div>
|
||||
</div>
|
||||
<div>
|
||||
<div id="elementsByCssSelector">Hello World!</div>
|
||||
<div id="elementsByCssSelector">Hello World!</div>
|
||||
<div id="elementsByCssSelector">Hello World!</div>
|
||||
</div>
|
||||
<div>
|
||||
<div id="elementsById">Hello World!</div>
|
||||
<div id="elementsById">Hello World!</div>
|
||||
<div id="elementsById">Hello World!</div>
|
||||
</div>
|
||||
<div>
|
||||
<div name="elementsByName">Hello World!</div>
|
||||
<div name="elementsByName">Hello World!</div>
|
||||
<div name="elementsByName">Hello World!</div>
|
||||
</div>
|
||||
<div>
|
||||
<div id="elementsByLinkText"><a>click elementsByLinkText</a></div>
|
||||
<div id="elementsByLinkText"><a>click elementsByLinkText</a></div>
|
||||
<div id="elementsByLinkText"><a>click elementsByLinkText</a></div>
|
||||
</div>
|
||||
<div>
|
||||
<div id="elementsByPartialLinkText"><a>click elementsByPartialLinkText</a></div>
|
||||
<div id="elementsByPartialLinkText"><a>click elementsByPartialLinkText</a></div>
|
||||
<div id="elementsByPartialLinkText"><a>click elementsByPartialLinkText</a></div>
|
||||
</div>
|
||||
<div id="elementsByTagName">
|
||||
<span>Hello World!</span>
|
||||
<span>Hello World!</span>
|
||||
<span>Hello World!</span>
|
||||
</div>
|
||||
<div id="elementsByXPath"/>
|
||||
<input>
|
||||
<input>
|
||||
<input>
|
||||
</div>
|
||||
<div>
|
||||
<div id="elementsByCss">Hello World!</div>
|
||||
<div id="elementsByCss">Hello World!</div>
|
||||
<div id="elementsByCss">Hello World!</div>
|
||||
</div>
|
||||
|
||||
<div id="getAttribute" weather="sunny">Hi</div>
|
||||
<div id="getValue">
|
||||
<input class="input-text" type="text" value="Hello getValueTest!">
|
||||
<textarea>Hello getValueTest2!</textarea>
|
||||
</div>
|
||||
<div id="text"><div>text content</div></div>
|
||||
<div id="type"><input class="input-text" type="text"></div>
|
||||
<div id="keys"><input class="input-text" type="text"></div>
|
||||
<div id="eval"><ul><li>line 1</li><li>line 2</li></ul></div>
|
||||
<div id="setWaitTimeout"></div>
|
||||
<div id="clickElement"><a href="#">not clicked</a></div>
|
||||
<div id="moveTo">
|
||||
<a class="a1" href="#">a1</a><br>
|
||||
<a class="a2" href="#">a2</a><br>
|
||||
<div class='current'></div>
|
||||
</div>
|
||||
<div id="click"><a href="#">not clicked</a></div>
|
||||
<div id="doubleclick"><a href="#">not clicked</a></div>
|
||||
<div id="clear"><input class="input-text" type="text" value="not cleared"></div>
|
||||
<div id="textPresent">weather is sunny</div>
|
||||
<div id="acceptAlert"><a>click me</a></div>
|
||||
<div id="dismissAlert"><a>click me</a></div>
|
||||
<div id="active">
|
||||
<input class="i1" type="text" value="input 1">
|
||||
<input class="i2" type="text" value="input 2">
|
||||
</div>
|
||||
<div id="mouseButton"><a>hold me</a><div></div></div>
|
||||
<div id="waitForCondition"></div>
|
||||
<div id="waitForConditionInBrowser"></div>
|
||||
</body>
|
||||
</html>
|
||||
14
Nodejs-Socketio-Mysql-Demo/node_modules/wd/test/unit/basic-test.coffee
generated
vendored
Normal file
14
Nodejs-Socketio-Mysql-Demo/node_modules/wd/test/unit/basic-test.coffee
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
# nodeunit test
|
||||
|
||||
{runTestWith} = require '../common/basic-test-base'
|
||||
|
||||
exports.wd =
|
||||
'basic test':
|
||||
chrome: (runTestWith {}, {browserName:'chrome'})
|
||||
|
||||
firefox: (runTestWith {}, {browserName:'firefox'})
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
18
Nodejs-Socketio-Mysql-Demo/node_modules/wd/test/unit/basic-test.js
generated
vendored
Normal file
18
Nodejs-Socketio-Mysql-Demo/node_modules/wd/test/unit/basic-test.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
// Generated by CoffeeScript 1.3.2
|
||||
(function() {
|
||||
var runTestWith;
|
||||
|
||||
runTestWith = require('../common/basic-test-base').runTestWith;
|
||||
|
||||
exports.wd = {
|
||||
'basic test': {
|
||||
chrome: runTestWith({}, {
|
||||
browserName: 'chrome'
|
||||
}),
|
||||
firefox: runTestWith({}, {
|
||||
browserName: 'firefox'
|
||||
})
|
||||
}
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
78
Nodejs-Socketio-Mysql-Demo/node_modules/wd/test/unit/browser-init-test.coffee
generated
vendored
Normal file
78
Nodejs-Socketio-Mysql-Demo/node_modules/wd/test/unit/browser-init-test.coffee
generated
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
# nodeunit test
|
||||
|
||||
wd = require '../../lib/main'
|
||||
should = require 'should'
|
||||
exports.wd =
|
||||
'browser init test':
|
||||
default: (test) ->
|
||||
browser = wd.remote()
|
||||
browser.defaultCapabilities.should.eql {
|
||||
browserName: 'firefox',
|
||||
version: '',
|
||||
javascriptEnabled: true,
|
||||
platform: 'ANY' }
|
||||
browser.init (err) ->
|
||||
should.not.exist err
|
||||
browser.sessionCapabilities (err, capabilities) ->
|
||||
should.not.exist err
|
||||
capabilities.browserName.should.equal 'firefox'
|
||||
browser.quit (err) ->
|
||||
should.not.exist err
|
||||
test.done()
|
||||
|
||||
'using browser.defaultCapabilities': (test) ->
|
||||
browser = wd.remote()
|
||||
browser.defaultCapabilities.browserName = 'chrome'
|
||||
browser.defaultCapabilities.javascriptEnabled = false
|
||||
browser.defaultCapabilities.should.eql {
|
||||
browserName: 'chrome',
|
||||
version: '',
|
||||
javascriptEnabled: false,
|
||||
platform: 'ANY',
|
||||
}
|
||||
browser.init (err) ->
|
||||
should.not.exist err
|
||||
browser.sessionCapabilities (err, capabilities) ->
|
||||
should.not.exist err
|
||||
capabilities.browserName.should.equal 'chrome'
|
||||
browser.quit (err) ->
|
||||
should.not.exist err
|
||||
test.done()
|
||||
|
||||
|
||||
'desired only': (test) ->
|
||||
browser = wd.remote()
|
||||
browser.defaultCapabilities.should.eql {
|
||||
browserName: 'firefox',
|
||||
version: '',
|
||||
javascriptEnabled: true,
|
||||
platform: 'ANY' }
|
||||
browser.init {browserName: 'chrome'}, (err) ->
|
||||
should.not.exist err
|
||||
browser.sessionCapabilities (err, capabilities) ->
|
||||
should.not.exist err
|
||||
capabilities.browserName.should.equal 'chrome'
|
||||
browser.quit (err) ->
|
||||
should.not.exist err
|
||||
test.done()
|
||||
|
||||
'desired overiding defaultCapabilities': (test) ->
|
||||
browser = wd.remote()
|
||||
browser.defaultCapabilities.browserName = 'chrome'
|
||||
browser.defaultCapabilities.should.eql {
|
||||
browserName: 'chrome',
|
||||
version: '',
|
||||
javascriptEnabled: true,
|
||||
platform: 'ANY' }
|
||||
browser.init {browserName: 'firefox'}, (err) ->
|
||||
should.not.exist err
|
||||
browser.sessionCapabilities (err, capabilities) ->
|
||||
should.not.exist err
|
||||
capabilities.browserName.should.equal 'firefox'
|
||||
browser.quit (err) ->
|
||||
should.not.exist err
|
||||
test.done()
|
||||
|
||||
|
||||
|
||||
|
||||
105
Nodejs-Socketio-Mysql-Demo/node_modules/wd/test/unit/browser-init-test.js
generated
vendored
Normal file
105
Nodejs-Socketio-Mysql-Demo/node_modules/wd/test/unit/browser-init-test.js
generated
vendored
Normal file
@@ -0,0 +1,105 @@
|
||||
// Generated by CoffeeScript 1.3.2
|
||||
(function() {
|
||||
var should, wd;
|
||||
|
||||
wd = require('../../lib/main');
|
||||
|
||||
should = require('should');
|
||||
|
||||
exports.wd = {
|
||||
'browser init test': {
|
||||
"default": function(test) {
|
||||
var browser;
|
||||
browser = wd.remote();
|
||||
browser.defaultCapabilities.should.eql({
|
||||
browserName: 'firefox',
|
||||
version: '',
|
||||
javascriptEnabled: true,
|
||||
platform: 'ANY'
|
||||
});
|
||||
return browser.init(function(err) {
|
||||
should.not.exist(err);
|
||||
return browser.sessionCapabilities(function(err, capabilities) {
|
||||
should.not.exist(err);
|
||||
capabilities.browserName.should.equal('firefox');
|
||||
return browser.quit(function(err) {
|
||||
should.not.exist(err);
|
||||
return test.done();
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
'using browser.defaultCapabilities': function(test) {
|
||||
var browser;
|
||||
browser = wd.remote();
|
||||
browser.defaultCapabilities.browserName = 'chrome';
|
||||
browser.defaultCapabilities.javascriptEnabled = false;
|
||||
browser.defaultCapabilities.should.eql({
|
||||
browserName: 'chrome',
|
||||
version: '',
|
||||
javascriptEnabled: false,
|
||||
platform: 'ANY'
|
||||
});
|
||||
return browser.init(function(err) {
|
||||
should.not.exist(err);
|
||||
return browser.sessionCapabilities(function(err, capabilities) {
|
||||
should.not.exist(err);
|
||||
capabilities.browserName.should.equal('chrome');
|
||||
return browser.quit(function(err) {
|
||||
should.not.exist(err);
|
||||
return test.done();
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
'desired only': function(test) {
|
||||
var browser;
|
||||
browser = wd.remote();
|
||||
browser.defaultCapabilities.should.eql({
|
||||
browserName: 'firefox',
|
||||
version: '',
|
||||
javascriptEnabled: true,
|
||||
platform: 'ANY'
|
||||
});
|
||||
return browser.init({
|
||||
browserName: 'chrome'
|
||||
}, function(err) {
|
||||
should.not.exist(err);
|
||||
return browser.sessionCapabilities(function(err, capabilities) {
|
||||
should.not.exist(err);
|
||||
capabilities.browserName.should.equal('chrome');
|
||||
return browser.quit(function(err) {
|
||||
should.not.exist(err);
|
||||
return test.done();
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
'desired overiding defaultCapabilities': function(test) {
|
||||
var browser;
|
||||
browser = wd.remote();
|
||||
browser.defaultCapabilities.browserName = 'chrome';
|
||||
browser.defaultCapabilities.should.eql({
|
||||
browserName: 'chrome',
|
||||
version: '',
|
||||
javascriptEnabled: true,
|
||||
platform: 'ANY'
|
||||
});
|
||||
return browser.init({
|
||||
browserName: 'firefox'
|
||||
}, function(err) {
|
||||
should.not.exist(err);
|
||||
return browser.sessionCapabilities(function(err, capabilities) {
|
||||
should.not.exist(err);
|
||||
capabilities.browserName.should.equal('firefox');
|
||||
return browser.quit(function(err) {
|
||||
should.not.exist(err);
|
||||
return test.done();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
1171
Nodejs-Socketio-Mysql-Demo/node_modules/wd/test/unit/per-method-test.coffee
generated
vendored
Normal file
1171
Nodejs-Socketio-Mysql-Demo/node_modules/wd/test/unit/per-method-test.coffee
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1349
Nodejs-Socketio-Mysql-Demo/node_modules/wd/test/unit/per-method-test.js
generated
vendored
Normal file
1349
Nodejs-Socketio-Mysql-Demo/node_modules/wd/test/unit/per-method-test.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
110
Nodejs-Socketio-Mysql-Demo/node_modules/wd/test/unit/wd-remote-init-test.coffee
generated
vendored
Normal file
110
Nodejs-Socketio-Mysql-Demo/node_modules/wd/test/unit/wd-remote-init-test.coffee
generated
vendored
Normal file
@@ -0,0 +1,110 @@
|
||||
# nodeunit test
|
||||
|
||||
wd = require '../../lib/main'
|
||||
should = require 'should'
|
||||
|
||||
exports.wd =
|
||||
'remote init test':
|
||||
default: (test) ->
|
||||
browser = wd.remote()
|
||||
browser.options.host.should.equal '127.0.0.1'
|
||||
browser.options.port.should.equal 4444
|
||||
browser.options.path.should.equal '/wd/hub/session'
|
||||
browser.basePath.should.equal '/wd/hub'
|
||||
should.not.exist browser.username
|
||||
should.not.exist browser.accessKey
|
||||
test.done()
|
||||
|
||||
params:
|
||||
'host, port': (test) ->
|
||||
browser = wd.remote('localhost', 8888)
|
||||
browser.options.host.should.equal 'localhost'
|
||||
browser.options.port.should.equal 8888
|
||||
browser.options.path.should.equal '/wd/hub/session'
|
||||
browser.basePath.should.equal '/wd/hub'
|
||||
should.not.exist browser.username
|
||||
should.not.exist browser.accessKey
|
||||
test.done()
|
||||
|
||||
'host, port, username, accesskey': (test) ->
|
||||
browser = wd.remote('localhost', 8888 , 'mickey', 'mouse' )
|
||||
browser.options.host.should.equal 'localhost'
|
||||
browser.options.port.should.equal 8888
|
||||
browser.options.path.should.equal '/wd/hub/session'
|
||||
browser.basePath.should.equal '/wd/hub'
|
||||
browser.username.should.equal 'mickey'
|
||||
browser.accessKey.should.equal 'mouse'
|
||||
test.done()
|
||||
|
||||
options:
|
||||
empty: (test) ->
|
||||
browser = wd.remote( {} )
|
||||
browser.options.host.should.equal '127.0.0.1'
|
||||
browser.options.port.should.equal 4444
|
||||
browser.options.path.should.equal '/wd/hub/session'
|
||||
browser.basePath.should.equal '/wd/hub'
|
||||
should.not.exist browser.username
|
||||
should.not.exist browser.accessKey
|
||||
test.done()
|
||||
'host, port': (test) ->
|
||||
browser = wd.remote({host:'localhost', port:8888})
|
||||
browser.options.host.should.equal 'localhost'
|
||||
browser.options.port.should.equal 8888
|
||||
browser.options.path.should.equal '/wd/hub/session'
|
||||
browser.basePath.should.equal '/wd/hub'
|
||||
should.not.exist browser.username
|
||||
should.not.exist browser.accessKey
|
||||
test.done()
|
||||
'host, port, username, accesskey': (test) ->
|
||||
browser = wd.remote({
|
||||
host:'localhost'
|
||||
port:8888
|
||||
username:'mickey'
|
||||
accessKey:'mouse'
|
||||
})
|
||||
browser.options.host.should.equal 'localhost'
|
||||
browser.options.port.should.equal 8888
|
||||
browser.options.path.should.equal '/wd/hub/session'
|
||||
browser.basePath.should.equal '/wd/hub'
|
||||
browser.username.should.equal 'mickey'
|
||||
browser.accessKey.should.equal 'mouse'
|
||||
test.done()
|
||||
'path': (test) ->
|
||||
browser = wd.remote( {path:'/taiwan'} )
|
||||
browser.options.host.should.equal '127.0.0.1'
|
||||
browser.options.port.should.equal 4444
|
||||
browser.options.path.should.equal '/taiwan/session'
|
||||
browser.basePath.should.equal '/taiwan'
|
||||
should.not.exist browser.username
|
||||
should.not.exist browser.accessKey
|
||||
test.done()
|
||||
'host, port, path': (test) ->
|
||||
browser = wd.remote({host:'localhost', port:8888, path:'/'})
|
||||
browser.options.host.should.equal 'localhost'
|
||||
browser.options.port.should.equal 8888
|
||||
browser.options.path.should.equal '/session'
|
||||
browser.basePath.should.equal '/'
|
||||
should.not.exist browser.username
|
||||
should.not.exist browser.accessKey
|
||||
test.done()
|
||||
'host, port, username, accesskey, path': (test) ->
|
||||
browser = wd.remote({
|
||||
host:'localhost'
|
||||
port:8888
|
||||
username:'mickey'
|
||||
accessKey:'mouse'
|
||||
path:'/asia/taiwan'
|
||||
})
|
||||
browser.options.host.should.equal 'localhost'
|
||||
browser.options.port.should.equal 8888
|
||||
browser.options.path.should.equal '/asia/taiwan/session'
|
||||
browser.basePath.should.equal '/asia/taiwan'
|
||||
browser.username.should.equal 'mickey'
|
||||
browser.accessKey.should.equal 'mouse'
|
||||
test.done()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
137
Nodejs-Socketio-Mysql-Demo/node_modules/wd/test/unit/wd-remote-init-test.js
generated
vendored
Normal file
137
Nodejs-Socketio-Mysql-Demo/node_modules/wd/test/unit/wd-remote-init-test.js
generated
vendored
Normal file
@@ -0,0 +1,137 @@
|
||||
// Generated by CoffeeScript 1.3.2
|
||||
(function() {
|
||||
var should, wd;
|
||||
|
||||
wd = require('../../lib/main');
|
||||
|
||||
should = require('should');
|
||||
|
||||
exports.wd = {
|
||||
'remote init test': {
|
||||
"default": function(test) {
|
||||
var browser;
|
||||
browser = wd.remote();
|
||||
browser.options.host.should.equal('127.0.0.1');
|
||||
browser.options.port.should.equal(4444);
|
||||
browser.options.path.should.equal('/wd/hub/session');
|
||||
browser.basePath.should.equal('/wd/hub');
|
||||
should.not.exist(browser.username);
|
||||
should.not.exist(browser.accessKey);
|
||||
return test.done();
|
||||
},
|
||||
params: {
|
||||
'host, port': function(test) {
|
||||
var browser;
|
||||
browser = wd.remote('localhost', 8888);
|
||||
browser.options.host.should.equal('localhost');
|
||||
browser.options.port.should.equal(8888);
|
||||
browser.options.path.should.equal('/wd/hub/session');
|
||||
browser.basePath.should.equal('/wd/hub');
|
||||
should.not.exist(browser.username);
|
||||
should.not.exist(browser.accessKey);
|
||||
return test.done();
|
||||
},
|
||||
'host, port, username, accesskey': function(test) {
|
||||
var browser;
|
||||
browser = wd.remote('localhost', 8888, 'mickey', 'mouse');
|
||||
browser.options.host.should.equal('localhost');
|
||||
browser.options.port.should.equal(8888);
|
||||
browser.options.path.should.equal('/wd/hub/session');
|
||||
browser.basePath.should.equal('/wd/hub');
|
||||
browser.username.should.equal('mickey');
|
||||
browser.accessKey.should.equal('mouse');
|
||||
return test.done();
|
||||
}
|
||||
},
|
||||
options: {
|
||||
empty: function(test) {
|
||||
var browser;
|
||||
browser = wd.remote({});
|
||||
browser.options.host.should.equal('127.0.0.1');
|
||||
browser.options.port.should.equal(4444);
|
||||
browser.options.path.should.equal('/wd/hub/session');
|
||||
browser.basePath.should.equal('/wd/hub');
|
||||
should.not.exist(browser.username);
|
||||
should.not.exist(browser.accessKey);
|
||||
return test.done();
|
||||
},
|
||||
'host, port': function(test) {
|
||||
var browser;
|
||||
browser = wd.remote({
|
||||
host: 'localhost',
|
||||
port: 8888
|
||||
});
|
||||
browser.options.host.should.equal('localhost');
|
||||
browser.options.port.should.equal(8888);
|
||||
browser.options.path.should.equal('/wd/hub/session');
|
||||
browser.basePath.should.equal('/wd/hub');
|
||||
should.not.exist(browser.username);
|
||||
should.not.exist(browser.accessKey);
|
||||
return test.done();
|
||||
},
|
||||
'host, port, username, accesskey': function(test) {
|
||||
var browser;
|
||||
browser = wd.remote({
|
||||
host: 'localhost',
|
||||
port: 8888,
|
||||
username: 'mickey',
|
||||
accessKey: 'mouse'
|
||||
});
|
||||
browser.options.host.should.equal('localhost');
|
||||
browser.options.port.should.equal(8888);
|
||||
browser.options.path.should.equal('/wd/hub/session');
|
||||
browser.basePath.should.equal('/wd/hub');
|
||||
browser.username.should.equal('mickey');
|
||||
browser.accessKey.should.equal('mouse');
|
||||
return test.done();
|
||||
},
|
||||
'path': function(test) {
|
||||
var browser;
|
||||
browser = wd.remote({
|
||||
path: '/taiwan'
|
||||
});
|
||||
browser.options.host.should.equal('127.0.0.1');
|
||||
browser.options.port.should.equal(4444);
|
||||
browser.options.path.should.equal('/taiwan/session');
|
||||
browser.basePath.should.equal('/taiwan');
|
||||
should.not.exist(browser.username);
|
||||
should.not.exist(browser.accessKey);
|
||||
return test.done();
|
||||
},
|
||||
'host, port, path': function(test) {
|
||||
var browser;
|
||||
browser = wd.remote({
|
||||
host: 'localhost',
|
||||
port: 8888,
|
||||
path: '/'
|
||||
});
|
||||
browser.options.host.should.equal('localhost');
|
||||
browser.options.port.should.equal(8888);
|
||||
browser.options.path.should.equal('/session');
|
||||
browser.basePath.should.equal('/');
|
||||
should.not.exist(browser.username);
|
||||
should.not.exist(browser.accessKey);
|
||||
return test.done();
|
||||
},
|
||||
'host, port, username, accesskey, path': function(test) {
|
||||
var browser;
|
||||
browser = wd.remote({
|
||||
host: 'localhost',
|
||||
port: 8888,
|
||||
username: 'mickey',
|
||||
accessKey: 'mouse',
|
||||
path: '/asia/taiwan'
|
||||
});
|
||||
browser.options.host.should.equal('localhost');
|
||||
browser.options.port.should.equal(8888);
|
||||
browser.options.path.should.equal('/asia/taiwan/session');
|
||||
browser.basePath.should.equal('/asia/taiwan');
|
||||
browser.username.should.equal('mickey');
|
||||
browser.accessKey.should.equal('mouse');
|
||||
return test.done();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
Reference in New Issue
Block a user