简体   繁体   中英

Enable java plugin in Firefox on a selenium server running on a Ubuntu machine

I setup a selenium server to run on a ubuntu machine remotely. My test is written in Java and it looks like this:

(...)
// setup the WebDrive
DesiredCapabilities dc = DesiredCapabilities.firefox();
dc.setCapability(FirefoxDriver.PROFILE, setupBrowser());
mDriver = new RemoteWebDriver(new URL("http://MY-SERVER-IP:4444/wd/hub"), dc);
(...)

private FirefoxProfile setupBrowser() {
    FirefoxProfile fp = new FirefoxProfile();
    fp.setAcceptUntrustedCertificates(true);
    fp.setAssumeUntrustedCertificateIssuer(false);
    fp.setPreference("browser.download.folderList",2);//browser dir
    fp.setPreference("browser.download.dir", mExtractsDir);
    fp.setPreference("browser.helperApps.neverAsk.saveToDisk","text/plain");
    fp.setPreference("browser.helperApps.neverAsk.openFile","text/plain");
    fp.setPreference("plugin.default.state", 2);
    fp.setPreference("plugin.state.java", 2);
    fp.setPreference("security.enable_java", true);
    fp.setPreference("browser.helperApps.alwaysAsk.force", false);
    fp.setPreference("browser.download.manager.alertOnEXEOpen", false);
    fp.setPreference("browser.download.manager.focusWhenStarting", false);
    fp.setPreference("browser.download.manager.useWindow", false);
    fp.setPreference("browser.download.manager.showAlertOnComplete", false);
    fp.setPreference("browser.download.manager.closeWhenDone", false);
    return fp;
}
(...)

I then started a Selenium server in my remote machine running Ubuntu Linux in MY-SERVER-IP:4444 by executing this:

$ Xvfb :0 -screen 0 1024x768x24 2>&1 >xvfb.log &
$ export DISPLAY=:0
$ nohup xvfb-run java -jar selenium-server-standalone-2.45.0.jar > selenium.log &

PROBLEM: The website that my test code is loading requires java plugin, but it is not loading. How to load the java plugin? I know that it is not loading because I used wdriver.get point to the official java test website and took a screenshot of the browser by using the following code and it was possible to see that the java test plugin is not being loaded:

Augmenter augmenter = new Augmenter(); 
TakesScreenshot ts = (TakesScreenshot) augmenter.augment(mDriver);
File srcFile = ts.getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(srcFile, new File("/tmp/firefoxstopped.png"));

QUESTION: How can I enable java plugin in the Firefox for this scenario?

Remember read about Java Applets embed in HTML. Can you share the code of your HTML? How you embed the plugin?

You can see the plugins supported in the browser with navigator.plugins

The NPAPI like Java Plugin going to be deprecate soon.

You can compile the browser like XULRunner o Firefox with the support of Java and load the jar files with JavaScript.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM