import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.ie.InternetExplorerDriver; public class FirstExample { /**
* @param args
* @throws InterruptedException
*/
public static void main(String[] args) throws InterruptedException { //打开指定地方的firefox
// System.setProperty("webdriver.firefox.bin","C:\\Users\\test\\AppData\\Local\\Mozilla Firefox\\firefox.exe");
// FirefoxDriver driver = new FirefoxDriver(); //打开IE8
// System.setProperty("webdriver.ie.driver","E:\\driver\\IEDriverServer.exe");
// InternetExplorerDriver driver = new InternetExplorerDriver(); //打开chrome浏览器
System.setProperty("webdriver.chrome.driver","E:\\driver\\chromedriver.exe");
ChromeDriver driver = new ChromeDriver(); driver.get("http://localhost:8080/test/login.jsp");
driver.findElementByName("userName").sendKeys("test");
driver.findElementById("userPwd").sendKeys("test");
driver.findElementById("login").click(); System.out.println(driver.findElementByXPath("//*[@id='modify_psw']/a").getText()); driver.close();
} }

备注:
    1. firefox浏览器

selenium版本:2.44.0   firefox的版本:33.1

2. chrome浏览器

selenium版本:2.44.0   chrome版本: 33.0.1750.154   相应的chromedriver的驱动(驱动与selenium和chrome的版本也是对应的)

3. IE浏览器

selenium版本:2.44.0   IE版本: IE8   相应的IE的驱动(驱动与selenium和IE的版本也是对应的)

WebDriver中启动不同的浏览器的更多相关文章

  1. python webdriver api-对启动的火狐浏览器添加配置

    Webdriver启用的火狐不带插件,可以自已进行配置 先找到火狐的安装路径 C:\Program Files\Mozilla Firefox 步骤说明 在CMD中使用cd命令进入firefox.ex ...

  2. 在IE中启动火狐——自定义浏览器链接协议

    有时候需求就是这么奇葩,特别是在这个浏览器混战收尾的节骨眼上,有的客户正在将全单位的浏览器统一到Chrome.有的正在统一到Firefox.还有的正在统一到360上.于是就有了如题的需求,客户正在将浏 ...

  3. 为什么eclipse中启动tomcat后,浏览器中出现404?

    问题描述: tomcat压缩包加压后,启动lib文件夹下面的startup.bat,在浏览器中输入http://localhost:8080/后出现熟悉的界面. 但是在eclipse中,jsp可以正常 ...

  4. HTML5移动Web开发(十)——在浏览器中启动手机原生应用

    用户可以在浏览器中启动移动设备的原生应用程序,比如地图.电话.短信等,具体能够启动哪些应用程序,这取决于该移动设备上哪些原生应用是否允许从浏览器启动. 新建ch02r05.html <!doct ...

  5. eclipse中tomcat能正常启动,但是浏览器访问不了tomcat首页

    在eclipse中新建tomcat7,完成后tomcat能够正常启动,但是浏览器问题localhost:8080访问不了. 解决方法如下: 双击eclipse中服务器中的tomcat 出现tomcat ...

  6. Python Webdriver 重新使用已经打开的浏览器实例

    因为Webdriver每次实例化都会新开一个全新的浏览器会话,在有些情况下需要复用之前打开未关闭的会话.比如爬虫,希望结束脚本时,让浏览器处于空闲状态.当脚本重新运行时,它将继续使用这个会话工作.还就 ...

  7. Selenium3 Python3 Web自动化测试从基础到项目实战之一启动不同的浏览器及配置

    在web自动化中目前selenium作为底层的自动化测试是目前运用最广的,但是各个公司都会在这个基础之上进行修改.从今天开始我们就慢慢从low代码一步一步的学习框架知识. 首先当我们测试环境有了之后我 ...

  8. Selenium_Selenium WebDriver 中鼠标和键盘事件分析及扩展

    在使用 Selenium WebDriver 做自动化测试的时候,会经常模拟鼠标和键盘的一些行为.比如使用鼠标单击.双击.右击.拖拽等动作:或者键盘输入.快捷键使用.组合键使用等模拟键盘的操作.在 W ...

  9. 设置sublime text2/3中默认预览浏览器快捷键的方法

    各位前端大神们,大家在用IDE编辑器的时候喜欢用哪些呢?是Dreamweaver.Zend Studio.editplus又或者是sublime text?今天马浩周给大家就要说说设置sublime ...

随机推荐

  1. LiveUpdate Adminstrator配置手册

    第一种模式: LUA 从Symantec官网LiveUpdate服务器下载更新. .登陆LUA控制台 图1 .添加Symantec Endpoint Protecton v11.0 图2 3. 查看源 ...

  2. ubuntu下用virtualbox安装windows虚拟机

    按照这个教程: http://jingyan.baidu.com/article/eae07827856ac21fed54856f.html 安装. 会出现问题:"VT-x is disab ...

  3. [ZZ] [siggraph10]color enhancement and rendering in film and game productio

    原文link:<color enhancement and rendering in film and game production> 是siggraph 2010,“Color Enh ...

  4. Mac OS X 中安装JDK 7

    通过Mac系统的更新安装Java的版本均为JDK 6的版本,如果想要在Mac上安装JDK 7,就需要到Oracle的网站上去下载相应的安装包. 下面为详细教程: 最新版本为JDK8,目前需求JDK7够 ...

  5. A VNC server is already running as :1

    root@host:~# rm -f /tmp/.X1-lock root@host:~# rm -f /tmp/.X11-unix/X1 root@host:~# vncserver -geomet ...

  6. Ruby--String

    --全部转为小写:[STR].downcase --全部转为大写:[STR].upcase --仅仅首字母为大写:[STR].capitalize --每个单词首字母为大写:[STR].titleiz ...

  7. [转]为何TCP/IP协议栈设计成沙漏型的

    http://m.blog.csdn.net/blog/dog250/18959371 前几天有人回复我的一篇文章问,为何TCP/IP协议栈设计成沙漏型的.这个问题问得好!我先不谈为何它如此设计,我一 ...

  8. php-->mongodb[curd操作]

    <?php /** * PHP操作MongoDB学习笔记 */ //************************* //**   连接MongoDB数据库  **// //********* ...

  9. A Realistic Evaluation of Memory Hardware Errors and Software System Susceptibility

    http://www.cs.rochester.edu/~kshen/papers/usenix2010-li.pdf Abstract Memory hardware reliability is ...

  10. Behavior-Based Intelligence

    Computer Science An Overview _J. Glenn Brookshear _11th Edition Early work in artificial intelligenc ...