Selenium Webdriver 3.0.1 not loading Firefox Profile I chose - selenium

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);

Related

How to load a specific firefox profile using Selenium webdrivermanager?

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)}

Selenium - FirefoxDriver not accepting arguments in code

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);

Getting issue with creation of Firefox profile with Selenium 3.4/3.5/3.6

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);

How to launch IE browser using selenium webdriver 3.4.0

How to launch IE browser using selenium webdriver 3.4.0? I have tried, but unable to open an IE browser. I have downloaded IE Driver and followed the same like launching firefox driver.
Launching of Firefox browser is working fine, below are command lines
System.setProperty("webdriver.gecko.driver","C:\\Users\\vidhya.r\\Desktop\\Automation\\Jars\\geckodriver.exe");
FirefoxOptions options = new FirefoxOptions();
options.setBinary("C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe");
driver = new FirefoxDriver(options);
Download IEDriverServer, put it to path or use
System.setProperty("webdriver.ie.driver", ieDriverPath);
launch via
driver = new InternetExplorerDriver();
DesiredCapabilities capability = DesiredCapabilities.internetExplorer();
capability.setCapability(InternetExplorerDriver.IGNORE_ZOOM_SETTING, true);
capability.setCapability(InternetExplorerDriver.ELEMENT_SCROLL_BEHAVIOR, 1);
capability.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
capability.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,true);
System.setProperty("webdriver.ie.driver", ieDriverPath);
WebDriver driver = new InternetExplorerDriver(capability);
First download IEDriver from this Link
Use this:
System.setProperty("webdriver.ie.driver", "Path of IE driver");
WebDriver driver = new InternetExplorerDriver();
If you want to add some capabilities then use DesiredCapabilities

Migrating from Firefox WebDriver to Marionette

I am trying to switch from FireFoxDriver to MarionetteDriver.
I managed to run firefox with MarionetteDriver by running:
public void runMarionnete(){
DesiredCapabilities dc = DesiredCapabilities.firefox();
OSUtils.setProperty("webdriver.firefox.bin", "C:\\Firefox\\firefox.exe");
OSUtils.setProperty("webdriver.gecko.driver","C:\\Drivers\\wires-0.6.2-win.exe"));
_driver = new MarionetteDriver(dc);
}
But I have 2 things I am not sure how to do:
1.How to add XPI extensions to the driver ?
in the old way I used:
FirefoxProfile.addExtension ...
2.How to configure all the firefox properties , like I used to do , for example:
profile.setPreference("browser.startup.homepage;about:home","about:blank");
profile.setPreference("startup.homepage_welcome_url","about:blank");
profile.setPreference("browser.usedOnWindows10.introURL","about:blank");
profile.setPreference("devtools.devedition.promo.url","");
profile.setPreference("xpinstall.signatures.required",false);
Thank you!
You can use the same FirefoxProfile class, just add it to the DesiredCapabilities in the following way:
FirefoxProfile firefoxProfile = new FirefoxProfile();
firefoxProfile.setPreference("browser.startup.homepage;about:home","about:blank");
firefoxProfile.setPreference("startup.homepage_welcome_url","about:blank");
firefoxProfile.setPreference("browser.usedOnWindows10.introURL","about:blank");
firefoxProfile.setPreference("devtools.devedition.promo.url","");
firefoxProfile.setPreference("xpinstall.signatures.required",false);
DesiredCapabilities desiredCapabilities = DesiredCapabilities.firefox();
desiredCapabilities.setCapability(FirefoxDriver.PROFILE, firefoxProfile);