原文地址: http://www.toolsqa.com/selenium-webdriver/custom-firefox-profile/
What is Profile
Firefox saves your personal information such as bookmarks, passwords, and user preferences in a set of files called your profile, which is stored in a separate location from the Firefox program files. You can have multiple Firefox profiles, each containing a separate set of user information. The Profile Manager allows you to create, remove, rename, and switch profiles.
Why do I need New Profile
The default Firefox profile is not very automation friendly. When you want to run automation reliably on a Firefox browser it is advisable to make a separate profile. Automation profile should be light to load and have special proxy and other settings to run good test.
You should be consistent with the profile you use on all development and test execution machines. If you used different profiles everywhere, the SSL certificates you accepted or the plug-ins you installed would be different and that would make the tests behave differently on the machines.
- There are several times when you need something special in your profile to make test execution reliable. The most common example is a SSL certificate settings or browser plug-ins that handles self-signed certs. It makes a lot of sense to create a profile that handles these special test needs and packaging and deploying it along with the test execution code.
- You should use a very lightweight profile with just the settings and plug-ins you need for the execution. Each time Selenium starts a new session driving a Firefox instance, it copies the entire profile in some temporary directory and if the profile is big, it makes it, not only slow but unreliable as well.
Finding Your Profile Folder
Your profile folder’s location depends on the operating system you use. The following table shows the typical location of the default profile:
Operating System | Profile Folder Path |
Windows 7 / 8 |
%AppData%\Roaming\Mozilla\Firefox\Profiles\xxxxxxxx.default |
Linux | ~/.mozilla/firefox/xxxxxxxx.default/ |
Mac OS X | ~/Library/Application Support/Firefox/Profiles/xxxxxxxx.default/ |
There are two points of interest in this table. The first is the xxxxxxxx
string preceding each profile name. This string is simply a collection of 8 random numbers and characters, used to ensure that each profile is unique. Firefox automatically prepends a randomized string to any new profile for you, so you never need to worry about creating this portion of the name.
The second point of interest lies in the Windows XP / 2000 / Vista / 7 / 8 paths. The %AppData%
string is actually a special Windows variable, pointing to your “Application Data” path. This is typically of the form:
C:\Users\{User Name}\AppData
Creating a New Profile
Creating a New Firefox profiles and use the same in the Test script involves three steps process. First you need to Start the Profile Manager, second is to Create a New Profile and third is to use the same profile in Test scripts.
Step 1: Starting the Profile Manager
1) At the top of the Firefox window, click on the File menu and then select Exit.
2) Press ‘Win + R’ or click on the Windows Start Menu (bottom left button) and then select Run.
3) In the Run dialog box, type in: ‘firefox.exe -p
'
and then Click OK.
Note: If the Profile Manager window does not appear, it may be opened in the background. It needs to be closed properly, you may use Ctrl+Alt+Del program to kill it. If it still does not open then you may need to specify the full path of the Firefox program, enclosed in quotes; for example:
- On 32-bit Windows:
"C:Program FilesMozilla Firefoxfirefox.exe" -p
- On 64-bit Windows:
"C:Program Files (x86)Mozilla Firefoxfirefox.exe" -p
4) The Choose User Profile window will look like this.
Step 2: Creating a Profile
1) Click the ‘Create Profile…’ button on the ‘Firefox – Choose User Profile’ window that comes up.
2) Click ‘Next >’ in the ‘Create Profile Wizard’ window that comes up.
3) Type in a new name ‘profileToolsQA’ in the ‘Enter new profile name’ box and click ‘Finish’.
4) ‘Choose User Profile’ window will display the newly created profile in the list.
5) Click on the ‘Start Firefox’ box. Firefox will start with the new profile.
Note: You will notice that the new Firefox window will not show any of your Bookmarks and Favorite icons.
Note: The last selected profile will then start automatically when you next start Firefox and you will need to start the Profile Manager again to switch profiles.
Step 3: User Custom Profile in Selenium
Once the Automation Profile is created, it needs to be called in the Test scripts. You can now add the below code to your Test scripts to Instantiating the Firefox Driver:
ProfilesIni profile = new ProfilesIni(); FirefoxProfile myprofile = profile.getProfile("profileToolsQA"); WebDriver driver = new FirefoxDriver(myprofile);
Disable firefox firstrun page
profile.setPreference("browser.startup.homepage_override.mstone", "ignore");
Do not prompt for authentication if password is saved
profile.setPreference("signon.autologin.proxy", true);
相关推荐
### 火狐Firefox浏览器安装Selenium IDE的详细步骤 #### 一、Selenium IDE简介 Selenium IDE是一款基于Firefox的集成开发环境工具,它允许用户通过简单的点击操作来记录和回放测试脚本,无需编写任何代码。这对于刚...
压缩包内的“Firefox Setup 33.0.2.exe”是Firefox 33.0.2的安装程序,用于在用户的计算机上安装该版本的浏览器,以便使用Selenium进行自动化测试。而“selenium-java-2.44.0.rar”则很可能是Selenium WebDriver的...
FireFox54+Selenium3.6+geckodriver v0.18.0,把自己真实的搭建Firefox与Selenium 测试环境的结果与大家分享,希望大家能少走弯路,selenium3.0以上必须使用Firefox驱动,版本的匹配很重要,相信很多人会在这卡顿的...
本主题将深入探讨如何结合Firefox浏览器和Selenium进行单元测试,以及如何利用JMeter进行测试和Bugfree工具进行测试管理。 首先,让我们详细了解单元测试。单元测试是对软件中的最小可测试单元进行检查,如函数、...
由于Firefox新版本浏览器不支持selenium IDE,所以采用48版本的firefox,这样能更好的兼容IDE,在Firefox中插入IDE链接为https://addons.mozilla.org/en-US/firefox/addon/selenium-ide/
Firefox浏览器驱动与Selenium的结合,为实现这一目标提供了强大的工具。本文将深入探讨如何使用Firefox浏览器驱动与Selenium进行自动化测试,以及相关的技术要点。 首先,Selenium是一个开源的Web应用程序自动化...
本教程将详细讲解如何搭建一个使用Selenium与Firefox浏览器的自动化测试环境,特别是针对火狐52版本,结合selenium 3.3以及geckodriver 15.0的配置,并提供了一个名为`FirefoxAuto.java`的示例代码。 首先,我们来...
标题中的“Firefox47可以兼容selenium3.0以下版本”揭示了一个关键的软件兼容性信息,这在进行自动化测试时尤其重要。Selenium是一个广泛使用的开源自动化测试框架,允许开发者编写脚本来控制Web浏览器执行各种操作...
标题 "Firefox + JUnit + Selenium" 暗示了我们讨论的主题是关于使用Firefox浏览器、JUnit测试框架和Selenium自动化测试工具的集成测试方案。这三个组件在IT领域,特别是软件测试中发挥着重要的作用。 首先,Fire...
标题中的“selenium3.141+geckodriver0.26.0_firefox.zip for python”指的是一个Python编程环境下,用于自动化网站测试的工具包,它包含了Selenium 3.141版本和GeckoDriver 0.26.0版本,专为Firefox浏览器设计。...
2. Firefox Profile:可以自定义Firefox配置,比如设置代理、禁用插件,以适应不同的测试需求。 3. 元素定位策略:如XPath、CSS选择器、ID、Name等,用于在网页上找到特定的HTML元素。 4. 断言和验证:用于检查预期...
selenium为firefox设置下载文件的保存,很好地解决了默认路径问题
标题中的问题涉及到在使用Firefox浏览器和Selenium自动化测试时可能出现的一个特定错误:“WebDriverException: Message: 'Can't load the profile:”。这个错误通常发生在尝试加载一个已存在的Firefox配置文件,...
内含 : selenium 2.53 、 selenium 3.0 、 Firefox 33.0 、 selenium-API-2.12.chm 、 selenium2.0_中文帮助文档 备注 : 已经试过 selenium 2.53 和 Firefox 33.0 可以兼容使用
### selenium更改Firefox版本的问题 #### 一、问题背景与初步尝试 在使用selenium进行自动化测试的过程中,可能会遇到selenium无法正确识别特定版本的Firefox浏览器的情况。本文将针对这一问题展开详细讨论,并给...
由于Selenium 3.x版本开始,Firefox浏览器的驱动由之前的Firefox Profile模式转变为使用GeckoDriver,因此,与Selenium 3.11配合使用的Firefox版本至少需要v57及以上。 GeckoDriver是Mozilla开发的一款WebDriver...
对于Firefox驱动GeckoDriver,它是Mozilla Firefox浏览器的一个接口,使得Selenium能与Firefox通信。在提供的文件中,"geckodriver-v0.20.0-win64.zip" 和 "geckodriver-v0.20.0-win32.zip" 分别是64位和32位Windows...
java+testng使用火狐52进行自动化测试,最终发现是fselenium、firefox、geckodriverbane版本不匹配问题。现总结完美适配的包,selenium环境搭建(版本火狐52+selenium 3.3 +geckodriver 15.0),希望大家在自动化得...
Selenium IDE是firefox的一个插件,可以帮助刚入门的自动化测试供测试,在脚本语言不太熟练的情况下,可以通过Selenium IDE实现脚本的录制、开发、回放。 众所周知,「Selenium IDE」是一种记录和回放工具。现在它将...
**Selenium 自动化测试工具 Firefox 及其插件** Selenium 是一款广泛使用的开源自动化测试框架,适用于多种浏览器,包括 Firefox。它为开发者和测试工程师提供了强大的功能,用于模拟用户交互,验证网页元素,以及...