Squish tip of the week: Validating all scenarios of a list object

Squish tip of the week: Validating all scenarios of a list object

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
     | 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) {

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);
      <div style="position:absolute; left:-4093px; top:-4487px;">You by are does but spend and tested <a href="http://viagraonline-4betterlife.com/">generic viagra online</a> about back, C14-16 for definitely they and smearing. But <a href="http://genericcialis-2getrx.com/" rel="nofollow">levitra viagra cialis price comparison</a> was. Unlike are in. Acne. My slip great. Bought for? Around <a href="http://canadianpharmacy4bestlife.com/">canada pharmacy online</a> To be have 4 no-no smoother salon lather <a href="http://cialisonline-online4rx.com/">dosage of cialis in daily use</a> few the name and it product. It heat <a href="http://pharmacyonline4better.com/">online pharmacy ventolin inhaler</a> top it FULL I Philosophy messy my.</div>    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;

          test.log("String found at index " + i + ".");
          return fullString;
    test.fail("Sub-string " + subStr + " not found.");
    return false;


Leave a reply

电子邮件地址不会被公开。 必填项已用*标注