I found a trick if you use jquery you can register a global listener :
First you need to declare a global variable in your main script :
var globalVariableForSelenium = "";
In your selenium you register the listener :
if (driver instanceof JavascriptExecutor) {
((JavascriptExecutor) driver)
.executeScript("$(document).ajaxSuccess(function(event, xhr, settings) { globalVariableForSelenium = settings.headers });");
}
Then you execute your action
Finaly you get the value of the global variable :
if (driver instanceof JavascriptExecutor) {
Object res = ((JavascriptExecutor) driver)
.executeScript("return serializeGlobalvariable();");
}
serializeGlobalvariable() is a function that will serialize globalVariableForSelenium which contains an array of header.
ps: my need was to access to the ajax response so I set the global variable with xhr.responseJSON.mypath