To launch the Firefox using Selenium, you do not need to download and run the Firefox driver separately. Below line of code will start the Firefox from standard location.
WebDriver driver = new FirefoxDriver(myprofile);
Using different Firefox profile
ProfilesIni profile = new ProfilesIni();
FirefoxProfile myprofile = profile.getProfile("XYZ");
caps.setCapability(FirefoxDriver.PROFILE, profile);
Or you can also create new profile on the fly and pass that capability as shown in below code.
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("plugin.state.flash", 1);
caps.setCapability(FirefoxDriver.PROFILE, profile);
Using specific Firefox binary
Sometimes, we need to execute the tests on specific version of Firefox. We can download portable firefox from https://sourceforge.net/projects/portableapps/files/Mozilla%20Firefox%2C%20Portable%20Ed./
and run that binary as shown in below code.
File pathToBinary = new File("c:\\FirefoxPortable_p.exe");
FirefoxBinary ffBinary = new FirefoxBinary(pathToBinary);
FirefoxProfile firefoxProfile = new FirefoxProfile();
WebDriver driver = new FirefoxDriver(ffBinary,firefoxProfile);
What do you think on above selenium topic. Please provide your inputs and comments. You can write to me at reply2sagar@gmail.com
WebDriver driver = new FirefoxDriver(myprofile);
Using different Firefox profile
ProfilesIni profile = new ProfilesIni();
FirefoxProfile myprofile = profile.getProfile("XYZ");
caps.setCapability(FirefoxDriver.PROFILE, profile);
Or you can also create new profile on the fly and pass that capability as shown in below code.
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("plugin.state.flash", 1);
caps.setCapability(FirefoxDriver.PROFILE, profile);
Using specific Firefox binary
Sometimes, we need to execute the tests on specific version of Firefox. We can download portable firefox from https://sourceforge.net/projects/portableapps/files/Mozilla%20Firefox%2C%20Portable%20Ed./
and run that binary as shown in below code.
File pathToBinary = new File("c:\\FirefoxPortable_p.exe");
FirefoxBinary ffBinary = new FirefoxBinary(pathToBinary);
FirefoxProfile firefoxProfile = new FirefoxProfile();
WebDriver driver = new FirefoxDriver(ffBinary,firefoxProfile);
What do you think on above selenium topic. Please provide your inputs and comments. You can write to me at reply2sagar@gmail.com
No comments:
Post a Comment