tikiwiki/packages/tiki-pkg-casperjs/jerome-breton/casperjs/samples/multirun.coffee
2023-11-20 20:52:04 +00:00

38 lines
871 B
CoffeeScript
Executable File

casper = require("casper").create verbose: true
countLinks = ->
document.querySelectorAll('a').length
suites = [
->
@echo "Suite 1"
@start "http://google.com/", -> @echo "Page title: #{@getTitle()}"
@then -> @echo "#{@evaluate(countLinks)} links"
->
@echo "Suite 2"
@start "http://yahoo.com/", -> @echo "Page title: #{@getTitle()}"
@then -> @echo "#{@evaluate(countLinks)} links"
->
@echo "Suite 3"
@start "http://bing.com/", -> @echo "Page title: #{@getTitle()}"
@then -> @echo "#{@evaluate(countLinks)} links"
]
casper.start()
casper.then ->
@echo("Starting")
currentSuite = 0;
check = ->
if suites[currentSuite]
suites[currentSuite].call @
currentSuite++;
casper.run check
else
@echo "All done."
@exit()
casper.run check