Every testing scenario should be executed on some specific testing environment.WebDiver give us this opportunity using Firefox profile and Desired capability.
FireFox Profile
Firefox profile help the tester to execute the test on the particular profile which may be configured previously or may be it configured on run time using Desired Capabilities.
DesiredCapabilities
Desired Capability is a series of key/value pairs that encapsulate aspects of a browser means we can set the behavior of the browser on the run time. Basically, the DesiredCapabilities help to set properties for the WebDriver. A typical usecase would be to set the path for the FireFoxDriver if our local installation doesn't correspond to the default settings.
How to create Profile on FireFox?
Ans:
1.Open windows run mode(Windows+R) then type "firefox -p -no-remote"
-no-remote parameter
is optional it is required if we open multiple instance of firefox(it
means if we open a firefox and using it then open another one for test
purpose).
2.Click on Create Profile then click on next
3.Give a name of the profile and choose the directory path where it will be saved or we can choose the default path.
Now we learn how WebDriver use this Profiles.
Procedure 1:
ProfilesIni allProfiles = new ProfilesIni();
FirefoxProfile profile=allProfiles.getProfile("ExTest");
WebDriver driver = new FirefoxDriver(profile);
FirefoxProfile profile=allProfiles.getProfile("ExTest") here "ExTest" is test profile.
Here one thing one mind ProfilesIni class load all profiles, this profiles may or may not be saved on default location.
Procedure 2:
FirefoxProfile profile=new FirefoxProfile(new File("C:\\Test"));
WebDriver driver = new FirefoxDriver(profile);
FirefoxProfile profile=new FirefoxProfile(new File("C:\\Test")); here "C:\\Test" is the path where profile is created.
Now we learn how to use DesiredCapabilities.
DesiredCapabilities cap=new DesiredCapabilities();
cap.setCapability("firefox_binary", "G:\\Program Files\\Mozilla Firefox\\firefox.exe");
WebDriver driver = new FirefoxDriver(cap);
cap.setCapability("firefox_binary", "G:\\Program Files\\Mozilla Firefox\\firefox.exe");
We know previously that desired capability is a key value paired, here we can observed that we set the
Key as "firefox_binary" and value as "G:\\Program Files\\Mozilla Firefox\\firefox.exe".
Keep in mind that we can not create any profile on Internet Explorer but Chrome or Opera browser have the facility to create user profile. We can get more information regarding this from here .
Keep in mind that we can not create any profile on Internet Explorer but Chrome or Opera browser have the facility to create user profile. We can get more information regarding this from here .
Really nice
ReplyDelete