@@ -67,6 +67,9 @@ public class RemoteWebDriver : IWebDriver, ISearchContext, IJavaScriptExecutor,
6767 /// The default command timeout for HTTP requests in a RemoteWebDriver instance.
6868 /// </summary>
6969 protected static readonly TimeSpan DefaultCommandTimeout = TimeSpan . FromSeconds ( 60 ) ;
70+
71+ private static readonly string DefaultRemoteServerUrl = "http://127.0.0.1:4444/wd/hub" ;
72+
7073 private ICommandExecutor executor ;
7174 private ICapabilities capabilities ;
7275 private IMouse mouse ;
@@ -77,12 +80,31 @@ public class RemoteWebDriver : IWebDriver, ISearchContext, IJavaScriptExecutor,
7780 private ILocationContext locationContext ;
7881 private IFileDetector fileDetector = new DefaultFileDetector ( ) ;
7982
83+ /// <summary>
84+ /// Initializes a new instance of the <see cref="RemoteWebDriver"/> class. This constructor defaults proxy to http://127.0.0.1:4444/wd/hub
85+ /// </summary>
86+ /// <param name="options">An <see cref="DriverOptions"/> object containing the desired capabilities of the browser.</param>
87+ public RemoteWebDriver ( DriverOptions options )
88+ : this ( options . ToCapabilities ( ) )
89+ {
90+ }
91+
8092 /// <summary>
8193 /// Initializes a new instance of the <see cref="RemoteWebDriver"/> class. This constructor defaults proxy to http://127.0.0.1:4444/wd/hub
8294 /// </summary>
8395 /// <param name="desiredCapabilities">An <see cref="ICapabilities"/> object containing the desired capabilities of the browser.</param>
8496 public RemoteWebDriver ( ICapabilities desiredCapabilities )
85- : this ( new Uri ( "http://127.0.0.1:4444/wd/hub" ) , desiredCapabilities )
97+ : this ( new Uri ( DefaultRemoteServerUrl ) , desiredCapabilities )
98+ {
99+ }
100+
101+ /// <summary>
102+ /// Initializes a new instance of the <see cref="RemoteWebDriver"/> class. This constructor defaults proxy to http://127.0.0.1:4444/wd/hub
103+ /// </summary>
104+ /// <param name="remoteAddress">URI containing the address of the WebDriver remote server (e.g. http://127.0.0.1:4444/wd/hub).</param>
105+ /// <param name="options">An <see cref="DriverOptions"/> object containing the desired capabilities of the browser.</param>
106+ public RemoteWebDriver ( Uri remoteAddress , DriverOptions options )
107+ : this ( remoteAddress , options . ToCapabilities ( ) )
86108 {
87109 }
88110
@@ -1074,9 +1096,29 @@ protected void StartSession(ICapabilities desiredCapabilities)
10741096 {
10751097 DesiredCapabilities capabilitiesObject = desiredCapabilities as DesiredCapabilities ;
10761098 Dictionary < string , object > parameters = new Dictionary < string , object > ( ) ;
1077- Dictionary < string , object > capabilitiesParameter = new Dictionary < string , object > ( ) ;
1078- capabilitiesParameter [ "desiredCapabilities" ] = capabilitiesObject . CapabilitiesDictionary ;
10791099 parameters . Add ( "desiredCapabilities" , capabilitiesObject . CapabilitiesDictionary ) ;
1100+
1101+ // Must remove "platform" and "version" capabilities, which are not
1102+ // supported by W3C compliant remote ends. Note that this block is
1103+ // temporary and will change soon.
1104+ Dictionary < string , object > firstMatchCapabilities = capabilitiesObject . CapabilitiesDictionary ;
1105+ if ( firstMatchCapabilities . ContainsKey ( CapabilityType . Version ) )
1106+ {
1107+ firstMatchCapabilities . Remove ( CapabilityType . Version ) ;
1108+ }
1109+
1110+ if ( firstMatchCapabilities . ContainsKey ( CapabilityType . Platform ) )
1111+ {
1112+ firstMatchCapabilities . Remove ( CapabilityType . Platform ) ;
1113+ }
1114+
1115+ List < object > firstMatchCapabilitiesList = new List < object > ( ) ;
1116+ firstMatchCapabilitiesList . Add ( firstMatchCapabilities ) ;
1117+
1118+ Dictionary < string , object > specCompliantCapabilities = new Dictionary < string , object > ( ) ;
1119+ specCompliantCapabilities [ "firstMatch" ] = firstMatchCapabilitiesList ;
1120+ parameters . Add ( "capabilities" , specCompliantCapabilities ) ;
1121+
10801122 Response response = this . Execute ( DriverCommand . NewSession , parameters ) ;
10811123
10821124 Dictionary < string , object > rawCapabilities = ( Dictionary < string , object > ) response . Value ;
0 commit comments