gpt4 book ai didi

java - 如何使 Firefox 驱动程序与手动打开 Firefox 一样

转载 作者:行者123 更新时间:2023-11-30 09:00:09 24 4
gpt4 key购买 nike

我注意到使用 Selenium Webdriver 使用配置文件打开 Firefox 与使用完全相同的配置文件手动打开 Firefox 有很多不同。主页不会在 Selenium Webdriver 驱动程序中加载,about:config 中的非 boolean 设置无法修改……仅举几处差异。有没有办法让 Selenium Webdriver 打开 Firefox 驱动程序与手动打开 Firefox 完全一样?

编辑:这是我当前用于完整性检查的代码......

        File profileDirectory = new File("C:\\Users\\[UserName]\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles\\cox74xm7.default");
FirefoxProfile ffprofile = new FirefoxProfile(profileDirectory);
WebDriver ffdriver = new FirefoxDriver(ffprofile);

最佳答案

你需要实例化FirefoxProfile并将其传递给 WebDriver 构造函数:

File profileDirectory = new File(path);
FirefoxProfile profile = new FirefoxProfile(profileDirectory);
WebDriver webDriver = new FirefoxDriver(profile);

其中 path 是您现有配置文件的路径。

关于java - 如何使 Firefox 驱动程序与手动打开 Firefox 一样,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26914737/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com