Permalink
Browse files

Added .drag(sourceCssSelector, destinationCssSelector, [callback]);

  • Loading branch information...
1 parent 7720f5e commit 2eded56ce05d37f62d56f0e1bed9aedf83769418 @camme camme committed Jan 3, 2012
@@ -0,0 +1,12 @@
+var client = require("webdriverjs").remote();
+
+client
+ .init()
+ .url("http://wdjstest.local/")
+ .drag("#item1", "#dropContainer", function(result)
+ {
+ console.log("DROPPED");
+ })
+ .end();
+
+
@@ -0,0 +1,12 @@
+var assert = require("assert");
+var client = require("webdriverjs").remote();
+
+client
+ .init()
+ .url("http://localhost/projects/webdriverjs-testsite")
+ .drag("#item1", "#dropContainer")
+ .getText("#dropContainer #item1", function(result) {
+ assert.equal(result.value, "item 1");
+ })
+ .end();
+

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -34,7 +34,7 @@ Then run this with nodejs:
.init()
.url("https://github.com/")
.getElementSize("id", "header", function(result){ console.log(result); })
- .getTitle()
+ .getTitle(function(title) { console.log(title) })
.getElementCssProperty("id", "header", "color", function(result){ console.log(result); })
.end();
@@ -45,7 +45,7 @@ To submit a form, pick any elemtn inside the form (or the form itself) and call
var client = require("webdriverjs").remote();
client
- .init()
+ .init()
.url("http://www.google.com")
.setValue("#lst-ib", "webdriver")
.submitForm("#tsf")
@@ -68,7 +68,8 @@ To make webdriverjs be silent (omit all logs):
{
console.log(result)
}
- );
+ )
+ .end();
### Extending
If you want to extend with your own set of commands there is a method called addCommand:
@@ -128,6 +129,7 @@ Then run this with nodjs:
# List of current helper methods
These are the current implemented helper methods. All methods take from 0 to a couple of parameters. Also all methods accept a callback so that we can assert values or have more logic when the callback is called.
+- drag(sourceCssSelector, destinationCssSelector, [callback]) - Drags an item to a destination
- click(css selector, [callback]) - Clicks on an element based on a css selector
- end([callback]) - Ends a sessions (closes the browser)
- getAttribute(css selector, attribute name, [callback]) - Get an attribute from an dom obj based on the css selector and attribute name
@@ -190,6 +192,7 @@ Yes, the implementation is done so that more complicated sets of protocol elemen
- [The protocol](http://code.google.com/p/selenium/wiki/JsonWireProtocol)
# Change log
+- 2012-01-03: Added .drag(sourceCssSelector, destinationCssSelector, [callback]);
- 2011-11-09: Added client.addCommand(commandName, function) to extend webdriverjs. Also merged with arcaniusx to fix conflict with colors module and waitFor response
- 2011-11-08: Bindings added: moveTo, elementIdLocationInView, elementIdName. Helper methods added: getTagName, getLocationInView, moveToObject. Also added some tests.
- 2011-11-07: Found bug that caused the incompatibility with Selenium Grid 2.
@@ -29,4 +29,46 @@ p
width: 300px;
height: 800px;
background-color: orange;
+}
+
+#dragContainer
+{
+ width: 300px;
+ height: 90px;
+ border: 2px solid black;
+ position: absolute;
+ left: 500px;
+ top: 100px;
+ background-color: #aaa;
+ padding: 5px;
+ z-index: 100;
+}
+
+.dragItem
+{
+ width: 88px;
+ height: 88px;
+ background-color: lime;
+ float: left;
+ line-height: 88px;
+ text-align: center;
+ border: 1px green solid;
+ margin-right: 5px;
+}
+
+#dropContainer
+{
+ width: 300px;
+ height: 90px;
+ border: 2px solid black;
+ position: absolute;
+ left: 500px;
+ top: 220px;
+ background-color: #aaa;
+ padding: 5px;
+}
+
+#dropContainer.ui-state-active
+{
+ background-color: yellow;
}
View
@@ -3,13 +3,24 @@
<head>
<meta charset="utf-8" />
<title>Foo</title>
- <script type="text/javascript" charset="utf-8" src="js/lib/jquery-1.6.1.min.js"></script>
+ <script type="text/javascript" charset="utf-8" src="js/lib/jquery-1.6.2.min.js"></script>
+ <script type="text/javascript" charset="utf-8" src="js/lib/jquery-ui-1.8.16.custom.min.js"></script>
<script type="text/javascript" charset="utf-8" src="js/scripts.js"></script>
<link rel="stylesheet" href="css/master.css" type="text/css" media="screen" title="no title" charset="utf-8">
</head>
<body>
<h1>Foo</h1>
<div id="extra">Doloes</div>
+
+ <div id="dragContainer">
+
+ <div class="dragItem" id="item1">item 1</div>
+ <div class="dragItem" id="item2">item 2</div>
+
+ </div>
+
+ <div id="dropContainer"></div>
+
<div>
<input id="foo" />
</div>
@@ -21,5 +32,6 @@
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</p>
<div id="bottom">bottom</div>
+
</body>
</html>

Large diffs are not rendered by default.

Oops, something went wrong.

Large diffs are not rendered by default.

Oops, something went wrong.
Oops, something went wrong.

0 comments on commit 2eded56

Please sign in to comment.