I am trying to execute a javascript method on a webpage with the selenium WebDriver. I am able to execute my own script on the page, but not call the method from the page's HTML. Here is the HTML
function Search(){
if(check(document.forms[0],"searchResults")){
var fieldCode = "";
var fieldText = "";
if((document.forms[0].elements['prrSearchVO.selectedSearchCriteria.prrNumber'].value =="") && (!isPRRNoSelected()))
{
alert('PRR No. must be a selected field.');
unSelectAllOptions(document.forms[0].availableFieldsListArray);
unSelectAllOptions(document.forms[0].selectedFieldsList);
}
else
{
document.forms[0].excelRequested.value = "false";
document.forms[0].action = "prrSearchResults.do";
document.forms[0].submit();
}
}
}
If i attempt to submit the form manually it does not load properly. I can execute my own javascript using the code below. How can I execute the "Search" function from the page?
JavascriptExecutor js = (JavascriptExecutor)driver;
js.executeScript("document.getElementById('fromIssueDate').removeAttribute('readOnly')");