聊聊Selenium不同webdriver的构造

数字开拓者说
• 阅读 2389

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

点赞
收藏
评论区
推荐文章
使用Python爬取QQ群成员信息
直接贴代码pythonimportosfromseleniumimportwebdriverfromselenium.webdriver.support.uiimportWebDriverWaitfromselenium.webdriver.supportimportexpectedconditionsasECfromseleni
Stella981 Stella981
3年前
Selenium Webdriver——操作隐藏的元素
作者何坤158109016@qq.com(https://www.oschina.net/action/GoToLink?urlmailto%3A158109016%40qq.com) V2.02017/3/26.更多内容请到:www.snappydata.top(https://www.oschina.net/action/GoToLin
Stella981 Stella981
3年前
Appium(三):安装appium client、adb命令
1\.安装appiumclientappiumclient是对webdriver原生api的一些扩展和封装。它可以帮助我们更容易的写出用例,写出更好的用例。appiumclient是配合原生的webdriver来使用的,因此二者必须配合使用,缺一不可。我们使用pip安装“AppiumPython
Stella981 Stella981
3年前
Python3+Selenium3自动化测试
之前的文章中,针对元素的各种属性,进行了相对应的操作,接下来可以看看selenium如何模拟操作键盘和鼠标。键盘事件webdriver可以模拟常规键盘上所有的按键操作,在导入包的源码中可以看到所有命令对应的按键。以代码的形式来展示:codingutf8importtimefr
Wesley13 Wesley13
3年前
UI自动化
codingutf8importtimefromseleniumimportwebdriverfromselenium.webdriver.common.action_chainsimportActionChainsfromselenium.webdriver.supportimpor
Stella981 Stella981
3年前
Python操作浏览器 WebDriver
\_\_author\_\_'zhangliping'fromseleniumimportwebdriverfromselenium.webdriver.common.keysimportKeysfromselenium.webdriver.common.action\_chains
Stella981 Stella981
3年前
Selenium WebDriver中一些鼠标和键盘事件的使用
在使用SeleniumWebDriver做自动化测试的时候,会经常模拟鼠标和键盘的一些行为。比如使用鼠标单击、双击、右击、拖拽等动作;或者键盘输入、快捷键使用、组合键使用等模拟键盘的操作。在WebDeriver中,有一个专门的类来负责实现这些测试场景,那就是Actions类,在使用该类的过程中会配合使用到Keys枚举以及Mouse、Ke
Stella981 Stella981
3年前
Selenium3+python几种定位元素的方法
学习小结:这里使用ChromeV73webdriver2.461几种定位方式:2Autotest.py3fromseleniumimportwebdriver4fromselenium.webdriver.common.byimportBy5importtim
Stella981 Stella981
3年前
Selenium(八)测试用例的设计与模块化
一.设计测试用例1.分析我之前写的登录脚本:fromseleniumimportwebdriverimporttimefromselenium.webdriver.common.action_chainsimportActionChainsfromselenium.webdriver.suppor
铁笛仙 铁笛仙
2年前
Selenium中控制Chorme浏览器会闪退
selenium控制浏览器会闪退,有可能是webdriver控制器的版本太低,和主机上的Chrome版本号不兼容了。
Java Selenium WebDriver:代理设置与图像捕获
在网络爬虫和自动化测试领域,SeleniumWebDriver是一个非常流行的工具,它允许开发者模拟用户在浏览器中的操作。然而,出于安全或隐私的考虑,有时我们需要通过代理服务器来发送请求。本文将介绍如何在Java环境中使用SeleniumWebDriver
数字开拓者说
数字开拓者说
Lv1
离别家乡岁月多,近来人事半消磨。
文章
5
粉丝
0
获赞
0