Rav*_*ven 8 c# firefox selenium
我需要使用C#在Selenium中使用现有的Firefox配置文件.该配置文件具有我需要的已配置插件.
我发现了一些代码谷歌搜索,但那些是Java,我尝试了以下代码,但它仍然无法正常工作.
FirefoxProfile profile = new FirefoxProfile("C:\\Users\\username\\Desktop\\software\\Files");
driver = new FirefoxDriver();
Run Code Online (Sandbox Code Playgroud)
我在硒的官方文件中找到了答案
var profileManager = new FirefoxProfileManager();
FirefoxProfile profile = profileManager.GetProfile("Selenium");
IWebDriver driver = new FirefoxDriver(profile);
Run Code Online (Sandbox Code Playgroud)
资料来源:Selenium docs
在新版本中可以使用此方法
1) 转到 Firefox 配置文件选择选项
2) 创建个人资料
FirefoxProfile profile = new FirefoxProfileManager().GetProfile("axixa");
FirefoxOptions options = new FirefoxOptions();
options.Profile = profile;
IWebDriver firefox = new FirefoxDriver(options);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6466 次 |
| 最近记录: |