Search code examples
regexgatling

Gatling save response in html redirect


I make one call that leads to 5 other redirects. On the last redirect I want to obtain the value for href (in the response below)

 <li class="list-group-item">
    <a id="Test IDP" class="ln-List_Element" tabindex="(3" title="Velg Test IDP" href="/Account/ExternalLogin?provider=testidp-oidc&amp;returnUrl=%2Fconnect%2Fauthorize%2Fcallback%3FauthzId%3DA87F0EE6346DD8A06C5C278988CE904448BDBA65EAD3B7668C3F2F00B5540F01">
        <div>
                <span class="ln-List_Element_Logo">
                    <img src="/img/test-idp.png" alt="Test IDP">
                </span>
        </div>

Two questions, is it possible to save response values if I am redirected? And what would be the expression I would use in this exact case? Something like

.check(regex("ID=\"Test IDP\" name=\"href\" value=\"(.*?)\"").saveAs("href")))

Solution

  • You can extact by css selector. Something like that:

    css("a[id='Test IDP']", "href").saveAs("testHref")