Verify a Dynamic Chart in Selenium WebDriver

How to use automated testing on dynamically updating charts

Courtney Zhan

--

In a previous article, I covered how to use automated testing for SVG charts and Canvas charts. Another scenario you may want to test with charts, is dynamic charts.

Dynamic charts are charts that auto update with new information. This one below updates every 2 seconds.

Example of a Dynamic Chart using ChartJS

Suppose you have a testing requirement to check the graph is dynamic. How could you use an automated test to verify that the chart gets updated over time?

Test Steps

  1. Verify the chart exists and take a snapshot
  2. Wait for the chart to update
  3. Take another snapshot of the chart
    If desired, you can repeat steps 2–3 more times.
  4. Verify the snapshots are all different

1. Verify the chart exists and take a snapshot

In my last article, I provided an example and the code to extract a snapshot of a canvas. Link below:

--

--