- Synthetic scripts can be used to test business-critical end-user flows, features and also helps to check whether specific elements and resources are present on the user interface.
- The test scripts can be scheduled to execute at a particular time and at different geographical locations.
- Easy to identify the broken things in critical end-user flows.
- Helps to improve performance by knowing where the response time of the web application is slow.
Here is an example of what a synthetic script can do:
- Visit and log in to a web application.
- Try navigating to your order or purchase list.
- Check whether your order list is present or not.
Are you able to see your order list? If yes, Good for you. If not, sad for you and me as well, cuz even I was not able to view them. Thanks to New Relic’s synthetic monitor for helping me to monitor this problem and fix it before a customer recognizes it. So here are few steps I followed to develop my script.
Step 1: Create a sample synthetic monitor in New Relic.
Step 2: Go to the script in the setting from the sidebar.
Step 3: Set the window size similar to the size of your web page.
$browser is a synthetic monitoring instance of selenium-webdriver.WebDriver(). It exposes some of the web driver API's like get() and findElement(). Refer the below link for more.
Step 4: Visit and log in to my web application.
.then() — The way to deal with asynchronous calls in JS is with callbacks. Let’s say we had to make multiple calls to the server, one after the other to set up the application. This becomes the nested callback hell. So there is a concept called Promise API. It was designed to resolve the nesting problem. The “then()” function returns the promise object which supports the chaining of multiple calls to the server.
$driver — provides all the exports from selenium-webdriver module. Refer for more info: https://docs.newrelic.com/docs/synthetics/synthetic-monitoring/scripting-monitors/synthetics-scripted-browser-reference-monitor-versions-050/#locators
Step 5: Validate my web application’s order or purchase list page.
Step 6: Save the script and validate.
Question: Wonder how this monitor is gonna validate the script?
Answer: New Relic creates a fully virtualized Selenium-driven Google Chrome browser that navigates your website and follows each step of the script.
Once the script validation is done. Check the Timeline, script log, and Screenshot for the output.
How about you?
Are you able to view your order list page now?
- New Relic — Synthetic Documentation
- App Dynamics — Synthetic Documentation