selenium2.0不通浏览器启动方式汇总

老牛6000000刀 2014-03-07 06:14:08
//打开默认路径的firefox
WebDriver diver = new FirefoxDriver();
//打开指定路径的firefox,方法1
System.setProperty("webdriver.firefox.bin",
"C:/Program Files/Mozilla Firefox/firefox.exe");
WebDriver driver = new FirefoxDriver();
//打开指定路径的firefox,方法2
File pathToFirefoxBinary = new File( "C:/Program Files/Mozilla Firefox/firefox.exe");
FirefoxBinary firefoxbin = new FirefoxBinary(pathToFirefoxBinary);
WebDriver driver1 = new FirefoxDriver(firefoxbin,null);


//打开ie
WebDriver ie_driver = new InternetExplorerDriver();

//打开chrome
下载chromedirver.exe 并解压放置到windows/system32目录下,
下载路径:http://chromedriver.storage.googleapis.com/index.html
System.setProperty("webdriver.chrome.bin","C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe");
WebDriver driver = new ChromeDriver();

//打开浏览器
driver.get("http://www.baidu.com");
...全文
41 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

50,526

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧