Search This Blog

September 20, 2018

DesiredCapabilities is obsolete in Selenium Web Driver v.3.14, How to write the code for Selenium Grid in C#?

I upgraded Selenium Web Driver and Support to v3.14.  Noticed that the following code showed the error.  

DesiredCapabilities capabilities; --deprecated  
capabilities = DesiredCapabilities.Chrome();  --has the error 
capabilities.SetCapability(CapabilityType.Platformnew Platform(PlatformType.Windows));  
Uri uri = new Uri(hub url);  
_driver = new RemoteWebDriver(uri, capabilities, TimeSpan.FromSeconds(120));  

From the class RemoteWebDriver in OpenQA.Selenium.Remote, it still has the ICapabilities parameter.  
public RemoteWebDriver(Uri remoteAddressICapabilities desiredCapabilitiesTimeSpan commandTimeout) 

After posting the question in stackflowone nice guy replied. I created a new branch , updated the following code , set up the private branch in bamboo and ran BVTs in the Selenium Grid. The tests passed.  

ChromeOptions options = new ChromeOptions(); 
options.PlatformName = PlatformType.Windows.ToString(); 
Uri uri = new Uri(hub url); 
_driver = new RemoteWebDriver(urioptions.ToCapabilities(), TimeSpan.FromSeconds(120)); 

No comments: