While
automating a web application, we want the application to be opened in a
customized browser. A browser without any theme/extension/add-ons or
with customized settings; settings like pop-ups are allowed, certain
sites are certified etc. The reason why we want a different browser
profile is our regular use browser has several add-ons installed,
several bookmarks, and some browser level restrictions which might
hamper the proper functioning of the AUT. Firefox provides a good
mechanism to manage different profiles of browser in the same machine. http://goo.gl/NTklV is a link which shows how to create a profile in Firefox. While
creating a profile, we can customized the browser settings per our
project need.
This
tip is about how to implement a profile in Selenium Webdriver using
Java. This implementation is of course after manually creation of the
profile. The below code snippet demonstrates the implementation of
profile in Webdriver :
ProfilesIni allProfiles = new ProfilesIni(); //Declare an object of ProfilesIni class
FirefoxProfile fProfile = allProfiles.getProfile("Profile Name"); //Get the specific Firefox profile information. "Profile Name" here is the name given to the profile while creating it.
FirefoxDriver wbdv = new FirefoxDriver(fProfile); //Pass the profile information to FirefoxDriver.
When a browser will be opened using “wbdv” object, it’ll be opened with the specified profile.
No comments:
Post a Comment