Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixes #65, add local-ish support for drag-and-drop

  • Loading branch information...
commit f0ded80e37d56c863d1747b40dfb8e3080d9f8e6 1 parent 520da9f
@semperos authored
View
26 resources/javascript.html
@@ -0,0 +1,26 @@
+<h1>JavaScript Playground</h1>
+
+<div id="js-playground">
+ <div id="draggable">
+ <p>draggable</p>
+ </div>
+ <div id="droppable">
+ <p>droppable</p>
+ </div>
+</div>
+
+<script type="text/javascript">
+ <!--
+ $(function() {
+ $( "#draggable" ).draggable();
+ $( "#droppable" ).droppable({
+ drop: function( event, ui ) {
+ $( this )
+ .addClass( "ui-state-highlight" )
+ .find( "p" )
+ .html( "Dropped!" );
+ }
+ });
+ });
+ // -->
+</script>
View
26 resources/page.html
@@ -43,7 +43,30 @@
padding-bottom: 5px;
margin-bottom: 5px;
}
+ #draggable {
+ width: 100px;
+ height: 100px;
+ background-color: orange;
+ }
+ #draggable p {
+ margin: 5px;
+ }
+ #droppable {
+ width: 200px;
+ height: 200px;
+ background-color: red;
+ color: white;
+ }
+ #droppable.ui-state-highlight {
+ background-color: green;
+ color: black;
+ }
+ #droppable p {
+ margin: 5px;
+ }
</style>
+ <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
+ <script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.8.23/jquery-ui.min.js"></script>
</head>
<body>
@@ -56,7 +79,8 @@
<div id="footer">
<a class="menu-item" href="/">home</a> |
<a class="menu-item" href="/clojure">clojure</a> |
- <a class="menu-item" href="/example-form">example form</a>
+ <a class="menu-item" href="/example-form">example form</a> |
+ <a class="menu-item" href="/js-playground">javascript playground</a>
</div>
</div>
View
12 test/clj_webdriver/test/common.clj
@@ -91,7 +91,7 @@
(attribute (find-element driver {:tag :li, :class "first odd"}) :class)))
(is (= "https://github.com/cgrand/moustache"
(attribute (find-element driver {:text "Moustache"}) "href")))
- (is (= 8
+ (is (= 9
(count (find-elements driver {:tag :a}))))
(-> driver
(find-element {:tag :a, :text "example form"})
@@ -109,7 +109,7 @@
(text (find-element driver [{:tag :div, :id "content"}, {:tag :a, :class "external"}]))))
(is (= "home"
(text (find-element driver [{:tag :*, :id "footer"}, {:tag :a}]))))
- (is (= 3
+ (is (= 4
(count (find-elements driver [{:tag :*, :id "footer"}, {:tag :a}])))))
(defn hierarchical-querying-should-not-support-css-or-xpath-attrs
@@ -158,7 +158,9 @@
(defn drag-and-drop-by-pixels-should-work
[driver]
- (to driver "http://jqueryui.com/demos/draggable")
+ (-> driver
+ (find-element {:tag :a, :text "javascript playground"})
+ click)
;; Just check to make sure this page still has the element we expect,
;; since it's an external site
(is (-> driver
@@ -176,7 +178,9 @@
(defn drag-and-drop-on-elements-should-work
[driver]
- (to driver "http://jqueryui.com/demos/droppable/")
+ (-> driver
+ (find-element {:tag :a, :text "javascript playground"})
+ click)
;; Just check to make sure this page still has the element we expect,
;; since it's an external site
(is (-> driver
View
8 test/clj_webdriver/test/example_app/core.clj
@@ -18,8 +18,14 @@
(->> (page nil nil (example-form))
response))
+(defn view-javascript-playground
+ [r]
+ (->> (page nil nil (javascript-playground-page))
+ response))
+
(def routes
(app
[""] view-frontpage
["clojure"] view-clojure-page
- ["example-form"] view-example-form))
+ ["example-form"] view-example-form
+ ["js-playground"] view-javascript-playground))
View
4 test/clj_webdriver/test/example_app/templates.clj
@@ -8,4 +8,6 @@
(defsnippet clojure-page "clojure.html" [:body :> any-node] [])
-(defsnippet example-form "form.html" [:body :> any-node] [])
+(defsnippet example-form "form.html" [:body :> any-node] [])
+
+(defsnippet javascript-playground-page "javascript.html" [:body :> any-node] [])
View
12 test/clj_webdriver/test/taxi.clj
@@ -83,12 +83,12 @@
(is (= (text "*.external") "Moustache"))
(is (= (attribute "*.first.odd" :class) "first odd"))
(is (= (attribute "li.first.odd" :class) "first odd"))
- (is (= (count (elements "a")) 8))
+ (is (= (count (elements "a")) 9))
(is (= (text "a[class^='exter']") "Moustache"))
(is (= (text "a.external[href*='github']") "Moustache"))
(is (= (text "a[class*='exter'][href*='github']") "Moustache"))
- (is (= (count (elements "*[class*='-item']")) 3))
- (is (= (count (elements "a[class*='-item']")) 3))
+ (is (= (count (elements "*[class*='-item']")) 4))
+ (is (= (count (elements "a[class*='-item']")) 4))
(is (= (count (elements "a[class*='exter'][href*='github']")) 2)))
(deftest test-querying-under-elements
@@ -98,7 +98,7 @@
(is (= (text (find-element-under "div#content" {:css "a[class*='exter']"})) "Moustache"))
(is (= (text (find-element-under "div#content" {:css "a[href*='github']"})) "Moustache"))
(is (= (text (find-element-under "#footer" (core/by-tag :a))) "home"))
- (is (= (count (find-elements-under "#footer" {:tag :a})) 3))
+ (is (= (count (find-elements-under "#footer" {:tag :a})) 4))
(is (= (count (find-elements-under "div#content" {:css "a[class*='exter']"})) 2)))
(deftest text-exists-visible-present
@@ -114,7 +114,7 @@
(deftest test-drag-and-drop
;; TODO: Implement locally
- (to "http://jqueryui.com/demos/draggable")
+ (click (find-element {:tag :a, :text "javascript playground"}))
;; since it's an external site, make sure that draggable div is still there
(is (present? "#draggable"))
(let [el-to-drag (element {:id "draggable"})
@@ -128,7 +128,7 @@
(is (= y-diff 20))))
(deftest drag-and-drop-on-elements-should-work
- (to "http://jqueryui.com/demos/droppable/")
+ (click (find-element {:tag :a, :text "javascript playground"}))
;; Just check to make sure this page still has the element we expect,
;; since it's an external site
(is (present? "#draggable"))
Please sign in to comment.
Something went wrong with that request. Please try again.