I have seen other posts mention this issue for their Apps, but the issue in this context is regarding Synthetic Testing.
We would like to use the Atlassian Connect JS API)to send a request to the Metrics API.
The all.js
script is included in our App, and appears inside of our iFrame as expected.
Our synthetic test framework has already done the following:
- Logged into the instance and navigated to the App.
- Switched context to the iFrame of the Atlassian Connect App.
At this stage, the following request is attempted:
window.AP.request({
url: `/rest/atlassian-connect/latest/addons-metrics/${appKey}/publish`,
type: 'PUT',
contentType: 'application/json',
data: JSON.stringify([{
metricsType: 'SYNTHETIC',
status: testStatus
}])
})
resulting in the error:
frame.evaluateHandle: TypeError: Cannot read properties of undefined (reading 'request')
We have attempted this for both Playwright and WebdriverIO, both times Window.AP is undefined, preventing requests to be called.
Findings:
As far as I can tell, there are multiple window
objects in play:
- Calling
window.AP
from the App in a normal browser returnsundefined
, but has access to window objects such aswindow.JIRA
. - Calling
window.AP
from the App’s iFrame in a normal browser returns the window.AP object (as expected?), but does not have access to the parent pages window objects such aswindow.JIRA
.
This would lead to knowing that both Playwright and WebdriverIO Javascript evaluation to access window
objects uses the Pages window
object, without a way to use the iFrames window object (despite being inside the iFrame context).
Should window.AP
be available after switching to the Apps iFrame context?
If not, is there a known method to access the JS API from within the App via a Synthetic Testing Framework?