I'm trying to execute jQuery/Angular calls via WWW::Mechanize::Firefox's eval_in_page
. I'm guessing there is some sort of scope issue, because I'm getting errors.
If I try to execute this code:
angular.element(document.getElementsByClassName("input")[0]).triggerHandler(('change');
I get this response:
MozRepl::RemoteObject: ReferenceError: angular is not defined at ...
If I try to execute this code:
$(".input").val("Foo")
I get this response:
MozRepl::RemoteObject: ReferenceError: $ is not defined ...
It seems I don't have access to either framework. The page does appear to have both loaded, however. If I execute the code in the browser console it works fine.
Thanks for the ideas all. I wasn't able to solve the original question, but I was able to come up with this alternate solution. Using this javascript I was able to fill in the field and trigger the appropriate change and blur events. Doing this allowed angular to do the processing it needed to do.
Note the function I used was a trimmed down solution found here. I trimmed it down to just the Firefox code. If you're using a different browser, you'd want to use their more robust code. If anyone comes up with a solution to the original question I'd be happy to accept it.