How to check if a page has been updated

While not built as a monitoring tool, Axiom.ai can be used to check if a page has been updated. There are a few requirements to this, you will need to identify elements on the page that may update and that you will be using as a determinant for whether or not the page has been updated, for example, an 'add to cart' button on a page that may show 'out of stock' when the products are sold out.

If you want to have the automation check the page with any cadence, you will need to have access to scheduling - this will enable you to set this on a schedule that checks based on the cadence that you need it to.

# Checking for updates


Identifying a changed value on a page is one of the best methods of checking if a page has been updated. There are four things that you will need to do to get started with this:

  1. Identify the element to check.
  2. Determine how this element will change - will it change to a set value, will the element not be present on the site, etc.?
  3. Store the previous value, to check against the new value.
  4. Overwrite the previous value with the new value, so later checks can work as expected.

# Handling changed values


To handle a changed value on the page, for example, the text of a button being changed, you will need to create an automation that can check the previous value versus the new version. To get started, you will need to ensure that you have Google Sheets or Microsoft Excel connected. When ready, follow the steps below:

  1. Add a "Read data from a [Google Sheet/Excel]" step, the "First cell" and "Last cell" options should be set to "A1".
  2. Add a "Go to page" step to navigate to the page.
  3. Add a "Get data from bot's current page" step - set this to scrape the element that you wish to check, for example, the text of a button.
  4. Add a "If condition" step - set this to check the value from step 1 against the data acquired from step 3.
  5. Inside the "If condition" step, add a "Write data to a [Google Sheet/Excel]" step to write the value from step 3, setting "Clear data before writing" and "A1" as the cell to write to.

Note, we recommend adding a value into cell A1 of the sheet before running the automation, or enabling the "Continue when empty" setting within the "Read data from a [Google Sheet/Excel]" step.

Step 5 would imply that the page has changed.

# Handling missing elements


There may be instances where the page changes by removing certain elements from the page. Amazon is a good example of this, where the 'add to cart' button will not be present on the page when the item is unavailable. Using the method above will not work in this case as it will cause the automation to run into an error due to the element not being found on the page. Follow the steps below to get started:

  1. Add a "Go to page" step to navigate to the page.
  2. Add a "Try/Catch" step into your automation.
  3. Inside the "Try" portion of the "Try/Catch" step, add a "Get data from bot's current page" step - set this to scrape the element that you wish to check, for example, the text of a button.
  4. Inside the "Catch" portion of the "Try/Catch" step, add any steps that you would like to run in the event of the element not being present, such as a "Send an email" step, or "Trigger webhook" step.

Note, this will not check for the changed value, simply the existence of the element on the page.

Step 4 would imply that the page has changed.

# Combining the two methods


There may be instances where you want to be 100% sure that any changes are recorded, both of the above methods can be combined. To get started, you will need to ensure that you have Google Sheets or Microsoft Excel connected. When ready, follow the steps below:

  1. Add a "Read data from a [Google Sheet/Excel]" step, the "First cell" and "Last cell" options should be set to "A1".
  2. Add a "Go to page" step to navigate to the page.
  3. Add a "Try/Catch" step into your automation, steps 4.6 should be included in the "Try" portion of this step.
  4. Add a "Get data from bot's current page" step - set this to scrape the element that you wish to check, for example, the text of a button.
  5. Add a "If condition" step - set this to check the value from step 1 against the data acquired from step 3.
  6. Inside the "If condition" step, add a "Write data to a [Google Sheet/Excel]" step to write the value from step 3, setting "Clear data before writing" and "A1" as the cell to write to.
  7. Inside the "Catch" portion of the "Try/Catch" step, add any steps that you would like to run in the event of the element not being present, such as a "Send an email" step, or "Trigger webhook" step.

Step 6 and step 7 in this process would imply that the page has changed.

# Wrapping up


If you would like to learn more about any steps that have been mentioned in this guide, we would recommend checking out steps documentation.