ok scriptStep: test fictitious order page with inlined Groovy script

Test started at Wed Apr 25 13:12:07 CEST 2012, lasting 497 ms.
Source: /raid/volume1/opt/webtest/webtestCC/CanooFunctionalTesting/selftests/tests/scriptStep.xml:170:
Base URL (used by invoke steps with a relative URL): http://localhost:19090/selftest/
Simulated browser: IE6
#ResultNameParameterDuration
  1okinvoke
Load Order Page
Resulting page
-> complete urlhttp://localhost:19090/selftest/order.html
urlorder.html
41
  2okscriptStep
check qty and price
languagegroovy
nested textcalc_qty = 0 calc_price = 0 document.getElementsByAttribute('tr', 'class', 'lineitem').each{ table_cells = it.getHtmlElementsByTagName('td') qty = table_cells.get(1).asText().toInteger() unit_price = table_cells.get(2).asText().toInteger() total_line_price = table_cells.get(3).asText().toInteger() calc_qty += qty calc_price += total_line_price assert qty * unit_price == total_line_price } root = new XmlSlurper().parseText(document.asXml()) totalCols = root.depthFirst().findAll{ it.name() == "tr" }.find{ it['@class'] == 'total' }.td // slightly shorter alternative to above if you don't mind explicitly specifying tr // totalCols = root.body.table.tbody.tr.find { it['@class'] == 'total' }.td assert calc_qty == totalCols[1].text().trim().toInteger() assert calc_price == totalCols[3].text().trim().toInteger()
script calc_qty = 0 calc_price = 0 document.getElementsByAttribute('tr', 'class', 'lineitem').each{ table_cells = it.getHtmlElementsByTagName('td') qty = table_cells.get(1).asText().toInteger() unit_price = table_cells.get(2).asText().toInteger() total_line_price = table_cells.get(3).asText().toInteger() calc_qty += qty calc_price += total_line_price assert qty * unit_price == total_line_price } root = new XmlSlurper().parseText(document.asXml()) totalCols = root.depthFirst().findAll{ it.name() == "tr" }.find{ it['@class'] == 'total' }.td // slightly shorter alternative to above if you don't mind explicitly specifying tr // totalCols = root.body.table.tbody.tr.find { it['@class'] == 'total' }.td assert calc_qty == totalCols[1].text().trim().toInteger() assert calc_price == totalCols[3].text().trim().toInteger()
456

Back to Test Report Overview