'My Application throws an error when it starts at the same time as windows (Selenium)
I hope you are well, I need help, I am creating a software that starts at the same time as Windows with Selenium, this software opens a web browser in the background, but when the computer starts, I get this error:
But if I open my app again it works. How can I make it runs at the same time as Windows?
//register the application key
private void Start()
{
RegistryKey rkApp = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
if (rkApp.GetValue(Application.ProductName, Application.ExecutablePath.ToString()) != null)
{
rkApp.SetValue(Application.ProductName, Application.ExecutablePath.ToString());
}
}
private Dictionary<string, WebExplorer > _WebExplorer = new Dictionary<string, WebExplorer >()
{
["chrome"] = new ChromeWebExplorer(),
["firefox"] = new FireFoxWebExplorer(),
["edge"] = new MicrosoftEdgeWebExplorer()
};
private DriverManager _Mananger = new DriverManager();
private IWebDriver _Driver;
public WebDriver(string WebExplorer , string Version)
{
Init(WebExplorer , Version);
}
private void Init(string WebExplorer , string Version)
{
_Mananger.SetUpDriver(_WebExplorer [WebExplorer].GetConfig(), Version);
_WebExplorer[WebExplorer].Start().HideCommandPromptWindow = true;
_Driver = Navegadores[WebExplorer].GetDriver();
}
//A web explorer class
internal class MicrosoftEdgeWebExplorer: WebExplorer
{
public MicrosoftEdgeWebExplorer()
{
_Options= new EdgeOptions();
}
public override IDriverConfig GetConfig()
{
return new EdgeConfig();
}
public override IWebDriver GetDriver()
{
var Options = _Options as EdgeOptions;
Opciones.AddArguments(_Arguments);
return new EdgeDriver(_Service as EdgeDriverService,Options);
}
public override DriverService StartService()
{
_Service= EdgeDriverService.CreateDefaultService();
return _Service;
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

