> For the complete documentation index, see [llms.txt](https://docs.puppetry.app/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.puppetry.app/testing-techniques/testing-dynamic-content.md).

# 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](/files/-Ltdm1H2OIss83CcD2Qt)

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](/files/-Ltdm5TCleu9TEmiAZrf)

\
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](/files/-LtdpsrxUGkv74peN_jt)

> 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;
