Monitoring dynamically generated elements

Hi.

I have looked at all of the support posts involving dynamic content etc, but could not find a specific solution to what I think must be a common issue.

Pages that I monitor contain dynamic Xpath elements that change daily. Every day the monitors break because they can no longer find the previous day’s element. What is the best way around this please?

Example
https://www.bunnings.com.au/fiskars-x25-xl-splitting-axe_p3360996

The Xpath element to monitor the price of this item looks something like this

//main[@id='main']/div[contains(@class,'jINGaM')]/div[@class='container-main']//div[contains(@class,'dmAWSL')]/div//div[@class='container']/div[contains(@class,'MuiGrid-root')]/div[contains(@class,'productDetails')]/div[contains(@class,'doa-dFD')]/div[contains(@class,'MuiGrid-root')]/div[contains(@class,'MuiGrid-root')]/div[contains(@class,'dhNsnU')]/div[contains(@class,'dVChWy')]//p[contains(@class,'dwOrgK')]

As you can see, many of the @class elements contain dynamically generated random codes

Eg:

(@class,'******')

Am I best to target the parent class, use wildcards, or would Ihave more luck using a CSS or Javascript selector?

Many thanks for you help!

Hello Andrew, I think you have identified the problem correctly. The autogenerated XPath expressions contain parts that seems to change quite frequently. This makes the selectors unstable.

We recently updated the Chrome and Edge extensions (3.6.17+) to create much better selectors. It does that by trying to remove to unstable looking parts from the selector. If you are using the Firefox extension, which is still on 3.6.12.

Can you try using the webapp at monitor.distill.io or the Chrome extension to select the elements? Thanks!

Thanks. I reset the monitor using the updated selectors and it seems to be working well. Brilliant. Great update. Thanks so much!

1 Like