WebDriver wd = new RemoteDriver("http://localhost:4444/wd/hub", aDesiredcap); //test01: 只匹配 Windows下的ie来执行此用例,版本不限;多个版本匹配成功时优先级暂未知 DesiredCapabilities aDesiredcap = DesiredCapabilities(); aDesiredcap.setBrowserName("internet explorer") aDesiredcap.setVersion("") aDesiredcap.setPlatform(Platform.WINDOWS) WebDriver wd = new RemoteDriver("http://localhost:4444/wd/hub", aDesiredcap); wd.doSomething() //test02: 只匹配linix下的firefox的版本为22的浏览器执行用例; DesiredCapabilities aDesiredcap = DesiredCapabilities("firefox", "22", Platform.LINUX); WebDriver wd = new RemoteDriver("http://localhost:4444/wd/hub", aDesiredcap); wd.doSomething() //test03: 只匹配MAC下的safari浏览器执行,版本不限 DesiredCapabilities aDesiredcap = DesiredCapabilities.safari(); aDesiredcap.setPlatform(Platform.MAC) WebDriver wd = new RemoteDriver("http://localhost:4444/wd/hub", aDesiredcap); wd.doSomething() //test04: 只匹配chrome浏览器,任意平台,任意版本 DesiredCapabilities aDesiredcap = DesiredCapabilities.chrome(); aDesiredcap.setPlatform(Platform.ANY) WebDriver wd = new RemoteDriver("http://localhost:4444/wd/hub", aDesiredcap); wd.doSomething() |