I am using Java with Selenium and Edge (IE compatibility). There is an embedded javascript method:
function onclick_DocType() {
var docPopURL = "http://my.url.com/docpop/docpop.aspx?clienttype=html";
var el_select = document.getElementById("select_DocType");
var iframe = document.getElementById("iframe_DocList");
var selectedIndex = el_select.selectedIndex;
var docKeyValues = el_select.options[selectedIndex].value.split("||");
if(docKeyValues[1] == "")
docPopURL += "&cqid=" + docKeyValues[0];
else
docPopURL += "&cqid=" + docKeyValues[0] + "&" + docKeyValues[1] + "=10296";
iframe.href = docPopURL;
}
I would like to get this using JavascriptExecutor and modify it to remove the function declaration and return docPopURL; In my Java code I can do it by hardcoding the script and doing an execute. However, if the html designers ever change the function, I will have to rewrite (re-hard-code) the script into my Java code. I would like to be able to have the program do it each time so it is current. But not sure how.
To be clear the hard-coded script works in my Java program.
This is the function called upon clicking a link, but for some reason when I am running this remotely (on Jenkins grid) it cannot access the browser window.