I need to call a JavaScript function from Selenium WebDriver in Firefox. I use this command in Firebug's Command Editor to invoke a file upload application after logged into my website:
infoPanel.applicationManager.changeApp('FileUploader', {action: 'new'})
Is there a way to execute this from Selenium?
I need to call a JavaScript function from Selenium WebDriver in Firefox. I use this command in Firebug's Command Editor to invoke a file upload application after logged into my website:
infoPanel.applicationManager.changeApp('FileUploader', {action: 'new'})
Is there a way to execute this from Selenium?
Share Improve this question edited Nov 21, 2014 at 18:54 Sebastian Zartner 20.1k10 gold badges102 silver badges141 bronze badges asked Nov 21, 2014 at 9:02 bpkbpk 3132 gold badges6 silver badges20 bronze badges2 Answers
Reset to default 11Try this:
WebDriver driver = new ChromeDriver();
((JavascriptExecutor)driver).executeScript("yourScript();");
WebDriver driver = new AnyDriverYouWant();
if (driver instanceof JavascriptExecutor)
{
((JavascriptExecutor)driver).executeScript("yourScript();");
}