【发布时间】: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 配置文件位置?每当我的脚本执行时,它不应采用默认配置文件位置,而应指向新的用户配置文件位置。谁能告诉我怎么做?
【问题讨论】: