Search code examples
javascriptjqueryhtmldojotableau-api

Unable to click() div-element in embedded tableau


I'm having issues clicking the "Create PDF"-button in the embedded tableau frame on this webpage.

First, I call the element for the export button on the bottom of the tableau-iframe => works. That opens a Pop-Up window in the Tableau-Iframe. I then grab the Button-Container for both the Cancel and actual Download-Button. But no matter what I do, I'm not able to click the damn button.

Here's my code rn:

--grab export-button and click

var exportBtn = document.getElementById("btn-export-to-pdf");
exportBtn.click();

--grab "Create PDF" (or in German "PDF Erstellen") and click it

var buttn = document.getElementsByClassName("tab-pdf-dialog-buttons")[0].children.item(1)

buttn.click(); => returns undefined

var evnt = new Event("click");

buttn.dispatchEvent(evnt); => returns true

Any advice on how to click those kind of Buttons? It appears that tableau uses dojo, which coincides with some of these issue, but I wasn't able to figure anything more detailed out.


Solution

  • Just using javascript running in main page it is not possible to click the second button because it is located inside an <iframe> from a different domain. You can read more about Same-Origin-Policy on MDN.

    If you run this code inside a browser extension, selenium or similar please update your question as they might provide a way to do what you want.