Hy,
I'm succesfully separeted my long run thread from the main application so I can reach the Winform UI.
Now I would like to put a button to the winform to close and quit the webdriver. Here are some snippets from the code:
private void buttonStart_Click(object sender, EventArgs e)
{
Task task = Task.Run((Action) ChromeApp);
}
public void chromeApp()
{
ChromeOptions options = new ChromeOptions();
options.AddArguments("--disable-extensions");
options.AddArguments("--disable-notifications");
options.AddArguments("--disable-application-cache");
options.AddArguments("--lang=en");
IWebDriver driver = new ChromeDriver(options);
driver.Navigate().GoToUrl("webpageurl");
//
//OTHER PARTS OF THE CODE
//
driver.Close();
driver.Quit();
}
I've tried to close the driver with this code, but of course it didn't work:
The name 'driver' does not exist in the current context
public void buttonClose_Click(object sender, EventArgs e)
{
ChromeApp(driver).Close;
}
Can You help me in this case? Thank You!