4

自从更新到 Firefox 12 后,每次我使用 Selenium(在 python 和 Mac OS 10.7 中)启动具有特定配置文件的 Firefox 时,它都会弹出“检查加载项的兼容性”对话框,有时这个对话框会永远存在,我有强制退出它。强制退出后,Firefox 的新实例将继续启动并成功完成 Selenium 脚本的其余部分。

我尝试设置extensions.checkCompatibilityfalse. 如果我正常启动 Firefox,这会修复它,但如果我用 Selenium 启动它则不会。关于如何抑制此对话框的任何想法?谢谢!

4

3 回答 3

5

每当 Firefox 更新时,此对话框只会显示一次。每次都为您显示它的原因可能是 Selenium 每次都会创建一个新的配置文件。如果您将extensions.lastAppVersion首选项设置为"12.0"(或任何当前的 Firefox 版本),那么 Firefox 将不再认为它已更新并且不会显示此对话框。extensions.showMismatchUI但是,添加首选项并将其设置为应该更容易false,这将抑制此对话框(但不会抑制其他升级操作)。

旁注extensions.checkCompatibility从 Firefox 3.6 开始,首选项不再做任何事情,它是当前 Firefox 版本中特定于版本的首选项。因此,您必须改为设置extensions.checkCompatibility.12.0首选项。但是,这会完全禁用扩展的兼容性检查,而不仅仅是您关心的对话框。

于 2012-07-30T06:49:08.493 回答
1

我尝试将 extensions.checkCompatibility 设置为 false。如果我正常启动 Firefox,这会修复它,但如果我用 Selenium 启动它则不会。

当您使用 Selenium 启动它时它不会的原因是 Firefox 驱动程序将在临时文件目录中创建一个临时配置文件,从而减慢测试速度并占用不必要的空间。

为您的测试目的创建配置文件并设置您需要的内容。创建 SeleniumProfile 的完整说明可以在https://support.mozilla.org/en-US/kb/profile-manager-create-and-remove-firefox-profiles找到

在Java中,我有以下内容:

protected WebDriver createFirefoxDriver() {     
    File proFile = new File("C:\\Users\\<username>\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles\\xxxxxx42.SeleniumProfile");
    FirefoxProfile ffProfile = new FirefoxProfile(proFile);
    WebDriver ffDriver = new FirefoxDriver(ffProfile);

    return ffDriver;
}
于 2014-01-15T19:30:33.047 回答
0

Do this to remove the "checking for addon's compatibility" Dialog. This is based on the Windows operating system..

Create a temporary FF Profile and start the server with that profileas shown below.

java -jar selenium-server-x.x.x.jar -firefoxProfileTemplate "/path/to/the/temp/profile"

Now use the following code.

import com.thoughtworks.selenium.*;
public class Test {

public static void main(String ar[]) {

Selenium sel = new DefaultSelenium("localhost", 4444, "*firefox", "http://www.google.com/");

sel.start();
}
}

Now in the Run command type "%TEMP%" and you can see there a folder with same name as the selenium session. Copy the folder contents and replace them with your temp profile Contents.

Follow the steps below to remove the Addons compatibility.
1 . Create a new FF Profile
2 . Set the FF Profile as per required settings
3 . Just run a sample program of selenium such that it invokes firefox.
4 . Now you can find a folder with the same name as Selenium Session created somewhere in your sytsem. ( Most probably in the directory where the Temporary Content is saved)
5 . Copy the folder contents and replace them with the newly created profile.

Now you can use the newly created profile whenever required. Whenever FF is updated , always check whether the existing addons are compatible with the Existing version by once invoking firefox with the Profile.

于 2012-07-30T05:24:15.560 回答