当前的Selenium.NET源不再需要此技术。
DriverProcessStarting现在,该事件使用户可以修改
ProcessStartInfo用于启动驱动程序服务过程的对象。完成此操作的代码如下所示:
假设您的用户对象看起来像这样:
public class User{ public string UserName { get; set; } public SecureString Password { get; set; } public string Domain { get; set; } public bool LoadUserProfile { get; set; }}您可以使用如下所示的内容:
public IWebDriver StartInternetExplorerDriver(InternetExplorerOptions options, User user){ InternetExplorerDriverService service = InternetExplorerDriverService.CreateDefaultService(); service.DriverProcessStarting += (object sender, DriverProcessStartingEventArgs e) => { e.DriverServiceProcessStartInfo.UserName = user.UserName; e.DriverServiceProcessStartInfo.Password = user.Password; e.DriverServiceProcessStartInfo.Domain = user.Domain; e.DriverServiceProcessStartInfo.LoadUserProfile = user.LoadUserProfile; }; return new InternetExplorerDriver(service, options);}


