I would like to execute a script from a JavaScript file but due the same origin policy measure, I can't.
I tried to execute put the script in a string and pass it to the function.
js.exec()
However I cannot execute this script due the fact that the string is too long.
This is how I pass the script.
class TheClass extend GebReportingSpec {
....
and:'I execute the script'
js.exec('''
$.getScript("http://localhost/jscript/html2canvas.js", function() {
var height = Math.round($("#TopImageContainer").height());
var width = Math.round($("#TopImageContainer").height());
// function() {
html2canvas($("#TopImageContainer"), {
onrendered: function (canvas) {
var tempcanvas = document.createElement("canvas");
tempcanvas.width = width;
tempcanvas.height = height;
var context = tempcanvas.getContext("2d");
context.drawImage(canvas,0,0,width,height,0,0,width,height);
var link = document.createElement("a");
link.href = tempcanvas.toDataURL("image/png");
link.download = "myElement.png";
link.click();
}
});
});''')
}
I am getting the following error:
The given string is 126694 Unicode code units long, but only a maximum of 65535 is allowed.
What can I do?