How to detect a change since last load in a particular web page element?

I want to create a macro that detects whether anything in a certain element of a certain web page changes, and if so, takes a screenshot of the element and saves the contents of the element to CSV (text and hyperlinks).

For the time being, I have a crude start to this, which simply detects whether the element is present based on its ID. So for now, whenever the element is present, it just takes a screenshot of the element, exports it with a timestamp, and saves the element’s visible text, the element’s source code, and the timestamp to CSV.

The trouble with that is the element can change at any time, but letting the macro run for several hours or a whole day to capture as many changes as possible results in a lot of redundant screenshots and CSV lines since it’s currently just detecting whether the element is there, and if so, saving a new screenshot and CSV line.

So I’m wondering if there’s some way to not simply detect whether the element is there, but also whether any of its contents have changed since the last time it was loaded, and only export a new screenshot and add to the CSV if it has changed. (That is, I only want to detect changes within that particular element–not the rest of the page outside of the element.)

Here’s a recap of the logic:

  • Open web page
  • Is “SomeStuff” element present?
  • If no, start over. If yes, has “SomeStuff” element changed since last run?
  • If no, start over. If yes, save text/URLs within “SomeStuff” element to CSV, and export a screenshot of “SomeStuff” element, then start over.

It’s that third bullet about detecting a change that I would like to address now–can that be done with UI.Vision RPA, and if so, how?

Hi,

There are few ways I can think about how to do this. But non of them are very practica.

  1. Use the clipboard. Load the value into the clipboard and on the second run read if from the clipboard. However you must make sure that the clipboard is not overwritten in the meanwhile by anything else
  2. Use a while loop. You run the script one time and use a while loop inside with a pause timer for how long you want to wait for the next validation process
  3. You can store values in a csv file. Store the value in a csv file and then on the next run read it from the csv file. However I do believe you have to load the csv file manually into the console before running the script.
  4. There is a command called LocalStorageExport. I have not used it yet but you might want to look into this command to find out how it works. Could potentioally solve your issue.
  5. extended the clipboard solution: before the script ends store the value in a clipboard. Then call with xrun a windows batch file (you have to write) to store the value from the clipboard into a file on your computer. When you start the script, in the beginning, execute with xrun another batch file that reads the value from the text file you have stored previously into the clipboard. From there you can access the value with your script.

The batch file to store the clipboard into the file has to be have those two commands:
set outputFile=h:\file.txt
powershell -command “Get-Clipboard” > “%outputFile%”
And to read from the batch file use these commands:
set inputFile=h:\file.txt
powershell -command “Get-Content ‘%inputFile%’ | Set-Clipboard”