this is the code I'm using
var sys, zombie,site;
zombie = require('zombie');
sys = require('sys');
site = "https://somesite.co.il"
describe("testing site: "+site, function() {
it('responds 200 OK', function() {
zombie.visit(site, function(err, browser) {
expect(browser.statusCode).toEqual(200);
//This method is a part of jasmine-node
asyncSpecDone();
});
});
it('title should be a specfiic title', function() {
zombie.visit(site, function(err, browser) {
expect(browser.text('title')).toEqual('טקסט בעברית');
//console.log(browser.text('title'));
asyncSpecDone();
});
});
it("should fail logging with wrong password", function(err, browser){
zombie.visit(site,{debug:true},function(err,browser){
browser.
fill("#email","us...@gmail.com").
fill("#password", "aaa").
pressButton(".loginbutton", function(){
//console.log(browser.text("#errorarealogin"));
expect(browser.text("#errorarealogin")).toContain("שגויים");
//assert.equal(browser.text("title"),"טקסט בעברית")
//asyncSpecDone();
expect(browser.html("#errorarealogin")).toBeDefined();
});
expect(browser.text("#errorarealogin")).toContain("שגויים");
expect(browser.html("#errorarealogin")).toBeDefined();
asyncSpecDone();
//console.log("should fail logging with wrong password");
//asyncSpecDone();
})
})
it("should succeedin logging in",function(){
zombie.visit(site,{debug:true},function(err,browser){
browser.
fill("#email","us...@gmail.com").
fill("#password", "password").
pressButton(".loginbutton", function(){
//assert.equal(browser.text("title"),"טקסט בעברית")
});
expect(browser.success).toBeTruthy();
asyncSpecDone();
})
})
afterEach(function() {
//So is this.
asyncSpecWait();
});
});
and this is the results I get from jasmine-node (without the debugging web info):
testing site: https://somesites.co.il
responds 200 OK
title should be a specific title
should fail logging with wrong password
should succeedin logging in
Failures:
1) should fail logging with wrong password
Message:
Expected '' to contain 'שגויים'.
Stacktrace:
Error: Expected '' to contain 'שגויים'.
at new jasmine.ExpectationResult (D:\Users\Alonisser\AppData\Roaming\npm\node_modules\jasmine-node\lib\jasmine-node/
jasmine-2.0.0.rc1.js:102:32)
at null.toContain (D:\Users\Alonisser\AppData\Roaming\npm\node_modules\jasmine-node\lib\jasmine-node/jasmine-2.0.0.r
c1.js:1171:29)
at zombie.visit.debug (D:\Users\Alonisser\workspace\zombie\zombieSpec.js:47:49)
at Browser.visit (D:\Users\Alonisser\node_modules\zombie\lib\zombie\browser.js:339:16)
at Browser.wait (D:\Users\Alonisser\node_modules\zombie\lib\zombie\browser.js:192:16)
at EventLoop.wait.done (D:\Users\Alonisser\node_modules\zombie\lib\zombie\eventloop.js:202:18)
at process.startup.processNextTick.process._tickCallback (node.js:244:9)
2) should fail logging with wrong password
Message:
timeout: timed out after 5000 msec waiting for spec to complete
Stacktrace:
undefined
Finished in 18.1 seconds
what am I doing wrong? I validated that the div id is correct and it does contain the specific text but it fails even if I comment out the whole expect thing, can't figure this one by myself. thanks for the help
update: I do know that this is some async problem, since littering the code with browser.log (like console.log) I can see the inside of pressButton
is processed after the code just beneath it. but I can't figure out how to solve it, tried adding browser.wait()
function inside pressButton()
but that didn't help either. I also tried setting the waitFor function attribute like this waitFor=15000
but that didn't help either.
maybe I should switch to mocha, maybe that would better for me
another update:mocha didn't help, since the lack of help here or in the google group I moved to casper.js (based on phantomjs) which works much better(for me atleast). not blaming anyone but me, but the lack of a strong community worked against me here. guess this question is closed. also I would reward the right answer if one arises, just for pure curiosity