21 Mar 2022 03:04 PM - last edited on 21 Mar 2022 03:28 PM by AgataWlodarczyk
Hi all,
I know that it's possible in browser monitors to validate against text, regex, and placeholders such as {email}.
I have a use case where I'd like to validate against today's date (i.e. the date of the execution day). A regex wouldn't be helpful in this case because there is a list of dates and I'd need a content validation of the latest.
Has anyone done something like this before? If yes, how? Or is this impossible to achieve with a synthetic monitor at all?
Thanks,
Olga
Solved! Go to Solution.
22 Mar 2022 10:35 AM
Hi Olga,
yes, date validation and manipulation are both possible in Dynatrace Synthetic. You can use api.date() to get the current date in epoch format. Then you can either convert it or compare it to a list of other epoch dates.
23 Mar 2022 09:59 AM
Hi Hannah,
good to know, thanks!
Just to confirm: api.date() will also work with manually added JS events within browser clickpaths? Because I have only seen this reference only in the documentation section for HTTP monitors
23 Mar 2022 10:17 AM
Apologies, you're right. We need to use Date.now() in the Browser Monitor JavaScript event instead. Good spot.
12 Apr 2022 09:07 AM
I have a similar scenario..can you please provide some example on how to resolve this
12 Apr 2022 03:33 PM
Sorry, I haven't implemented this use case yet and thus I don't have any examples to share.
But you can check the documentation on JavaScript events in browser monitors as a starting point: https://www.dynatrace.com/support/help/shortlink/id-brower-clickpath-events#javascript