博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
聊聊Selenium不同webdriver的构造
阅读量:7235 次
发布时间:2019-06-29

本文共 1642 字,大约阅读时间需要 5 分钟。

  hot3.png

本文主要讨论Selenium不同webdriver的构造

Selenium 2.0

Selenium 2,又名 WebDriver,它的主要新功能是集成了 Selenium 1.0 以及 WebDriver(WebDriver 曾经是 Selenium 的竞争对手)。也就是说 Selenium 2 是 Selenium 和 WebDriver 两个项目的合并,即 Selenium 2 兼容 Selenium,它既支持 Selenium API 也支持 WebDriver API。

支持的web driver

  • ChromeDriver
  • EventFiringWebDriver
  • FirefoxDriver
  • HtmlUnitDriver
  • InternetExplorerDriver
  • PhantomJSDriver
  • RemoteWebDriver
  • SafariDriver

PhantomJS与Ghost Driver

phantomis就是一个基于webkit的无界面浏览器,而ghost driver是phantomis的WebDriver Wire Protocol的js实现。 后来ghost driver跟phantomjs合并在一起,内嵌在phantomis中,相当于现在的phantomis = ghost driver + phantomis浏览器

driver特性

chromedriver

chrome driver的好处是支持mobile emulation

Map
mobileEmulation = new HashMap<>(); mobileEmulation.put("deviceName", "iphone 5"); Map
chromeOptions = new HashMap<>(); chromeOptions.put("mobileEmulation", mobileEmulation); dcaps.setCapability(ChromeOptions.CAPABILITY, chromeOptions);

firefoxdriver(geckodriver)

FirefoxProfile profile = new FirefoxProfile();            profile.setEnableNativeEvents(true);            profile.setAcceptUntrustedCertificates(true);            profile.setAssumeUntrustedCertificateIssuer(false);            dcaps.setCapability(FirefoxDriver.PROFILE, profile);

firefox的功能看起来相对鸡肋一些

通用设置

LoggingPreferences logging = new LoggingPreferences();        logging.enable(LogType.PERFORMANCE, Level.ALL);        logging.enable(LogType.BROWSER, Level.ALL);        dcaps.setCapability(CapabilityType.LOGGING_PREFS, logging);        dcaps.setCapability(CapabilityType.ForSeleniumServer.ENSURING_CLEAN_SESSION, true);

doc

转载于:https://my.oschina.net/go4it/blog/1561070

你可能感兴趣的文章
app_item_property.SET_PROPERTY与set_item_property有什么区别?
查看>>
Basic Tutorials of Redis(6) - List
查看>>
测试计划
查看>>
C# 学习笔记 20170406
查看>>
PHP分页倒序时,需要注意的问题
查看>>
[ZJOI2012]网络
查看>>
一款好看+极简到不行的HTML5音乐播放器-skPlayer
查看>>
计算机视觉——图像匹配(1)
查看>>
使用golang的slice来模拟栈
查看>>
error C2504: 'CRecordset' : base class undefined
查看>>
李涛PS高手之路基础篇(1)
查看>>
学习Oracle数据库入门到精通教程资料合集
查看>>
Linux Shell 教程
查看>>
【补充习题七】积分不等式及定积分性质
查看>>
任意进制转换简单理解
查看>>
Unity Game窗口中还原Scene窗口摄像机操作 强化版
查看>>
Jmeter(5)逻辑控制器(Logic Controller)
查看>>
解决网速慢时maven仓库访问慢
查看>>
webpack 4.0的一些小坑
查看>>
mysql中查询语句做为条件
查看>>