1
0
Fork 0
mirror of https://github.com/teampoltergeist/poltergeist.git synced 2022-11-09 12:05:00 -05:00

Click co-ordinates are shown in the debug log.

You can use this in combination with `page.driver.render`
to work out where clicks are actually happening if you
are having trouble.
This commit is contained in:
Jon Leighton 2012-09-01 18:26:54 +01:00
parent 7218290098
commit 1ef674b9df
5 changed files with 18 additions and 7 deletions

View file

@ -183,6 +183,12 @@ makes debugging easier). Running `rake autocompile` will watch the
### 0.8.0 ### ### 0.8.0 ###
#### Features ####
* Click co-ordinates are shown in the debug log. You can use this in
combination with `page.driver.render` to work out where clicks are
actually happening if you are having trouble.
#### Bug fixes #### #### Bug fixes ####
* Prevent `TypeError: 'undefined' is not an object (evaluating * Prevent `TypeError: 'undefined' is not an object (evaluating

View file

@ -19,7 +19,7 @@ class Poltergeist.Browser
@page.onLoadFinished = (status) => @page.onLoadFinished = (status) =>
if @state == 'loading' if @state == 'loading'
this.sendResponse(status) this.sendResponse(status: status, click: @last_click)
@state = 'default' @state = 'default'
@page.onInitialized = => @page.onInitialized = =>
@ -119,11 +119,11 @@ class Poltergeist.Browser
# state and wait for onLoadFinished before sending a response. # state and wait for onLoadFinished before sending a response.
@state = 'clicked' @state = 'clicked'
node.click() @last_click = node.click()
if @state != 'loading' if @state != 'loading'
@state = 'default' @state = 'default'
this.sendResponse(true) this.sendResponse(@last_click)
drag: (page_id, id, other_id) -> drag: (page_id, id, other_id) ->
this.node(page_id, id).dragTo this.node(page_id, other_id) this.node(page_id, id).dragTo this.node(page_id, other_id)

View file

@ -28,7 +28,10 @@ Poltergeist.Browser = (function() {
}; };
this.page.onLoadFinished = function(status) { this.page.onLoadFinished = function(status) {
if (_this.state === 'loading') { if (_this.state === 'loading') {
_this.sendResponse(status); _this.sendResponse({
status: status,
click: _this.last_click
});
return _this.state = 'default'; return _this.state = 'default';
} }
}; };
@ -152,10 +155,10 @@ Poltergeist.Browser = (function() {
var node; var node;
node = this.node(page_id, id); node = this.node(page_id, id);
this.state = 'clicked'; this.state = 'clicked';
node.click(); this.last_click = node.click();
if (this.state !== 'loading') { if (this.state !== 'loading') {
this.state = 'default'; this.state = 'default';
return this.sendResponse(true); return this.sendResponse(this.last_click);
} }
}; };

View file

@ -47,7 +47,8 @@ Poltergeist.Node = (function() {
pos = this.clickPosition(); pos = this.clickPosition();
test = this.clickTest(pos.x, pos.y); test = this.clickTest(pos.x, pos.y);
if (test.status === 'success') { if (test.status === 'success') {
return this.page.mouseEvent('click', pos.x, pos.y); this.page.mouseEvent('click', pos.x, pos.y);
return pos;
} else { } else {
throw new Poltergeist.ClickFailed(test.selector, pos); throw new Poltergeist.ClickFailed(test.selector, pos);
} }

View file

@ -36,6 +36,7 @@ class Poltergeist.Node
if test.status == 'success' if test.status == 'success'
@page.mouseEvent('click', pos.x, pos.y) @page.mouseEvent('click', pos.x, pos.y)
pos
else else
throw new Poltergeist.ClickFailed(test.selector, pos) throw new Poltergeist.ClickFailed(test.selector, pos)