如何将FirefoxProfile与IWebDriver一起使用

时间:2016-05-20 16:37:10

标签: c# selenium

Firefox有很多问题。对于大多数人来说,我发现了许多使用FirefoxDriver对象的解决方案。但是我需要使用RemoteWebDriver

我的问题的所有解决方案都使用FirefoxProfile对象。有没有办法将此个人资料用于IWebDriver

我需要做的一件事是使用配置文件来执行此操作:

Firefox webdriver opens first run page all the time

以下是我使用IWebDriver的方式:

driver = new RemoteWebDriver(new Uri("http://localhost:4444/wd/hub"), DesiredCapabilities.Firefox(), TimeSpan.FromSeconds(timeout));

1 个答案:

答案 0 :(得分:1)

首先创建FirefoxProfile,然后将其添加到功能中:

// create the profile
var profile = new FirefoxProfile();

// create the capabilities
var capabilities = DesiredCapabilities.Firefox();
capabilities.SetCapability(FirefoxDriver.ProfileCapabilityName, profile.ToBase64String());

// start the remote driver
IWebDriver driver = new RemoteWebDriver(new Uri("http://localhost:4444/wd/hub"), capabilities);