Need to validate all options in a particular scenario in your application?
For example a list which triggers another event.
The following example takes list values and validates the exacted text appears when the value is selected:
BDD Test Case (Feature File)
Feature: Product details lookup Looking up product description Scenario Outline: Verify details for selected project Given the application is loaded When I select product '<Product>' to evaluate Then the related product '<Product>' text '<Description>' appears Examples: | Product | Description | | Qt | Test Qt, QML and QtQuick and 4JS GDC applications on Windows, Mac OS X, Linux, Unix, embedded Linux, WinCE, QNX and other RTOSes | | Java | Test AWT, Swing, SWT, RCP, Eclipse and JavaFx applications on Windows, Mac OS X, Linux and other Unix-based systems. | | Coco | C/C++, C# and Tcl code coverage (commercial evaluation) |
Test Script (Implementation File)
Given("the application is loaded", function(context, Product, Description) { startBrowser("http://www.froglogic.com/squish/evaluate.php"); }); When("I select product '|any|' to evaluate", function(context, product, description) { productString = getItemFullStringValue(":froglogic • • Evaluate Squish.d[product]_select-one", product) selectOption(waitForObject(":froglogic • • Evaluate Squish.d[product]_select-one"), productString); }); Then("the related product '|any|' text '|any|' appears", function(context, Product, Description) { waitFor("object.exists(':froglogic • • Evaluate Squish.productdescription_SPAN')", 20000); test.compare(findObject(":froglogic • • Evaluate Squish.productdescription_SPAN").simplifiedInnerText, Description); }); function getItemFullStringValue(obj, subStr){ listObj = waitForObject(obj); listObjArray = listObj.options(); subStrRegex = new RegExp(subStr, "i"); for(var i=0; i < listObjArray.length; i++){ fullString = listObjArray.at(i).text; if(subStrRegex.test(fullString)){ test.log("String found at index " + i + "."); return fullString; } } test.fail("Sub-string " + subStr + " not found."); return false; }