前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >聊聊Selenium不同webdriver的构造

聊聊Selenium不同webdriver的构造

作者头像
code4it
发布2018-09-17 15:15:58
5790
发布2018-09-17 15:15:58
举报
文章被收录于专栏:码匠的流水账码匠的流水账

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

代码语言:javascript
复制
        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)

代码语言:javascript
复制
            FirefoxProfile profile = new FirefoxProfile();
            profile.setEnableNativeEvents(true);
            profile.setAcceptUntrustedCertificates(true);
            profile.setAssumeUntrustedCertificateIssuer(false);
            dcaps.setCapability(FirefoxDriver.PROFILE, profile);

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

通用设置

代码语言:javascript
复制
        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
本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2017-11-05,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 码匠的流水账 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • Selenium 2.0
  • 支持的web driver
  • PhantomJS与Ghost Driver
  • driver特性
    • chromedriver
      • firefoxdriver(geckodriver)
        • 通用设置
        • doc
        领券
        问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档