@@ -1094,23 +1094,10 @@ protected virtual void Dispose(bool disposing)
10941094 /// <param name="desiredCapabilities">Capabilities of the browser</param>
10951095 protected void StartSession ( ICapabilities desiredCapabilities )
10961096 {
1097- DesiredCapabilities capabilitiesObject = desiredCapabilities as DesiredCapabilities ;
10981097 Dictionary < string , object > parameters = new Dictionary < string , object > ( ) ;
1099- parameters . Add ( "desiredCapabilities" , capabilitiesObject . CapabilitiesDictionary ) ;
1098+ parameters . Add ( "desiredCapabilities" , this . GetLegacyCapabilitiesDictionary ( desiredCapabilities ) ) ;
11001099
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- }
1100+ Dictionary < string , object > firstMatchCapabilities = this . GetCapabilitiesDictionary ( desiredCapabilities ) ;
11141101
11151102 List < object > firstMatchCapabilitiesList = new List < object > ( ) ;
11161103 firstMatchCapabilitiesList . Add ( firstMatchCapabilities ) ;
@@ -1127,6 +1114,47 @@ protected void StartSession(ICapabilities desiredCapabilities)
11271114 this . sessionId = new SessionId ( response . SessionId ) ;
11281115 }
11291116
1117+ /// <summary>
1118+ /// Gets the capabilities as a dictionary supporting legacy drivers.
1119+ /// </summary>
1120+ /// <param name="capabilities">The dictionary to return.</param>
1121+ /// <returns>A Dictionary consisting of the capabilities requested.</returns>
1122+ /// <remarks>This method is only transitional. Do not rely on it. It will be removed
1123+ /// once browser driver capability formats stabilize.</remarks>
1124+ protected virtual Dictionary < string , object > GetLegacyCapabilitiesDictionary ( ICapabilities capabilities )
1125+ {
1126+ Dictionary < string , object > capabilitiesDictionary = new Dictionary < string , object > ( ) ;
1127+ DesiredCapabilities capabilitiesObject = capabilities as DesiredCapabilities ;
1128+ foreach ( KeyValuePair < string , object > entry in capabilitiesObject . CapabilitiesDictionary )
1129+ {
1130+ capabilitiesDictionary . Add ( entry . Key , entry . Value ) ;
1131+ }
1132+
1133+ return capabilitiesDictionary ;
1134+ }
1135+
1136+ /// <summary>
1137+ /// Gets the capabilities as a dictionary.
1138+ /// </summary>
1139+ /// <param name="capabilities">The dictionary to return.</param>
1140+ /// <returns>A Dictionary consisting of the capabilities requested.</returns>
1141+ /// <remarks>This method is only transitional. Do not rely on it. It will be removed
1142+ /// once browser driver capability formats stabilize.</remarks>
1143+ protected virtual Dictionary < string , object > GetCapabilitiesDictionary ( ICapabilities capabilities )
1144+ {
1145+ Dictionary < string , object > capabilitiesDictionary = new Dictionary < string , object > ( ) ;
1146+ DesiredCapabilities capabilitiesObject = capabilities as DesiredCapabilities ;
1147+ foreach ( KeyValuePair < string , object > entry in capabilitiesObject . CapabilitiesDictionary )
1148+ {
1149+ if ( entry . Key != CapabilityType . Version && entry . Key != CapabilityType . Platform )
1150+ {
1151+ capabilitiesDictionary . Add ( entry . Key , entry . Value ) ;
1152+ }
1153+ }
1154+
1155+ return capabilitiesDictionary ;
1156+ }
1157+
11301158 /// <summary>
11311159 /// Executes a command with this driver .
11321160 /// </summary>
0 commit comments