C#环境下,使用Selenium调用不同的浏览器,可以使用如下方法:

 IWebDriver driver = null;
string Browser =null;
if (Browser.Equals("IE"))
{
  InternetExplorerOptions options = new InternetExplorerOptions();
  options.IntroduceInstabilityByIgnoringProtectedModeSettings = true;
  driver = new InternetExplorerDriver(options); }
else if (Browser.Equals("Chrome".ToUpper()))
{
  driver = new ChromeDriver();
}
else
{
  driver = new FirefoxDriver();
}

注意实现:

1、使用IE浏览器的时候要在该项目的bin\Debug或bin\Release目录下添加IEDriverServer.exe文件。

用nuget获取IEDriverServer.exe:Install-Package WebDriver.IEDriverServer.win32

2、使用IE时要取消浏览器的保护模式,添加如下代码。

InternetExplorerOptions options = new InternetExplorerOptions();
options.IntroduceInstabilityByIgnoringProtectedModeSettings = true;

3、使用Chrome浏览器的时候要在该项目的bin\Debug或bin\Release目录下添加chromedriver.exe文件。

  用nuget获取chromedriver.exe:Install-Package Selenium.WebDriver.ChromeDriver

Selenium调用Chrome,Firefox,IE的更多相关文章

  1. python+selenium调用chrome打开网址获取内容

    目录 1,安装selenium和配置chromedriver 2,调用chromedriver打开网页获取网页内容 3,模拟登陆百度云 附录(webdriver版本兼容列表) 通过selenium库, ...

  2. [Python爬虫] Selenium自动访问Firefox和Chrome并实现搜索截图

    前两篇文章介绍了安装,此篇文章算是一个简单的进阶应用吧!它是在Windows下通过Selenium+Python实现自动访问Firefox和Chrome并实现搜索截图的功能.        [Pyth ...

  3. selenium启动Chrome时,加载用户配置文件

    selenium启动Chrome时,加载用户配置文件   Selenium操作浏览器是不加载任何配置的,网上找了半天,关于Firefox加载配置的多点,Chrome资料很少,下面是关于加载Chrome ...

  4. Python+Selenium与Chrome如何进行完美结合

    zhuan:http://blog.51cto.com/starpoint/2102975?cid=704621 使用WebDriver在Chrome浏览器上进行测试时,需要从http://chrom ...

  5. 结合FireBreath在Chrome/FireFox的多进程模式下崩溃一例

    FireBreath是跨浏览器跨操作系统的插件方案,它封装了ActiveX和NPAPI的插件接口,使用统一的API来暴露JSAPI.Chrome和FireFox使用NPAPI,IE使用ActiveX. ...

  6. selenium与chrome浏览器及驱动的版本匹配

    用selenium+python+webdriver完成UI功能自动化,经常会碰到浏览器版本与驱动的版本不匹配而引起报错,下面就selenium与chrome浏览器及驱动的版本匹配 做个总结. 使用W ...

  7. selenium调用webdriver异常

    使用selenium调用webdriver的时候报错. from selenium import webdriver browser = webdriver.Chrome() browser.get( ...

  8. ubuntu 安装 selenium selenium操作 chrome

    重装虚拟机,好多包需要重装,sele这个记得当时就找了好久的完整重装方法,这次又找了好久,,,省的下次再这样,记录下来..... ubuntu16.04 4安装seleniumsudo pip ins ...

  9. Chrome/FireFox处理JSON的插件

    Chrome/FireFox处理JSON的插件 JSON插件   效果对比 对于json的数据如果不编排一下格式查看起来很费劲,今天推荐一款chrome/Firfox下处理json的插件JSON-ha ...

随机推荐

  1. [DFNews] Touch ID不是神话,指模依旧能搞定。

    扫描制作翻模,使用含石墨硅胶压膜,前者复制指纹纹路,后者欺骗活体检测.

  2. VC非法内存值的判断

    0xcdcdcdcd - Created but not initialised0xdddddddd - Deleted0xfeeefeee - Freed memory set by NT's he ...

  3. SpringMVC环境搭建 配置文件_2

    applicationContext 命名空间: 引入命名空间,这样可以在代码中使用annotation xmlns="http://www.springframework.org/sche ...

  4. 在windows编译MariaDB

    OS: Windows XP sp3 IDE: VS2010 MariaDB: V5.5 (到目前为止2016.5,中文域(.cn)只有清华大学 TUNA 镜像源可用) (.tar.gz为源码:.zi ...

  5. 好的sql

    select count(2) from vw_pmcthtdj A WHERE a.HTBL_ID not in (select jg.jgjs_htid from PMCTJGJS jg wher ...

  6. Caused by: java.lang.NoSuchMethodError: javax.persistence.spi.PersistenceUnitInfo.getValidationMode

    进行 spring mvc jpa整合时.Junit方法测试时. 异常: org.springframework.beans.factory.BeanCreationException: Error ...

  7. 使用FIO对SATA、SSD和PCIe Flash进行测试

    首先声明,同事做的实验 使用fio对SATA.SSD.PCIE进行了测试 测试说明: 1.测试命名   sync_write_4k_32      sync表示测试方式,可以是sync或者libaio ...

  8. mongodb 分组查询

    数据的保存 include_once 'mDB.class.php'; $m=new mDB(); $m->setDB('mydb'); // $m->save('stu',['dept' ...

  9. Python自动化 【第十一篇】:Python进阶-RabbitMQ队列/Memcached/Redis

     本节内容: RabbitMQ队列 Memcached Redis 1.  RabbitMQ 安装 http://www.rabbitmq.com/install-standalone-mac.htm ...

  10. centos7.2环境elasticsearch-5.0.1+kibana-5.0.1+zookeeper3.4.6+kafka_2.9.2-0.8.2.1部署详解

    centos7.2环境elasticsearch-5.0.1+kibana-5.0.1+zookeeper3.4.6+kafka_2.9.2-0.8.2.1部署详解 环境准备: 操作系统:centos ...