聊聊Selenium不同webdriver的构造

发表于:2019-1-10 21:47

字体: | 上一篇 | 下一篇 | 我要投稿

 作者:codecraft    来源:思否

  序
  本文主要讨论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<String, String> mobileEmulation = new HashMap<>();
  mobileEmulation.put("deviceName", "iphone 5");
  Map<String, Object> 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
  webdriver

     上文内容不用于商业目的,如涉及知识产权问题,请权利人联系博为峰小编(021-64471599-8017),我们将立即处理。
《2023软件测试行业现状调查报告》独家发布~

关注51Testing

联系我们

快捷面板 站点地图 联系我们 广告服务 关于我们 站长统计 发展历程

法律顾问:上海兰迪律师事务所 项棋律师
版权所有 上海博为峰软件技术股份有限公司 Copyright©51testing.com 2003-2024
投诉及意见反馈:webmaster@51testing.com; 业务联系:service@51testing.com 021-64471599-8017

沪ICP备05003035号

沪公网安备 31010102002173号