使用 Selenium 打开网站时没有 firebug

No firebug when open a website with Selenium

我刚刚在 Selenium 的帮助下打开了 Facebook:

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class class1 {
    public static void main(String[] args) {

        System.setProperty("webdriver.gecko.driver","C:\Users\Hi\Desktop\selenium\geckodriver.exe");

        WebDriver driver = new FirefoxDriver();
        driver.get("http://www.facebook.com");


    }

}

但是那个网站上没有 Firebug。当我在没有 Selenium 的情况下正常打开浏览器时,Firebug 图标就在那里。有人可以帮忙吗?

编辑:感谢yong的帮助。借助我在此处找到的这段代码,我还找到了解决问题的好方法 http://toolsqa.com/selenium-webdriver/custom-firefox-profile/

ProfilesIni profile = new ProfilesIni();
        FirefoxProfile myProfile = profile.getProfile("default");

        System.setProperty("webdriver.gecko.driver","C:\Users\Hi\Desktop\selenium\geckodriver.exe");

        WebDriver driver = new FirefoxDriver(myProfile);
        driver.get("http://www.facebook.com");

分析:

Selenium 使用默认配置文件打开firefox,此配置文件与您手动打开的配置文件不同。一般来说,默认配置文件不会包含您在 firefox 上安装的插件。

解决方案

  1. 手动创建 firefox 配置文件,默认情况下新配置文件将包含
    http://kb.mozillazine.org/Creating_a_new_Firefox_profile_on_Windows

  2. 告诉 selenium 在打开 firefox 时使用创建的配置文件
    How to use custom Firefox Profile with Selenium? (Java) (And pass HTML Authorization Window)