I have created scripts in new relic synthetics that verify the web application is still behaving correctly.

This script does the following things:

  • go to the specific page
  • click on a pdf link
  • verify that the pdf is correctly displayed

To do that, here is a snippet of my script:

    .then(() => { // Here I click on my link
            logger.log(10, "clickElement link=The link text");
            return $browser.waitForAndFindElement(By.linkText("The link text"), DefaultTimeout)
                .then(function (el) {
    .then(() => { // I switch to the newly open pdf windows
            // switchTo window [1] as the new window
            logger.log(11, "switch window ");
            return $browser.sleep(1000)
                .then(function() {
                    return $browser.getAllWindowHandles()
                .then(handles => {
                    return $browser.switchTo().window(handles[1])

    .then(() => {  // I verify that the pdf is displayed by looking for the id "viewer"
            logger.log(12, "waitForElementPresent");
            return $browser.waitForAndFindElement(By.id("viewer"), DefaultTimeout)


The problem is, new relic doesn’t find the id “viewer” even though the screenshot shows that the pdf is correctly displayed. I also tried to us $browser.waitForAndFindElement(By.class("page"), DefaultTimeout) instead, but I have the same error.

Any thought?

(Please note that my way of verifying the pdf display works with selenium+java)

  • My way of veryfing pdfs was to download them as file and then parse their content using external libraries. The advantages are that the downloaded file is the same regardless of which browser was used to download it. The disadvantages are that pdfs cannot be reliably converted to html or anything that would make it easy to verify their layout. In my case the text content was enough. Also, doing so is relatively easy in java, and you say you have no problem in java anyway, so there you have it. – JockX Sep 4 at 14:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.