Mac PAW app - enter form authentication token

I am trying to automatically authenticate Paw, and for this I need

  • request login page
  • parse html response to get authentication token from login form
  • send authentication request

but I don’t know how to do it ...

Does anyone have an idea?

thanks

+4
source share
1 answer

In the paw, first configure the request for the login page. Then, in the second request, you can define the response body of the first request: we can use the regular expression filter on the raw response of another request.

create custom dynamic value: Adding a custom dynamic value

then use the code below to set a custom dynamic value.

function evaluate(context){
	// Set up your regex to extract the token
	var re = /<h2>([^<]+)<\/h2>/;
	
	// Replace the 'Login page' with your request name 
	var request = context.getRequestByName('Login page')
	var lastExchange = request.getLastExchange()
	var body =  lastExchange.responseBody
	
	var m = re.exec(body)
	return m[1]
};
Hide result
+3

Source: https://habr.com/ru/post/1618449/


All Articles