Forum Discussion

SS01's avatar
Occasional Contributor
3 years ago

Writing script test to validate text which has some part dynamic but the rest remains the same

I would like to know a way to validate some text on search page using javascript which is returning number of items based upon what has been searched but the remaining text remains the same (e.g. 20 items found or 0 items found where 20 and 0 can change but remaining text remains the same). I would want the test to pass as long as there is a number coming back doesn't matter if it is a zero. A test should fail if nothing is coming back in the number place.

3 Replies

    • SS01's avatar
      Occasional Contributor

      Thanks for that. Could you please also suggest which method out of these would work here to validate a static text containing some dynamic number so the test pass. If it is returning a number anything >=0 it should pass else fail. 

      • Mr_Bro's avatar
        Frequent Contributor

        try using the aqstring.find to validate the substring of the complete text and based the result you can log the message or error