18 January 2026:


This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.



Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.

Dynamic assertion

ellinorellinor Members
edited November -1 in Sahi - Open Source
I want to be able to assert text that is not the same from time to time. For example, the text can be "Result: 1010" but it can also be "Result: 912". Is there a way to replace the numbers (1010 and 912) with something else that means "anything"? (_assertContainsText("Result: ???", _byId("lblNumResult"));

Comments

  • Hi,

    Check if this works (if u dont knw the number beforehand):
    _assertContainsText(/Result: \d*/, _byId("lblNumResult"));
    
    and this if you want a variable:
    var $num = "123";
    _assertContainsText("Result: "+$num, _byId("lblNumResult"));
    
    Regards,
    Pankaj.
Sign In or Register to comment.