ebrehault / resurrectio

CasperJS test recorder Chrome extension
GNU General Public License v2.0
721 stars 106 forks source link

Navigate with this Link #4

Closed SeriousM closed 11 years ago

SeriousM commented 11 years ago

Hi,

can we get a function that says something like

rmb on link use link

so that the elements existence is checked, the href must match and then a mouse-click of the element?

Cheers

ebrehault commented 11 years ago

At the moment, when you click on a link, the resulting casperjs test does assert the element exists and then clicks on it. So what you propose is to also assert that the href is the one expected, correct ?

SeriousM commented 11 years ago

Yes and if I have seen it correctly the script contains a click with coordinates which should not be the case. It is not good because the script depends on the recording browser's resolution/size.

var x = require('casper').selectXPath;
var casper = require('casper').create();
casper.options.viewportSize = {width: 1920, height: 1137};
casper.start('http://wetter.orf.at/oes/');
casper.then(function() {
    this.mouse.click(725, 187);
});

casper.run(function() {this.test.renderResults(true);});
ebrehault commented 11 years ago

Yes indeed, mouse click is not always properly handled right now. The idea here is to be able to produce special click sequences (like drag&drop for instance), so Resurrectio records x and y for all mouse down and mouse up events. When generating the CasperJS script, depending on the object we clicked, it should produce either a click event on the element, either a (x, y) click. In your case, it comes form this line: https://github.com/ebrehault/resurrectio/blob/master/casper.js#L268 your clicked element is probably not a a, an input or a button.

SeriousM commented 11 years ago

My element was a div wrapped in a a-tag. I understand and like the way how you deal with links because not everything is a link, it is maybe just a bound js-function. The disadvantage is that an element on a pages with dynamic content can be "anywhere", take the Comment button on this github page.

Can't you just locate the element and then click on it? Or add a context menu to choose the right action, not the default one.

Cheers :)

ebrehault commented 11 years ago

Now there is an option to generate the Casperjs script using (x,y) moure event events specifically. With regular mode, for now, for all elments but a, input or button, it only work if the lement has an id.

ebrehault commented 11 years ago

see https://github.com/ebrehault/resurrectio/issues/5 which aims to improve this behaviour

SeriousM commented 11 years ago

I still have a problem with that but it is more a bug.

I have this workflow: http://i.imgur.com/ThnfuLr.jpg.

when i export it as "Export CasperJS" this is the result: https://gist.github.com/SeriousM/5747073#file-casperjs (focus on the massive undefined)

with x,y everithing looks legit: https://gist.github.com/SeriousM/5747073#file-casperjs-x-y

Cheers

ebrehault commented 11 years ago

well I am not sure I made exactly the same workflow, but here is what I get: https://gist.github.com/ebrehault/5747228

SeriousM commented 11 years ago

hmmm, i thought pulling latest version and click "update extensions" were enough. nope :) reinstalled the extension -> works fine!

ebrehault commented 11 years ago

Actually, the easiest way is:

It should be enough.

SeriousM commented 11 years ago

I totally not saw this button, thx :)