简体   繁体   中英

How to start Firefox without safe mode via Selenium.WebDriver

I have call new instance firefox browser by Selenium webdriver in Java

WebDriver driver = new FirefoxDriver();

driver.get("http://www.google.com");

When i compiled, firefox starts safe mode. How can i disable safe mode. Because i want to use extensions that doesn't seem safe mode.

You don't need start Firefox without safe mode, you only need load all wanted extensions.

  1. Loads the extension inside a File variable,
  2. Add this extension in a FirefoxProfile variable using the method addExtension(File) ,
  3. Set the version of the extension in preferences,
  4. Start FirefoxDriver with the FirefoxProfile.

Example:

File file = new File("path_to_firebug-2.0.17.xpi");
FirefoxProfile firefoxProfile = new FirefoxProfile();
firefoxProfile.addExtension(file);
firefoxProfile.setPreference("extensions.firebug.currentVersion", "2.0.17"); 

WebDriver driver = new FirefoxDriver(firefoxProfile);

I'm not sure about it but may be this is the solution of your problem. You can disable it by setting preference as toolkit.startup.max_resumed_crashes to -1 to Initialize FirefoxDriver with FirefoxProfile as below :-

FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("toolkit.startup.max_resumed_crashes", "-1");

 WebDriver driver = new FirefoxDriver(profile);

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