how to set system properties in C#
how c开发者_运维问答an i set system properties in C#.
In java i can use:
System.setProperty("webdriver.chrome.driver","/path/to/where/you/ve/put/chromedriver.exe");
how to do this in C#?
try System.Environment.SetEnvironmentVariable("webdriver.chrome.driver",@"/path/to/where/you/ve/put/chromedriver.exe")
-MSDN
There's no equivalent of "system properties" in C#. They're a Java-specific concept. (They're not really system properties in Java - they're JVM-wide-properties, some of which are derived from system environment variables etc.)
You should look in the WebDriver documentation for how to set this for the .NET version.
EDIT: Just to clarify, System.Environment.SetEnvironmentVariable
could be used in a similar way, but it tends not to be in my experience.
System.Environment
will provide you some "properties" but this is a Java specific concept which will not have any direct equivalent in C#.
You need to start Selenium Server with the following option: Dwebdriver.chrome.driver=c:\path\to\your\chromedriver.exe
Like this: java -jar selenium-server-standalone-2.42.0.jar -role node -hub http://localhost:4444/grid/register -Dwebdriver.chrome.driver=c:\path\to\your\chromedriver.exe
I realize that this thread is really old, but if you ended up on this page, an alternative solution is to add chromedriver.exe to your project, set Build Action to "Content" and set Copy to Output Directory to "Copy if newer". Then you can skip setting the environment variable.
The drawback to this solution is that you'll end up with multiple copies of a 5 MB file.
Take a look at Environment class, you could set some of the properties there.
精彩评论