Has anyone tried to automate testing for a Confluence add-on before? Specially E2E automated testing.
I tried with Pupeteer suggested by a peer, but I just can’t find the content of our add-on’s iframe.
I tried with something like this:
//login to confluence first
await page.goto('https://id.atlassian.com/login?continue=https%3A%2F%2Fmyorg.atlassian.net%2Flogin%3FredirectCount%3D1%26dest-url%3D%252Fwiki%252Findex.action%26application%3Dconfluence&application=confluence')
var userTextBoxId = '#username'
var passwdTextBoxId = '#password'
var continueButton = '#login-submit'
await page.waitForSelector(userTextBoxId)
await page.type(userTextBoxId, config.confluenceUser);
await page.keyboard.press('Enter')
await page.waitForSelector(passwdTextBoxId)
await page.waitFor(1000)
await page.type(passwdTextBoxId, config.confluencePassword);
await page.keyboard.press('Enter')
page.waitForNavigation()
await page.waitFor(15000)
// wait for Confluence add on to be fully loaded
let frames = await page.frames()
console.log('Number of Frames:',frames.length)
let mainFrame = frames.find(f => f.url() === 'https://myorg.atlassian.net/wiki/spaces/COMPANY/overview?mode=global')
frames.map(f => console.log(`Name: ${f.name()} Url: ${f.url()}`))
let content = await mainFrame.content()
// console.log('Mainframe:',content)
let childFrames = await mainFrame.childFrames()
console.log('Number of ChildFrames:',childFrames.length)
console.log('childFrame 0',await childFrames[0].content())
The info Im getting back is the following:
Number of Frames: 2
Name: Url: https://myorg.atlassian.net/wiki/spaces/COMPANY/overview?mode=global
Name: Url: about:blank
Number of ChildFrames: 1
childFrame 0 <html><head></head><body></body></html>
However, if I log the mainFrame content, I can actually see the info for our addon. It’s just that I can’t handle it as iframe. Should I actually do some kind of manual parsing and then open a new page to see the addon info?
<script class="ap-iframe-body-script">
(function(){
var data = {
"addon_key":"confluence-myorg",
"uniqueKey":"confluence-tmyorg__tt-header",
"key":"tt-header",
"moduleType":"webPanels", "moduleLocation":"atl.general", "title":"TopNavigation", "cp":"/wiki",
"general":"",
"w":"100%",
"h":"32px",
"url":"https://myproj-staging.myorg.net/content/topNavigation?xdm_e=https%3A%2F%2Fmyorg.atlassian.net&xdm_c=channel-confluence-myorg__tt-header&cp=%2Fwiki&xdm_deprecated_addon_key_do_not_use=confluence-myorg&lic=none&cv=1.520.0&jwt=MYBIG_JWT_TOKEN",
"contextJwt": "MY_JWT_TOKEN_AGAIN", "structuredContext": "{\"confluence\":{\"content\":{\"type\":\"page\",\"version\":\"1\",\"id\":\"xxx\"},\"space\":{\"key\":\"COMPANY\",\"id\":\"xxxx\"}}}",
"contentClassifier":"",
"productCtx":"{\"page.id\":\"xxx\",\"space.key\":\"COMPANY\",\"content.id\":\"xx\",\"content.version\":\"1\",\"page.type\":\"page\",\"page.title\":\"Company\",\"space.id\":\"xxx\",\"content.type\":\"page\",\"page.version\":\"1\"}",
"timeZone":"Europe/Minsk",
"origin":"https://myproj-staging.myorg.net",
"hostOrigin":"https://myorg.atlassian.net",
"apiMigrations": {
"gdpr": true
}
};
What would you recommend? Has someone already tried that before? The thing is that we have different iframes, since we are showing displays in different sections of Confluence.
Thanks in advance for your help