Forum Discussion
Think you can do it using Event Handlers
Create a event handler of type 'RequestFilter.filterRequest' and use a script like below. Customize for your need accordingly
def headers = request.requestHeaders
headers.clear()
headers.put( "my_header", "header_value" )
request.requestHeaders = headers
Regards,
Gilu Gopi
Thanks for responding, I got what your are telling, but I am not sure exactly how I can do it.
for every test case[10-30 step steps] I need to replace the whole header with different. can u describe how to do it..
- gilugopi9 years agoContributor
The event handler you create will by default apply to all requests in the project ( unless you specifically populate target column with a regular expression to select any specific requests only)
1. So as I mentioned above create an event handler of type 'RequestFilter.filterRequest' for the speficic project where you want to update headers.
2. Copy paste below code in the script for event handler
def headers = request.requestHeaders
headers.clear()
headers.put("header_1","value_1")
headers.put("header_2","value_2")
request.requestHeaders = headers3. modify header_1, header_2 and and it's values to what you need. Add more rows of headers.put if you need to add more than two headers.
4. Then execute your test cases.
Right before execution of each request, this event handler will remove all your existing headers and add the specific headers mentioned in script to your requests. If you execute whole project all requests will be updated.
Once everything is update, go to even handler window and disable the script and save your project.
Related Content
- 2 years ago
- 5 years ago
Recent Discussions
- 5 days ago
- 10 days ago