Verify a Dynamic Chart in Selenium WebDriver
How to verify a chart changed in Selenium WebDriver
4 min readMay 22, 2022
A repost of the aggregate of my daughter’s two articles with permission and slight modification. I added it here for the convenience of my blog subscribers. You can find more Selenium examples like this one in my eBook: Selenium WebDriver Recipes in Ruby. This is also included in my “How to in Selenium WebDriver” series.
Here is one chart that updates every a few seconds.
This article shows an automated test, in Selenium WebDriver, to verify this chart is actually dynamic, i.e. changes.
Table of Contents:
· Test Design
· Test Steps
∘ 1. Verify the chart exists
∘ 2. Extract the Canvas & Save the chart to a file
∘ 3. Verify the image file
∘ 4. Wait for the chart to update
∘ 5. Take another snapshot of the chart
∘ 6. Verify the snapshots are different
· Completed Test Script
Test Design
- Verify the chart is present by checking the
canvas
orsvg
tag - Extract the Canvas & Save the chart to a file
- Verify the image file
- Wait for the chart to update
- Take another snapshot of the chart
- Verify the snapshots are all different