Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Improves Ghost.click that no more uses utils.py

  • Loading branch information...
commit ff9b77e77f8536d7680f85b983ec25af6fdd7aeb 1 parent 040807f
@jeanphix authored
Showing with 7 additions and 20 deletions.
  1. +7 −2 ghost/ghost.py
  2. +0 −18 ghost/utils.js
  3. 0  tests/uploaded_
View
9 ghost/ghost.py
@@ -284,7 +284,6 @@ def capture_to(self, path, region=None, selector=None,
self.capture(region=region, format=format,
selector=selector).save(path)
- @client_utils_required
@can_load_page
def click(self, selector):
"""Click the targeted element.
@@ -293,7 +292,13 @@ def click(self, selector):
"""
if not self.exists(selector):
raise Exception("Can't find element to click")
- return self.evaluate('GhostUtils.click("%s");' % selector)
+ return self.evaluate("""
+ var element = document.querySelector("%s");
+ var evt = document.createEvent("MouseEvents");
+ evt.initMouseEvent("click", true, true, window, 1, 1, 1, 1, 1,
+ false, false, false, false, 0, element);
+ element.dispatchEvent(evt)
+ """ % selector)
class confirm:
"""Statement that tells Ghost how to deal with javascript confirm().
View
18 ghost/utils.js
@@ -2,22 +2,4 @@
* This file includes client side javascript utilities.
*/
var GhostUtils = {
- /**
- * Clicks element for given selector.
- *
- * @param String selector A CSS3 selector that targets the element
- */
- click: function(selector) {
- var elem = document.querySelector(selector);
- if (!elem) {
- return false;
- }
- var evt = document.createEvent("MouseEvents");
- evt.initMouseEvent("click", true, true, window, 1, 1, 1, 1, 1,
- false, false, false, false, 0, elem);
- if (elem.dispatchEvent(evt)) {
- return true;
- }
- return false;
- }
};
View
0  tests/uploaded_
No changes.
Please sign in to comment.
Something went wrong with that request. Please try again.