Morty
12 years agoNew Contributor
How to assert ajax response in a web page
Hi Guys,
I'm new with the soapui so please bear with me is i ask stupid questions.
I'm trying to test a sample web page that loads a div content dynamically ( ajax request to server). When i try to do an assert for the response to that web page i get the div content before the ajax returns. i also added delay in the test steps and added the assert after the delay. Still the div is empty. i guess that the assert looks at the content of the page initially laoded and doesn't take into consideration the modified div.
Probably i'm doing something wrong so any help will be appreciated.
Below is the assertion criteria written in JavaScript:
I'm new with the soapui so please bear with me is i ask stupid questions.
I'm trying to test a sample web page that loads a div content dynamically ( ajax request to server). When i try to do an assert for the response to that web page i get the div content before the ajax returns. i also added delay in the test steps and added the assert after the delay. Still the div is empty. i guess that the assert looks at the content of the page initially laoded and doesn't take into consideration the modified div.
Probably i'm doing something wrong so any help will be appreciated.
Below is the assertion criteria written in JavaScript:
var x = messageExchange.getResponseContent();
var matches = x.match(/<div id="results" style="width:100%;">([^<]*)<\/div>/);
if (matches != null) {
log.info(matches[1]);
}