c# - Confused on how to specify a Platform and Version while using ChromeOptions for RemoteWebDriver with Selenium donNet since recent updates -
Using Selenium 2.39 and earlier c #, you were able to interact directly with ChromeOptions and DesiredCapabilities. Therefore, if you want to customize an Android device to a modern version of Windows, then your code snippet can look like this:
// Chrome is the option of the mobile device chrome option Set Chrome options to work as well = new ChromeOptions (); Options.AddArgument ("User-agent = Mozilla / 5.0 (Linux; Android 4.0.4; Galaxy Nexus Build / IMM 76b) Apple WebKat / 535.19 (like KHTHML, GECO) Chrome / 18.0.1025.133 Mobile Safari / 535.19") ; Options.AddArgument ("- disabled-sync-password"); Capabilities = desired capabilities Chrome (); // Need to find Win7 VM instead of Linux or Mac capabilities. Capability ("platform", "Vista"); // CEF Apes has also been tested using Selenium 2 and Grid. // A version of "real" has been created in my grid config, to ensure that I target the current Chrome and not the CEF. Capabilities. Set capability ("version", "real"); Capabilities. Capability (chrome option. Ability, option); // Get a new remote web device, which thinks this is an Android device driver = new remote web device (new URI (settings.remoteWebDriver settings.Grid Location), capabilities); // Resize for mobile driver. Management (). Window.Position = new System.Drawing.Point (0, 0); Driver. Management (). Window. Size = new system Drawing. Size (400, 680);
However, in Selenium 2.40 and above, a change has been made that breaks this approach to the Net. I know how it has changed, its best description is from that state:
.NET binding is moving towards a pattern where the desired capabilities are not used directly Should be done, even with remote web drivers. To facilitate this, the ChromeOptions class has a ToCapabilities () method.
I can not find a good example of setting up a targeted platform and version using ChromeOptions as much as possible.
At some point, I want to take advantage of the new mobile emulation that was introduced with recent versions of the chrome driver, but I have to eliminate this obstacle first.
Any help would be greatly appreciated.
Get an answer back from Selenium Project member.
My snippet from above goes something like this, instead:
// Chrome defines Chrome options to act as a mobile device Chrome option Option = new chrome option (); Options.AddArgument ("User-agent = Mozilla / 5.0 (Linux; Android 4.0.4; Galaxy Nexus Build / IMM 76b) Apple WebKat / 535.19 (like KHTHML, GECO) Chrome / 18.0.1025.133 Mobile Safari / 535.19") ; Options.AddArgument ("- disabled-sync-password"); // You can put ICPP objects by Tocapabilities () as desired capabilities = options.ToCapabilities () as DesiredCapabilities; // is required to find Win7 VM instead of Linux or Mac capabilities. Capability ("platform", "Vista"); // CEF Apes has also been tested using Selenium 2 and Grid. // A version of "real" has been created in my grid config, to ensure that I target the current Chrome and not the CEF. Capabilities .etc capacity ("version", "real"); // Get a new remote webware that thinks this is an Android device driver = new remote web device (new URI (settings.remoteWebDriver settings.Grid Location), capabilities); // Resize for mobile driver. Management (). Window.Position = new System.Drawing.Point (0, 0); Driver. Management (). Window. Size = new system Drawing. Size (400, 680);
Comments
Post a Comment