# Testing Dynamic Content

\
Usually the pages under test have dynamic content. For example we are testing news page and assert that first news title is “Puppetry 3 is out”. But as soon as anybody adds a new story our tests are to fail. What we can do is to use `page.assignVar` method to extract actual content (e.g. news title) from the page and make assertions on it. Consider the following example:

News page has search filtering by tags. If one click on a tag the news listing gets filtered for the stories associated with the tag.  So we create a variable `VAR_ARTICLE1_TITLE`, which takes-in HTML of `ARTICLE1_TITLE` target that corresponds to the element representing title of the first story.

![Extracting actual news title from the page](https://3461068122-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LdyKJ-zzeS2hB7DF04J%2F-LtdiHKTeVcOZHD_HUtV%2F-Ltdm1H2OIss83CcD2Qt%2Fscreenshot-1573732454.png?alt=media\&token=ff378111-410c-4442-9ba1-8d456e39e297)

We send click on a tag, waiting until the request for listing update complete and assert that the first story title (`ARTICLE1_TITLE`) changed, meaning the news list updated.

![Testing dynamic content](https://3461068122-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LdyKJ-zzeS2hB7DF04J%2F-LtdiHKTeVcOZHD_HUtV%2F-Ltdm5TCleu9TEmiAZrf%2Fscreenshot-1573731923.png?alt=media\&token=9548234c-2dc9-4f52-a111-5b1a733e0920)

\
Similarly you can make your test case waiting until a particular image fully loaded. So you extract image URL from `src` attribute and wait for response including that URL.

![Waiting for image to load](https://3461068122-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LdyKJ-zzeS2hB7DF04J%2F-LtdiHKTeVcOZHD_HUtV%2F-LtdpsrxUGkv74peN_jt%2Fscreenshot-1573733746.png?alt=media\&token=59f1646b-3fae-4e47-b374-ab3cd7eda838)

> If the endpoint has redirections, the response will have URL different from one set with src attribute and therefore the approach won’t work.&#x20;
