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) {
el.click();
})
})
.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)