Created
February 6, 2014 06:42
-
-
Save drewwells/8839350 to your computer and use it in GitHub Desktop.
run via `casper test index.js`
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var base = 'http://m.retailmenot.test'; | |
var url = base + '/view/macys.com'; | |
function getCookie (page, name) { | |
var cookies = page.cookies; | |
var val; | |
cookies.forEach(function (cookie) { | |
if (cookie.name === name) { | |
val = cookie.value; | |
} | |
}); | |
return val; | |
}; | |
var page1, page2, success, id, | |
ufv = [], | |
sliceCookie = []; | |
casper.test.begin( | |
'Cookies did not change across pages', function(test) { | |
casper.userAgent('iphone'); | |
casper.start(url, function() { | |
ufv.push(getCookie(this.page, 'userFlashVersion')); | |
sliceCookie.push(getCookie(this.page, 'slice')); | |
/*page1 = 'Slice: ' + | |
getCookie(this.page, 'slice') + | |
' url: ' + this.getCurrentUrl() + | |
' userid: ' + | |
getCookie(this.page, 'userFlashVersion');*/ | |
}); | |
casper.then(function(){ | |
id = this.evaluate(function(){ | |
$(".js-offer").eq(0).trigger('tap'); | |
$(".js-bad-touch span").eq(0).trigger('click'); | |
return $(".js-bad-touch").data('offer-id'); | |
}); | |
if (id) { | |
success = true; | |
} | |
}); | |
casper.then(function(){ | |
casper.thenOpen(base + '/showcoupon/' + id, function(){ | |
console.log('oc_slice: ' + getCookie(this.page, 'oc_slice')); | |
ufv.push(getCookie(this.page, 'userFlashVersion')); | |
sliceCookie.push(getCookie(this.page, 'slice')); | |
test.assertEquals(ufv[0], ufv[1], 'userFlashVersion matches'); | |
test.assertEquals(sliceCookie[0], sliceCookie[1], 'slice matches'); | |
}); | |
}); | |
casper.run(function(){ | |
console.log(getCookie(this.page, 'oc_slice')); | |
test.done(); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment