Just like a custom patterns is an abstraction of extractors used to create multiple specific extractors, the pattern template is an abstraction of a custom pattern that further improves autocorrelation.

    In some cases, you may need correlate multiple values by creating extractors of the same type. For example consider the following response snippet where you need to correlate ids that follow the number 834 and 836:

    HTTP Response

     

    Manual

    One way is to manually create the extractors.

    In this case an example of an extractor that can be created is: "834","([A-Z0-9]{58,})" and "836","([A-Z0-9]{58,})"

    However, you will need to create these extractors and corresponding parameters for every test case in this application.

    Custom Patterns

    Another way is to create a custom pattern regular expression pattern that will automatically create the extractors and corresponding parameters during auto-correlation.

    An example of a pattern can be: "\d{3}","([A-Z0-9]{58,})"

    After auto correlation, 2 extractors will be created: 

    • "\d{3}","([A-Z0-9]{58,})" with Occurrence 4 to extract 834 id
    • "\d{3}","([A-Z0-9]{58,})" with Occurrence 6 to extract 836 id

     

    The problem can arise when replaying the test case where the response will be significantly different. In this case, the occurrence of the desired id will change, which will lead to the wrong value being extracted.

    A better solution is to use pattern templates.

    Pattern Templates

    A pattern template is a regular expression pattern that has more than one capture group. 

    An example of a pattern can be: "(\d{3})","([A-Z0-9]{58,})" with extractor group 2 (extractor group 2 means that the second capture group should be used as extracted value)

     

    After auto correlation, 2 extractors will be created: 

    • "834","([A-Z0-9]{58,})" with Occurrence 1 to extract 834 id
    • "836","([A-Z0-9]{58,})" with Occurrence 1 to extract 836 id

     

    Notice that both extractors are very specific and have occurrence 1. If when replaying the test case the response will be significantly different, the desired id occurrence will not change. 

     

    • No labels