[英]Can't use existing Firefox profile in Selenium WebDriver using C#
[英]C# Changing the existing Firefox Profile location in selenium webdriver
我创建了一个新的用户配置文件( 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 配置文件位置? 每当我的脚本执行时,它不应采用默认配置文件位置,而应指向新的用户配置文件位置。 谁能告诉我如何做到这一点?
这适用于我更改个人资料:
var option = new FirefoxOptions();
var profile = new FirefoxProfile("Path_to_profile");
option.Profile = profile;
IWebDriver driver = new FirefoxDriver(option);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.