我创建了一个新的用户配置文件( In Run, type -> firefox.exe -p and create a new profile ) . 出于演示目的,我在桌面上创建了一个新文件夹 . 我的新用户 Profiles 指向此新位置 (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 Class有一个名为 profileDirectory 的属性 . 但不幸的是,这是一个获得 property

public string ProfileDirectory { get; }

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

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