Reputation: 85
I've created a script as the I want to use in another Selenium WebDriver
script:
$function() {
$("pane1").hide(300);
});
I'm trying to figure out a way to call this script in my Selenium java code.
Upvotes: 1
Views: 5267
Reputation: 151511
Calling jQuery functions from Selenium is done exactly the same way as calling any other. However, there are two issues with your code:
You have $function
, where you probably mean $(function
. If you tried to execute the code in your question as-is you certainly got an error because of this.
Ok, let's say you fix that problem. Now you have a $(function () {...})
call. This is not harmful but it is pointless as you are essentially saying "execute this function when the page has finished its initial load". If you use Selenium the way it is usually used, it won't return control to you until the page has finished its initial load, so there is no reason to wait for the page load.
So:
((JavascriptExecutor) driver).executeScript("$('pane1').hide(300);");
Upvotes: 3