1、启动firefox浏览器

a.如果你的本地firefox是默认路径安装的话,如下方式即可启动浏览器

WebDriver driver = new FirefoxDriver();

driver.get("http://www.baidu.com");

b.如果不是默认路径安装,需要先将firefox.exe配置到系统变量中去,如下:

System.setProperty("webdriver.firefox.bin", "D:\\ruanjian\\Firefox\\azml\\firefox.exe");
driver = new FirefoxDriver();
String url = "http://www.baidu.com";
driver.get(url);

2、启动ie浏览器,由于ie,chrome浏览器的driverServer是由他们自己管理的,我们需要下载相应的驱动,注意区分 32位和64位,使用方法如下:

System.setProperty("webdriver.ie.driver", "src\\main\\resources\\IEDriver.exe");

WebDriver driver = new InternetExplorerDriver();
driver.get("http://www.baidu.com");
同样,如果ie不是默认路径安装需要配置bin路径到系统属性中去
Tip:加载IEDriverServer的时候,通常会因为兼容模式的设置问题,而无法启动,尝试在创建IEDriver对象的时候 加入合适的参数设置:
DesiredCapabilities ieCapabilities = DesiredCapabilities.internetExplorer();
ieCapabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
WebDriver driver =
new InternetExplorerDriver(ieCapabilities);
3、启动chrome浏览器,需要下载chromedriver驱动
System.setProperty("webdriver.chrome.driver","C:\\Program Files (x86)\\Google\\Chrome\\Application\\chromedriver_x64.exe");

WebDriver driver = new ChromeDriver();

4、启动浏览器的过程中,经常出现启动浏览器窗口,却没有完成输入url地址的情况,大部分由于版本不兼容造成的。

比如:火狐的会报如下错误
org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms.

selenium启动firefox、ie、chrome各浏览器方法的更多相关文章

  1. Selenium启动Firefox示例(java版)

    本文示例使用selenium启动Firefox,并将浏览器窗口最大化,在百度搜索框内输入"HelloWorld",最后点击搜索按钮. 源代码如下: 1 package com.se ...

  2. 7.解决在python中用selenium启动FireFox浏览器启动不了的方法

    首次在利用python中的selenium启动FireFox浏览器时可能碰到如下问题 当输入如下代码时: from selenium import webdriver brower=webdriver ...

  3. selenium启动firefox打开导入向导问题解决

    操作系统:win8-64位 火狐版本:40.0.2 问题描述:selenium启动firefox时,每次启动都提示我导入其他浏览器的页签,如下图所示 解决方法一: 到firefox的profiles. ...

  4. Selenium启动Firefox示例(python版)

    目前做selenium自动化使用的主流语言分为java和python,前一篇为java版,本篇介绍python实现selenium启动Firefox. 1 #-*- coding:utf-8 -*- ...

  5. Selenium2学习-042-Selenium3启动Firefox Version 48.x浏览器(ff 原生 geckodriver 诞生)

    今天又被坑了一把,不知谁把 Slave 机的火狐浏览器版本升级为了 48 的版本,导致网页自动化测试脚本无法启动火狐的浏览器,相关的网页自动化脚本全线飘红(可惜不是股票,哈哈哈...),报版本不兼容的 ...

  6. selenium启动firefox时加载扩展

    有些时候,我们测试需要用到插件或者已经导入的证书(比如金融和安全加密行业),而selenium启动firefox时会打开一个新的,不含有任何插件和个人证书的firefox(等同于全新安装后第一次打开的 ...

  7. selenium启动Firefox失败

    今天搭建java+selenium环境,搭建几次都失败,总结一下原因 1. selenium启动Firefox,不需要额外的driver 2. Friefox如果没有安装到默认路径C盘,代码中需要修改 ...

  8. Java+selenium+Firefox/ IE/ Chrome主流浏览器自动化环境搭建

    一.java+selenium+firefox 1.环境准备:JDK1.8 2.安装firefox浏览器v59 3.下载驱动:https://github.com/mozilla/geckodrive ...

  9. selenium调用Firefox和Chrome需要注意的一些问题,和出现的报错selenium:expected [object undefined] undefined to be a string

    在高版本selenium下如:selenium3.4.3 1.高版本的selenium需要浏览器安装一些补丁驱动 Firefox:geckodriver 下载网址:http://download.cs ...

随机推荐

  1. httpd-2.2

    http://httpd.apache.org/docs/2.2/logs.html httpd.conf文件 Configuration and logfile names: If the file ...

  2. vs2010设置 "行号显示"

    Microsoft Visual Studio 2010 默认情况下是不显示代码的行号的.在编译出错时,可点击下面输出窗口中的错误提示进行定位. 但是这样操作起来你有没有感觉到不方便呢. 不显示行号时 ...

  3. Java模板引擎 HTTL

    新一代java模板引擎典范 Beetl http://www.oschina.net/p/httl HTTL(Hyper-Text Template Language)是一个高性能的开源JAVA模板引 ...

  4. DataRow[] 转为数组

    DataRow[] rows = dt.Select("1=1"); ].ToString()).ToArray();

  5. 剑指offer系列47---翻转单词顺序

    [题目]输入“I am a student.”>>>“.tneduts a ma I”.>>输出:student. a am I package com.exe9.off ...

  6. linux时间管理

    /etc/sysconfig/clock         该配置文件可用来设置用户选择何种方式显示时间.如果硬件时钟为本地时间,则UTC设为0,并且不用设置环境变量TZ.如果硬件时钟为UTC时间,则要 ...

  7. WINDOWS黑客基础(5):利用内存来进行获取计算结果

    在前面的注入代码的章节中,我们利用了VirtualAllocEx来在对方的进程开辟了一块内存,并且将代码复制进对方进程的内存里面,从而执行那段内存的代码,但是这里有一个问题,就是代码不是执行在我们进程 ...

  8. IE浏览器的兼容模式代码细节解读

    兼容性对于网页设计师来说非常重要.虽然最好是建立一个完全不需依赖任何网页浏览器特性或功能的网站,但是有时候这是不可能实现的.而文件兼容模式能将网页限制在某个特定版本的IE中.可以使用 X-UA-Com ...

  9. [dts]Device Tree格式解析

    转自:http://blog.csdn.net/airk000/article/details/21345159 目录: 1. 作用 2. 基本数据格式 3. 一些基本概念 4. 工作方式 a. 地址 ...

  10. 黄聪:发送键盘指令System.Windows.Forms.SendKeys.Send

    若要指定在按键(如 Enter 或 Tab)时不显示的字符,以及表示操作而不表示字符的键,请使用下表中的代码:   键 代码 Backspace {BACKSPACE}.{BS} 或 {BKSP} B ...