c# - Confused on how to specify a Platform and Version while using ChromeOptions for RemoteWebDriver with Selenium donNet since recent updates -
c# - Confused on how to specify a Platform and Version while using ChromeOptions for RemoteWebDriver with Selenium donNet since recent updates -
using c# selenium 2.39 , before, able interact chromeoptions , desiredcapabilities directly. so, if wanted emulate android device on modern version of windows, code snippet might this:
// define chromeoptions create chrome deed mobile device chromeoptions options = new chromeoptions(); options.addargument("--user-agent=mozilla/5.0 (linux; android 4.0.4; galaxy nexus build/imm76b) applewebkit/535.19 (khtml, gecko) chrome/18.0.1025.133 mobile safari/535.19"); options.addargument("--disable-sync-passwords"); capabilities = desiredcapabilities.chrome(); //needed find win7 vm rather linux or mac capabilities.setcapability("platform", "vista"); //cef apps tested using selenium2 , grid. //a version of "real" has been created in grid config ensure //i target current chrome , not cef. capabilities.setcapability("version", "real"); capabilities.setcapability(chromeoptions.capability, options); //get new remotewebdriver thinks android device driver = new remotewebdriver(new uri(settings.remotewebdriversettings.gridlocation), capabilities); //resize mobile driver.manage().window.position = new system.drawing.point(0, 0); driver.manage().window.size = new system.drawing.size(400, 680);
however, in selenium 2.40 , above, there has been alter made breaks approach .net. best explanation of changed can find this exchange here states:
the .net bindings moving toward pattern desiredcapabilites should not used directly, remotewebdriver. facilitate that, chromeoptions class has tocapabilities() method.
try might, cannot find illustration of how set targeted platform , version while using chromeoptions, anymore.
at point, i'd take advantage of new mobileemulation introduced recent versions of chromedriver, have on hurdle, first.
any help appreciated.
got reply selenium project fellow member can seen here.
my snippet above become this, instead:
// define chromeoptions create chrome deed mobile device chromeoptions options = new chromeoptions(); options.addargument("--user-agent=mozilla/5.0 (linux; android 4.0.4; galaxy nexus build/imm76b) applewebkit/535.19 (khtml, gecko) chrome/18.0.1025.133 mobile safari/535.19"); options.addargument("--disable-sync-passwords"); //you can cast icapabilities object returned tocapabilities() desiredcapabilities capabilities = options.tocapabilities() desiredcapabilities; //needed find win7 vm rather linux or mac capabilities.setcapability("platform", "vista"); //cef apps tested using selenium2 , grid. //a version of "real" has been created in grid config ensure //i target current chrome , not cef. capabilities.setcapability("version", "real"); //get new remotewebdriver thinks android device driver = new remotewebdriver(new uri(settings.remotewebdriversettings.gridlocation), capabilities); //resize mobile driver.manage().window.position = new system.drawing.point(0, 0); driver.manage().window.size = new system.drawing.size(400, 680);
c# selenium selenium-webdriver selenium-grid
Comments
Post a Comment