51Testing软件测试论坛

 找回密码
 (注-册)加入51Testing

QQ登录

只需一步,快速开始

微信登录,快人一步

查看: 1714|回复: 0
打印 上一主题 下一主题

聊聊Selenium不同webdriver的构造

[复制链接]

该用户从未签到

跳转到指定楼层
1#
发表于 2019-3-22 15:55:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式


本文主要讨论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

  1. Map<String, String> mobileEmulation = new HashMap<>();
  2.         mobileEmulation.put("deviceName", "iphone 5");

  3.         Map<String, Object> chromeOptions = new HashMap<>();
  4.         chromeOptions.put("mobileEmulation", mobileEmulation);
  5.         dcaps.setCapability(ChromeOptions.CAPABILITY, chromeOptions);复制代码
复制代码

firefoxdriver(geckodriver)
  1. FirefoxProfile profile = new FirefoxProfile();
  2.             profile.setEnableNativeEvents(true);
  3.             profile.setAcceptUntrustedCertificates(true);
  4.             profile.setAssumeUntrustedCertificateIssuer(false);
  5.             dcaps.setCapability(FirefoxDriver.PROFILE, profile);复制代码
复制代码
firefox的功能看起来相对鸡肋一些

通用设置
  1.     LoggingPreferences logging = new LoggingPreferences();
  2.         logging.enable(LogType.PERFORMANCE, Level.ALL);
  3.         logging.enable(LogType.BROWSER, Level.ALL);
  4.         dcaps.setCapability(CapabilityType.LOGGING_PREFS, logging);
  5.         dcaps.setCapability(CapabilityType.ForSeleniumServer.ENSURING_CLEAN_SESSION, true);复制代码
复制代码



分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏
回复

使用道具 举报

本版积分规则

关闭

站长推荐上一条 /1 下一条

小黑屋|手机版|Archiver|51Testing软件测试网 ( 沪ICP备05003035号 关于我们

GMT+8, 2024-4-19 14:48 , Processed in 0.063791 second(s), 23 queries .

Powered by Discuz! X3.2

© 2001-2024 Comsenz Inc.

快速回复 返回顶部 返回列表