You can specify PhantomJS ' --web-security command line options using the PhantomJSDriverService.WebSecurity property , rather than passing it as PhantomJSOptions .
This is added in Selenium 2.32.0, quote from CHANGELOG:
(on behalf of GeoffMcElhanon) Added support for passing PhantomJS arguments. PhantomJSDriverService now has type safe properties for all command line switches supported by PhantomJS. These can be passed directly to the command line or can be serialized to a JSON file for transfer using the -config command line to PhantomJS.
Below is the unverified code, if necessary, refer to the documentation (WebDriver.chm in your Selenium zip file).
var service = PhantomJSDriverService.CreateDefaultService(Environment.CurrentDirectory + @"\drivers"); service.WebSecurity = false; var driver = new PhantomJSDriver(service);
PhantomJSDriverService has other predefined command line arguments that you can specify, please check the documentation. There are also ways to add your own arguments.
AddArgument (): Adds one argument to the list of arguments added to the PhantomJS.exe command line.
AddArguments (IEnumerable): Adds arguments to add to the command line PhantomJS.exe.
AddArguments (String []): Adds arguments to add to the command line PhantomJS.exe.
source share