selenlium 打开不同位置的firefox的三种方法
2016-02-23 10:58 xlmig 阅读(223) 评论(0) 编辑 收藏 举报1. System.setProperty
System.setProperty("webdriver.firefox.bin","D:/Program Files/Mozilla firefox4002/firefox.exe"); WebDriver driver = new FirefoxDriver(); driver.get("http://www.baidu.com"); driver.manage().window().maximize();
2. FirefoxBinary
FirefoxBinary firefoxBinary = new FirefoxBinary(new File("D:/Program Files/Mozilla firefox4002/firefox.exe")); FirefoxProfile firefoxprofile = new FirefoxProfile(); WebDriver driver = new FirefoxDriver(firefoxBinary,firefoxprofile); driver.get("http://www.baidu.com"); driver.close();
3. DesiredCapabilities.setCapability
DesiredCapabilities capability=DesiredCapabilities.firefox(); capability.setCapability("firefox_binary", "D:\\Program Files\\Mozilla Firefox\\firefox.exe"); WebDriver driver = new FirefoxDriver(capability); driver.get("http://www.baidu.com/");