I try to create casperjs script to test my page. Actual algorithm looks that (1-5 works):
1) load url (login page)
2) take ss and save as img1.png
3) find inputs (login & pass)
4) fill inputs and click submit
5) take ss of new page and save as img2.png
6) change tab (page with two tabs - I want click on second tab)
7) do something
I am not 100% sure if code is ok so I paste it here:
casper.start(url, function(){});
casper.then(function() { this.capture('img1.png'); });
casper.thenEvaluate(function() {
document.querySelector('input[name="user"]').setAttribute('value', 'jamal');
document.querySelector('input[name="pass"]').setAttribute('value', 'asd');
document.querySelector('input[name="login"]').click();
});
casper.then(function() { this.capture('img2.png'); });
casper.thenEvaluate(function() {
document.getElementById('keyword_form').getElementsByTagName('div')[0].getElementsByTagName('ul')[0].getElementsByTagName('li')[1].getElementsByTagName('a')[0].click();
// this commented line works perfectly
//document.getElementById('keyword_form').getElementsByTagName('div')[0].getElementsByTagName('ul')[0].getElementsByTagName('li')[1].getElementsByTagName('a')[0].style.background = "yellow";
});
casper.then(function() {
this.capture('img3.png');
});
On the last screen (img3) I see that tabs isn't changed. It's still default first tab. I really don't know why that happen. Any idea ?