【问题标题】:C# Changing the existing Firefox Profile location in selenium webdriverC# 在 selenium webdriver 中更改现有的 Firefox 配置文件位置
【发布时间】:2016-05-20 09:50:55
【问题描述】:

我创建了一个新的用户配置文件 (In Run, type -> firefox.exe -p and create a new profile)。出于演示目的,我在桌面上创建了一个新文件夹。我的新用户个人资料指向这个新位置(C:\Users\username\Desktop\TemporaryProfile)。在我的 selenium webdriver 中,我想更改 firefox 配置文件的默认位置。

FirefoxBinary binary = new FirefoxBinary(@"C:\Program Files (x86)\Mozilla   Firefox\firefox.exe");
  FirefoxProfile profile = new FirefoxProfile(@"C:\Users\username\Desktop\TemporaryProfile");                                
  FirefoxDriver driver = new FirefoxDriver(binary, profile);

在前面的代码中,它没有采用新的 Firefox 配置文件位置,而是采用现有的配置文件位置。我的意思是默认位置。

FireFoxProfile 类有一个名为profileDirectory 的属性。但不幸的是,它是一个 get 属性

public string ProfileDirectory { get; }

所以我无法设置目录位置。

如何更改 selenium webdriver 中的 firefox 配置文件位置?每当我的脚本执行时,它不应采用默认配置文件位置,而应指向新的用户配置文件位置。谁能告诉我怎么做?

【问题讨论】:

    标签: c# selenium firefox


    【解决方案1】:

    这适用于我更改个人资料:

    var option = new FirefoxOptions();
    var profile = new FirefoxProfile("Path_to_profile");
    option.Profile = profile;
    IWebDriver driver = new FirefoxDriver(option);
    

    【讨论】:

      猜你喜欢
      • 2013-02-14
      • 1970-01-01
      • 2018-03-22
      • 2015-10-01
      • 1970-01-01
      • 2011-11-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多