Home > Software design >  How to retrieve session information and pass single digit value in JMeter
How to retrieve session information and pass single digit value in JMeter

Time:11-14

I have the below response on JMeter 5.2.1.

<!DOCTYPE html>
        <html>
            <head>

                <script id="web.layout.odooscript" type="text/javascript">
                    var odoo = {
                        csrf_token: "123123..",
                        debug: "",
                    };
                </script>
                <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"/>
                <meta name="theme-color" content="#875A7B"/>
                <script type="text/javascript">
                    xx.__session_info__ = {**"uid": 2,** "is_system": true, "is_admin": true, "user_context": {"lang": "en_US", "uid": 2}, "db": "test", "server_version_info": [1, 0, 0, "final", 0, "e"], "support_url": "https://www.test.com", "name": "admin", **"username": "admin"**, "partner_id": 1 };
                </script>                
                <script type="text/javascript" ...></script>
                <script type="text/javascript" ...></script>
            </head>
            <body >
            </body>
        </html>

I want to retrieve the "uid" and "username" values and pass them to the next request as a variable dynamically(uid value is 2 and username is admin)

Kindly suggest how to retrieve these values.

In addition, the uid value is very small and it's too complicated to find and replace so kindly suggest how to replace the existing id with the newly found id.

CodePudding user response:

I would suggest doing it in 2 steps:

  1. Use enter image description here

  2. Use enter image description here

End to end demo:

enter image description here

  • Related