Scripted Browser: Attempts to interact with elements fail
When validating a monitor created in an older runtime against the Chrome 100 (or newer) runtime, findElement and other methods to find and interact with elements on the page may fail due to promise handling differences. If the monitor passes in a legacy runtime, fails in the new runtime, and the element is present in the screenshot, you may need to improve your promise handling logic.
Selenium WebDriver promise manager / control flow allowed some functions to execute in order in legacy runtimes, without managing promises. This capability was removed in Selenium WebDriver 4.0 and is no longer available in the runtime. All async functions and promises need to be managed with await
or with .then
promise chains. This will ensure script functions execute in the expected order.
For example, promise manager / control flow could allow this partial script to complete successfully, even though $browser.get returns a promise and the promise is not being handled correctly:
$browser.get('http://example.com');
$browser.findElement($driver.By.css('h1'));
In the the Chrome 100 (or newer) runtime, any methods that return a promise need to use await or .then syntax to properly sequence steps. Using await is recommended due to cleaner syntax and easier usage, but .then promise chains are still supported too.
await $browser.get('http://example.com');
let el = await $browser.findElement($driver.By.css('h1'));
Scripted API: Differences between request
and got
The Node.js 10 and older scripted API runtimes used the request
Node.js module to provide a $http
object that could be used to test APIs.
The Node.js 16 and newer scripted API runtimes use got
instead of request
. The request
module was deprecated in 2020 and will no longer be included in new API or browser based runtimes. The $http
object provides a custom request
-like experience while being powered by got
to provide backward compatibility for basic use cases while still avoiding the use of a deprecated module. Not all advanced use cases of request
are or will be supported. Script examples and a conversion guide are available.
Tip
The request
-like experience provided by the $http
object will also be returned for any customers attempting to use request
directly in Node.js 16 and newer scripted API runtimes.
Scripted Browser: Deprecation warnings ($browser / $driver)
The Chrome 72 and older scripted browser runtimes exposed Selenium WebDriver APIs using $driver
and $browser
. These objects are still available in the Chrome 100 and newer runtimes for backward compatibility, but you will receive a deprecation warning in your script log when using these objects. This warning will not cause monitors to fail and no deprecation date has been set.
The Chrome 100 and newer scripted browser runtimes use $selenium
and $webDriver
instead of $driver
and $browser
. The $selenium
and $webDriver
objects provide access to Selenium WebDriver 4.1 APIs and the $driver
and $browser
objects provide backward compability with Selenium WebDriver 3.6 syntax.
Scripted Browser: waitForAndFindElement and waitForPendingRequests
The waitForAndFindElement
and waitForPendingRequests
methods are New Relic custom methods that are provided in the Chrome 72 and older scripted browser runtimes. They can still be used with $driver
and $browser
in the Chrome 100 and newer runtimes, but they will not be available when using the Selenium WebDriver 4.1 APIs directly with $selenium
and $webDriver
. This change will better align New Relic's Selenium WebDriver implementation with the base Selenium WebDriver implementation.
Customers who choose to continue using waitForAndFindElement
or waitForPendingRequests
in the new runtime can paste code examples into their monitors.