Can't figure out if it's possible to track this element

I need to track a simple number that is updated in real time by the website that’s always in the same space, but here’s the problem: the Xpath changes somewhat every time if you reload a page.

Sometimes I can read the variable once, and right now I can’t even make it read it once properly (Xpath now insists it’s empty while JS address gets a very long error with many wep addresses in it like AWS and yandex).
The extension really wants to load a new page every time it checks, but that would be a deal breaker as every reload changes the Xpath. Here’s how my Xpath looks:

//div[@id=‘app-layout’]/aside[@class=‘leftSide___nuhS’]//div[@class=‘sideMenu__s3wnX’]//div[@class=‘items__Dhczs’]/div[contains(@class,‘item__Udd0_’)]/div[@class=‘icon__NfwSQ’]/div[@class=‘badge__azvJx’]/div[@class=‘container__n3lSi’]/div[contains(@class,‘badge’)]/span)

See those icon__XXXXX? The XXXXX part changes every reload, it seems. Maybe even without reloads, not 100%

Is there a way around this? I can’t seem to make it scan this variable in static mode for some reason as it insists it’s empty, and in dynamic mode it loads a new page which changes Xpath AND kicks me from my account as only one instance of this page in question can be opened at a time.

Any ideas with this extension?

1 Like

Hey @Rajhin, the expression does look very brittle because of the autogenerated parts. It could be possible to manually create an expression that is more stable. Is the page you are monitoring publicly accessible?

1 Like

Sorry for late reply. Unfortunately no public access, it’s a work related tool.

I thought myself that I could do something like "“expr”: “//*[@data-qa-id=“side-menu-item-visitors-badge”]/div/div/span” and it would find it on the page automatically. But I think I’m messing up in syntax somewhere here, I get SELECTION_EMPTY error. I just need that span value on the bottom to be logged every 15 minutes or so, that’s really it.

1 Like

Using data-qa-id is a good idea. One likely source of problem are the quotes character. Note that in the config all quotes characters are " but in your post they are and . Can you use " everywhere are try again?

You can also try one of the following variant to see if it works:

  • /*[@data-qa-id=“side-menu-item-visitors-badge”]
  • /*[@data-qa-id=“side-menu-item-visitors-badge”]//*[contains(@class,'badge')]
1 Like

For some reason I can’t save “//*[@data-qa-id=“side-menu-item-visitors-badge”]/div/div/span” expression in the config, it bizarrely reverts to whatever was before in there no matter what. Hmm.

And your options do save but give me “Not a valid Xpath expression” error.

1 Like

Ah, I made the same mistake when copying the expression! :man_facepalming:
Try using " instead of all and . Corrected expressions are as follows:

//*[@data-qa-id="side-menu-item-visitors-badge"]/div/div/span
//*[@data-qa-id="side-menu-item-visitors-badge"]
//*[@data-qa-id="side-menu-item-visitors-badge"]//*[contains(@class,'badge')]

Notice the difference between the double quote characters. I had also missed a slash at the front.

Cheers!

1 Like

I think I found the combination that SHOULD work, it even logged value once (!), but when that value changes to something and the extension checks again it can’t see it anymore for some reason and returns “SELECTION EMPTY” error.

Does the extension tether to a tab I have open when it’s in static mode (not a dynamic update)? Or is it trying to access the web address it has “on it’s own”? Because it would only be able to read it in my open local tab.

All those Xpaths run well in the “select element” menu while in the tracked tab, grabbing the value easily and quickly as it changes, but when you try to set up the automated task off the tab in the extensions own menu after pressing “save selections” it just doesn’t work and it can’t see the same value (EMPTY) that it tracked well just moments before.

1 Like

Using a schedule based interval, Distill will open a new tab for dynamic pages. For static, it won’t open any page - they will be loaded in background.

Does this page update the badge count automatically without you needed to reload the page? In that case, you can try using “Live” mode to schedule checks. It will open a tab and keep that open instead of closing and opening again. Then it will monitor that tab for any changes and alert you in realtime.