Forum Discussion

mamar's avatar
mamar
Contributor
10 years ago

[Resolved]How to set content in Script Assertion with groovy

Hi,

I have created a script assertion in a test request using this groovy script. But i do not know how to add some groovy code in the created script assertion with the groovy script. can anyone please help me on this.

def assertion = testRunner.getTestCase().getTestStepByName(stepname).addAssertion("Script Assertion").

3 Replies

  • I have found the solution and here is the script i used.

    def stepname = testRunner.testCase.testSuite.getPropertyValue("TestRequestStepName")
    def assertion = testRunner.getTestCase().getTestStepByName(stepname).addAssertion("Script Assertion")
    assertion.setScriptText("hai from assertion.setScriptText.....")
    log.info assertion
  • hi, can any one help me with groovy scirpt, please ?

    1. I need XPATH MATch assertion in script. I need to assert Xpath match
    if XAPTH ASSERTION true
    DO this
    else
    Do this

    2. I need to access Test Request properties Remove Empty Content in script <once you click on Test Request, left bottom corner you see Test Request properties, where in we can select some options as true false, like strip whitspace, Remove Empty Contect etc,

    please help with groovy script.