I'd like to write a functional test on my webpage using CasperJS, that:
- Fills login form
- Submits login form
- Checks for dynamically loaded content
Two first steps I've already manage to do, but I have a problem with third one. The HTML structure I get after loggin in is not quite the one I can see inside ie. Chrome developer console. Some content is missing - it's like I would only get structure available inside my index.html file, but nothing more.
Here is my code for testing:
var casper = require('casper').create();
var loginForm = 'form[name="login"]';
var orderMenuItem = '.rst-menu-orders';
casper.start('http://ift.tt/1OY2YNR');
casper.waitForSelector(loginForm, function(){
this.echo(this.getCurrentUrl());
this.fillSelectors(loginForm, {
'input[name="username"]': '2-742',
'input[name="password"]': '1234qwer'
}, true);
});
casper.thenOpen('http://ift.tt/1MEA7if', function(){
this.echo(this.getCurrentUrl());
this.waitForSelector('.rst-tab-menu-element', function() {
this.echo(document.querySelectorAll('.rst-tab-menu-element').length);
});
});
casper.run();
So every time I run this test I get message that timeout of 5000 ms expired, which means, that the '.rst-tab-menu-element'
is not there, but I know, that it exists in the DOM, cause I can see it in Chrome ie.
I've already tried to wait for 20000ms hoping for cotent to load, but it seems, that the problem is something else. I'm using Require JS to load my javascript files and I was wondering - maybe this could be an issue? I'd be grateful for some tips how can I make this work.
Aucun commentaire:
Enregistrer un commentaire