I'm following the example on this page to set up a custom profile to use:
http://toolsqa.com/selenium-webdriver/custom-firefox-profile/
However in my code I'm getting "Remove argument to match Firefox driver" error:
ProfilesIni profile = new ProfilesIni();
FirefoxProfile myprofile = profile.getProfile("testProfile");
WebDriver driver = new FirefoxDriver(myprofile); // does not like myprofile as an argument here
Thanks
UPDATE
I was able to resolve this issue by slightly modifying try-catch's solution:
ProfilesIni profile = new ProfilesIni();
FirefoxProfile myprofile = profile.getProfile("testProfile"); //added this
FirefoxOptions options = new FirefoxOptions();
options.setProfile(myprofile);
According to the API docs of FirefoxDriver there's no FirefoxDriver(ProfilesIni) signature and ProfilesIni has no base class nor implements an interface that is available as a constructor signature to FirefoxDriver.
Through there's a FirefoxDriver(FirefoxOptions) signature. And FirefoxDriver has a setProfile(FirefoxProfile profile) method.
This should work:
ProfilesIni profile = new ProfilesIni();
FirefoxOptions options = new FirefoxOptions();
options.setProfile(profile.getProfile("testProfile"));
WebDriver driver = new FirefoxDriver(options);
Related
I'm trying to use webdrivermanager library to load firefox driver in my selenium tests. I'm unable to load a specific firefox profile using this library. Here is what i'm trying to do:
FirefoxDriverManager.getInstance().setup() // To instantiate the firefox driver
ProfilesIni Prof = new ProfilesIni();
FirefoxProfile profile = Prof.getProfile("C:\\Users\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles\\6xv9ndwh.SELENIUM");
WebDriver driver = new FirefoxDriver(profile);
But this instantiates a new driver and does not force the driver instantiated by firefoxdrivermanager to use the specific profile.
I tried using default gecko driver too that does not load the profile either. Here is the code that i'm trying:
System.setProperty("webdriver.gecko.driver", "C:\\geckodriver\\geckodriver-v0.20.0-win64\\geckodriver.exe");
ProfilesIni allProfiles = new ProfilesIni();
FirefoxProfile Profile = allProfiles.getProfile('default');
Profile.setAcceptUntrustedCertificates(true);
Profile.setAssumeUntrustedCertificateIssuer(false);
driver = new FirefoxDriver(Profile);
Can someone help me on this please?
First of all create a new firefox profile
steps for it are
1. Run this command firefox.exe -p in run window
It will show this dialog box create profile with new name and exit the window.
After that perform this command in webdriver
System.setProperty("webdriver.firefox.marionette", "Path to the exe of firefox driver");
ProfilesIni profile = new ProfilesIni();
FirefoxProfile myprofile = profile.getProfile("UrProfile Name which u created");
WebDriver driver = new FirefoxDriver(myprofile);
driver.get("http://www.google.com");
Hope it may help u...
This worked for me (though not using webdrivermanager) for instantiating webdriver using Gradle:
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapability("marionette", true);
capabilities.setCapability("acceptInsecureCerts", true);
driver = {new FirefoxDriver(capabilities)}
I am unable to use arguments for new FirefoxDriver as per code:
File pathBinary = new File("C:\\Users\\myname\\AppData\\Local\\Mozilla Firefox\\firefox.exe");
FirefoxBinary firefoxBinary = new FirefoxBinary(pathBinary);
FirefoxProfile firefoxProfile = new FirefoxProfile();
WebDriver driver = new FirefoxDriver(firefoxBinary,firefoxProfile);
//WebDriver driver = new FirefoxDriver();
I get an error saying "remove arguments to match FirefoxProfile();
When I try using just new FirefoxDriver() I get:
org.openqa.selenium.WebDriverException: Cannot find firefox binary in PATH. Make sure firefox is installed. OS appears to be: WIN8_1
I am using:
geckodriver-v0.19.1-win32
selenium-server-standalone-3.7.1
Any help most appreciated.
You need to pass them in as Firefox options try the following
FirefoxProfile ffprofile = new FirefoxProfile();
FirefoxBinary ffBinary = new FirefoxBinary(new File("path to your firefox
executable"));
FirefoxOptions options = new FirefoxOptions();
options.setProfile(ffprofile);
options.setProfile(ffBinary);
options.setCapability(FirefoxOptions.FIREFOX_OPTIONS,options);
WebDriver driver = new FirefoxDriver(options);
I tried with the below code. I am unable to import the FirefoxProfile package to my IDE.
ProfilesIni allProfiles = new ProfilesIni();
FirefoxProfile myProfile = allProfiles.getProfile("SeleniumTest");
WebDriver driver = new FirefoxDriver(myProfile);
Try this
ProfilesIni allProfiles = new ProfilesIni();
FirefoxProfile myProfile = allProfiles.getProfile("SeleniumTest");
FirefoxOptions options = new FirefoxOptions();
options.setProfile(myProfile);
WebDriver driver = new FirefoxDriver(options);
Since upgrading to the latest version of Selenium the following code seems to be deprecated:
Selenium 3.6.0 & webdriver = new FirefoxDriver(capabilities) - deprecated?
Full code:
System.setProperty("webdriver.gecko.driver", Base_Page.getConstant(Constant.GECKO_DRIVER_DIRECTORY));
DesiredCapabilities capabilities=DesiredCapabilities.firefox();
capabilities.setCapability("marionette", true);
webdriver = new FirefoxDriver(capabilities); //deprecated
From https://raw.githubusercontent.com/SeleniumHQ/selenium/master/rb/CHANGES
3.4.1 (2017-06-13)
==================
Firefox:
* Added new Firefox::Options class that should be used to customize browser
behavior (command line arguments, profile, preferences, Firefox binary, etc.).
The instance of options class can be passed to driver initialization using
:options key. Old way of passing these customization directly to driver
initialization is deprecated.
From the 3.4.1 version the FirefoxOptions should be used.
Changed the following code 'FirefoxDriver(capabilities) to firefoxOptions which uses .setCapcability()
FirefoxOptions firefoxOptions = new FirefoxOptions();
firefoxOptions.setCapability("marionette", true);
webdriver = new FirefoxDriver(firefoxOptions);
Try following:
FirefoxOptions firefoxOptions = new FirefoxOptions();
firefoxOptions.setCapability("marionette", true);
WebDriver driver = new FirefoxDriver(firefoxOptions);
You can try this line;
FirefoxOptions ffOpt = new FirefoxOptions();
ffOpt.setCapabilities("marionette", true);
WebDriver driver = new FirefoxDriver(ffOpt);
I read everywhere that this is the code used to load an existing profile:
ProfilesIni profile = new ProfilesIni();
FirefoxProfile ffprofile = profile.getProfile("SELENIUM");
WebDriver driver = new FirefoxDriver(ffprofile);
I have created one profile with that name and everything is ok. But it keeps loading the default selenium profile.
I'm using Selenium 3.0.1 with Java and Firefox 50.0.2 which is the last version in my country at least.
Any idea of why this is happening? thanks!
You should put profile to capabilities at first.
ProfilesIni profile = new ProfilesIni();
FirefoxProfile ffprofile = profile.getProfile("SELENIUM");
WebDriver driver = new FirefoxDriver(ffprofile);
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapability(FirefoxDriver.PROFILE, profile);
WebDriver driver = new FirefoxDriver(capabilities);