I want to start new browser Chrome process.
In the class ChromeDriver
have a method to do this.
And tried to initialize ChromeDriver
like this:
ChromeDriver browser;
private void OpenBrowser()
{
browser = new ChromeDriver(Browsers.Chrome);
}
Problem is:
I start n process browser Chrome, and it runs only one browser, another process not run my code(although it initialized).
So, I tried to change code:
private void OpenBrowser()
{
var browser = new ChromeDriver(Browsers.Chrome);
}
It's working, but another method was using the browser. But I can't declare var browser
out of a method.
It will return error like:
The contextual keyword 'var' may only appear within a local variable declaration or in script code
Updated:
I saw all answer and know var
is ChromeDriver
in my situation.
But when to run it, have the problem.
I will describe more information.
Suppose, I need to start 2 Chrome process. After initialized two Chrome process, I will go to URL with:
browser.GoToUrl(link);
So, I will know it working or not working.
At first, the case using ChromeDriver
it still opens 2 Chrome process, but it was only working with the second process, the first process not working.
At second, the case using var
keyword, it opens 2 Chrome process, and it was also working with two processes.