`
shijunjuan
  • 浏览: 46333 次
  • 性别: Icon_minigender_2
  • 来自: 上海
社区版块
存档分类
最新评论

OperaDriver

阅读更多
OperDriver
OperaDriver是WebDriver厂商Opera Software和志愿者开发了对于Opera的WebDriver实现。
OperaDriver可以驱动浏览器对您的网页运行不通的测试,就像真实用于一样在他们之间导航。他可以模仿象点击链接,输入文字,提交表单的动作,并把结果报告给您,这样你就知道网站是否象您希望的那样工作。
OperaDriver的终端用户模拟确保了你的整个堆栈(HTML、脚本、样式嵌入资源和后端设置)是正常的,并且没有繁琐的手工测试例程。
要求
您需要JRE1.5(Oracle或OpenJDK)或以上来使用OperaDriver。它使用Scope interface(与Dragonfly一样)来直接在Java中与Opera直接通讯。所以,他和Opera 11.6级以上的版本兼容,虽然他和老的版本做一些调整也可勉强使用。
OperaDriver Server期望你安装了Opera或者Opera Next在每个系统的缺省路径:
OS Expected Location of Opera
GNU/Linux /usr/bin/opera

/usr/bin/opera-next

/usr/bin/operamobile
Mac /Applications/Opera.app/Contents/MacOS/Opera

/Applications/Opera Next.app/Contents/MacOS/Opera

/Applications/Opera Mobile Emulator.app/Contents/Resources/Opera Mobile.app/Contents/MacOS/operamobile
Windows %PROGRAMFILES%\Opera\opera.exe

%PROGRAMFILES%\Opera Next\opera.exe

%PROGRAMFILES%\Opera Mobile Emulator\OperaMobileEmu.exe
你也可以通过opera.binary的capability设置或者环境变量OPERA_PATH来更改该路径。可以在Advanced Usage中得到更多关于OperaDriver配置的信息。
11.52或更低版本的OperaDriver
在低于11.52版本的Opera中使用OperaDriver,请确保opera.port的capabilites值为-1,opera.profile的值为””(空字符串)来禁用-debugproxy和-pd这些在老版本中不支持的命令行参数。对于更老的版本(11.01或者更老)你可能需要使用脚本的包装:(见下面)
开始
远程
去安装请去下载页面 下载selenium-server-standalone或selenium-server,确保你有一个相当最近版本的Opera安装。你所需要做的就是创建一个WebDriver实例:
WebDriver driver = new OperaDriver();
driver.navigate().to("http://opera.com/");
WebDriver提供了多个语言的API,你可以在Ruby中做同样的事,通过设置环境变量“SELENIUM_SERVER_JAR”为*selenium-server-standalone JAR的全路径。
export SELENIUM_SERVER_JAR=/path/to/selenium-server-standalone.jar
然后在Ruby中:
require 'selenium-webdriver'
driver = Selenium::WebDriver.forpera
driver.navigate.to 'http://opera.com/'
在Python中:
from selenium import webdriver
driver = webdriver.Opera()
driver.get('http://opera.com/')
把Server作为一个单独进程运行
OperaDriver与任何一个RemoteWebDriver客户端兼容。简单地启动您的服务器,创建一个远程客户端:
WebDriver driver = new RemoteWebDriver("http://localhost:9515", DesiredCapabilities.opera());
单独的OperaDriver
也可以使用OperaDriver作为您项目的一个单独的依赖。在Github project's download section下载,解压缩。在examples目录中有一些例子。你自己的项目中,在classpath中include lib目录,例如:
javac -classpath "lib/*:." Example.java
在Eclipse中,可在Project>Properties>Java Build Path中”Add JARs…” 或者”Add External JARs…”取决于您项目布局。
也可以使用Maven,group id是com.opera,artifact ID是operadriver。
文档
高级使用
Capabilities:
您可以使用DesiredCapabilities类来制定OperaDriver的设置。支持的capabilities有:
Capability Type Default Description
opera.logging.level String/Level
Level.INFO 日志的详细级别SEVERE, WARNING, INFO, CONFIG, FINE, FINER, FINEST, ALL.
opera.logging.file String null 日志的文件默认是不写到文件中.
opera.binary String system Opera binary Opera binary 的绝对路径. 如果没有指定,是安装路径。
opera.arguments* String null 传给Opera的参数,以空格分隔。参看Opera -help
opera.host String "127.0.0.1" Opera需要链接的Host。除非Opera在别的机器,否则不需要使用。
opera.port Integer random port Opera连接的端口. 0 = 随机端口, -1 = Opera默认 (port 7001) (for use with Opera < 12).
opera.launcher String ~/.launcher/LAUNCHER launcher binary的绝对路径. Launcher是OperaDriver 和Opera浏览器之间的一个网关,用来控制和监视binary,截屏。 默认使用OperaDriver提供的Launcher
opera.profile String/OperaProfile OperaProfile Opera使用的profile的目录.空是指一个新的随机Profile.如果 "", 空字符串, 那么默认的autotest 目录将会使用.
opera.idle Boolean false 是否使用 Opera 的imlpementation. 它将使用一个浏览器内置的启发式猜测页面何时完成加载,默认禁止。
opera.display Integer null 使用的X 显示, 通常为Xvfb 或者tightvncserver. ( UNIX-like OSes.)
opera.autostart Boolean true 是否自动启动Opera binary. 如果false, OperaDriver 会等待浏览器的连接. 到 "opera:debug", 输入正确的端口点"Connect"手动连接。
opera.no_restart Boolean false 是否重启.
opera.no_quit Boolean false 当OperaDriver 关闭时是否退出Opera. 如果启动,不退出
opera.product String null 我们使用的产品如"desktop", "core-desktop" 或 "sdk". See OperaProduct

使用capabilities:
DesiredCapabilities capabilities = DesiredCapabilities.opera();
capabilities.setCapability("opera.profile", new OperaProfile("/path/to/existing/profile"));
capabilities.setCapability("opera.logging.level", Level.CONFIG);
capabilities.setCapability("opera.logging.file", "/var/log/operadriver.log");
capabilities.setCapability("opera.display",;

// Now use it
WebDriver driver = new OperaDriver(capabilities);
driver.navigate().to("http://opera.com/");
定制Profile
您也可以指定一个Opera使用的profile。您可以使用一个新的随机的Profile(默认的)或者指定一个系统的Profile。您可以在Opera启动之前操作Profile,例如,设置您想要的Preferences。
OperaProfile profile = new OperaProfile();  // fresh, random profile
profile.preferences().set("User Prefs", "Ignore Unrequested Popups", false);
DesiredCapabilities capabilities = DesiredCapabilities.opera();
capabilities.setCapability("opera.profile", profile);
WebDriver driver = new OperaDriver(capabilities);
环境变量
为了制定opera安装路径和命令行参数,您需要使用环境变量。下表是您可以使用的环境变量:
Name Description
OPERA_PATH The absolute path to the Opera binary you want to use. If not set OperaDriver will try to locate Opera on your system.
OPERA_ARGS A space-delimited list of arguments to pass on to Opera, e.g. -nowindow, -dimensions 1600x1200, &c. See opera -help to view available arguments.
OPERA_PRODUCT To override the product check when running the OperaDriver tests.
如何设置环境变量,
GNU/Linux和Mac:export OPERA_PATH=…,添加这行到~/.bashrc(或者您的Shell的配置文件)来使用后面章节的特性。
Windows: 请参考http://support.microsoft.com/kb/310519

支持的Opera版本:
DeskTop
这是OperaDriver支持的官方Opera Desktop版本:
Version Workaround/tweaks needed
12.00 (Not released yet)
11.62
11.61
11.60
11.52 Set opera.port to -1 and opera.profile to "" (empty string) to disable -debugproxy and -pd command-line arguments
11.51
11.50
11.51
11.11
11.10
11.01 -autotestmode command-line argument is not supported, use a wrapper script
11.00
Wrapper script
一些老的版本默认不支持-autotestmode,-debugproxy和-pd等参数,您可以通过创建一个wrapper script绕过这些问题,把capability opera.binary执行它的绝对路径。
#!/bin/sh
# Wrapper to prevent the -autotestmode argument reaching this version of Opera
# which doesn't support it.
`dirname $0`/opera
已知问题:
Modifer Key的状态不能在Actions的多个.sendkeys调用中保持。
启用IME特性的Opera的问题(Opera Mobile, Android)
不支持Opera Mini。
不支持javascript 报警弹出框。
getScreenshotAs()只返回当前视区的图像,其他图像为空白。
在windows vista和win7,当Opera 11.5安装在默认路径时,需要管理员权限。
不可以移动到链接中的图片。
在视区中来回移动鼠标坐标有问题。
多字节输入在Windows中会失败。
双击一个元素时,EcmaScript dbClick事件没有被触发。
在Mac中Opera需要全部的焦点。
分享到:
评论

相关推荐

    Selenium Webdriver operadriver_win64

    "operadriver_win64"表明这是一个适用于64位Windows操作系统的Operadriver版本。在Windows 64位系统上运行32位软件可能会遇到性能问题或不兼容性,因此使用对应位数的驱动程序是非常必要的。这个版本确保了在64位...

    Web网页测试工具OperaDriver.zip

    OperaDriver 可让浏览器对web网页进行各种不同测试,包括链接点击、文本输入、表单提交等动作,并对测试的结果进行报告。 标签:OperaDriver

    Chromedriver、Operadriver、phantomjs

    4. Operadriver_linux64 5. Operadriver_mac64 6. Operadriver_win32 7. Operadriver_win64 8. phantomjs_win 9. phantomjs_mac 10.phantomjs_linux 验证程序(以Opera为例) from selenium import webdriver import ...

    operadriver.exe

    selenium模块使用的operadriver,适用python3 , 保存过来以便不时之需

    operadriver_win64.zip

    标题“operadriver_win64.zip”提示我们这是一个与Opera浏览器和Selenium自动化测试相关的文件。这个压缩包包含了适用于Windows 64位系统的Opera WebDriver,它是一个自动化工具,允许程序员通过编写代码来控制和...

    operadriver

    Selenium Webdriver自动化测试 operadriver win64位,最新版本(20150611)

    operadriver for python

    "operadriver for python"就是这样一个工具,它专门用于配合Python进行Opera浏览器的自动化测试。 Opera浏览器是一款基于Chromium内核的浏览器,提供了快速、安全的网页浏览体验。尽管它不如Chrome那么普及,但在...

    Selenium-operadriver

    Selenium使用的opera driver,功能自动化测试。可以使用Selenium直接调用driver完成功能自动化测试

    chromedriver、IEDriverServer、operadriver、phantomjs

    涵盖范围: 1. chromedriver.exe ...3. operadriver.exe 4. phantomjs.exe 自行验证(以Chrome为例): from selenium import webdriver driver = webdriver.Chrome() url = "http://www.baidu.com" driver.get(url)

    operachromiumdriver, 基于 Chromium的Opera 版本的OperaDriver.zip

    operachromiumdriver, 基于 Chromium的Opera 版本的OperaDriver OperaChromiumDriver介绍OperaChromiumDriver是由 ChromeDriver 和 Opera 插件衍生而来的实现,它支持基于桌面和Android平台的chrome产品的编程自动化...

    selenium driver

    文件名`operadriver-v0.6.zip`可能表示的是OperaDriver的一个早期版本,版本号为0.6。 在使用Selenium与这些驱动器配合时,你需要导入Selenium的WebDriver模块,然后实例化对应的浏览器驱动,如`webdriver.Chrome()...

    浏览器驱动合集.rar

    在这个压缩包中,我们看到了"operadriver_win64",这表明包含的是Opera浏览器的驱动程序,适用于64位的Windows操作系统。OperaDriver是Opera浏览器的WebDriver实现,它使得可以通过Selenium WebDriver API来控制...

    selenium webdriver学习.zip

    WebDriver支持Firefox (FirefoxDriver)、IE (InternetExplorerDriver)、Opera (OperaDriver) 和Chrome (ChromeDriver)。对Safari的支持由于技术限制在本版本中未包含,但是可以使用SeleneseCommandExecutor模拟。它...

    selenium-2.24-server-all

    "operadriver" 对应于 Opera 浏览器,使得 Selenium 可以控制 Opera 进行自动化测试。"iedriverserver" 是针对 Internet Explorer 浏览器的 WebDriver 实现,让 Selenium 能够在 IE 上运行自动化测试。"selenium-ide...

    Selenium WebDriver Project on Eclipse

    &lt;artifactId&gt;operadriver &lt;version&gt;0.14 &lt;groupId&gt;org.seleniumhq.selenium &lt;artifactId&gt;selenium-remote-driver &lt;groupId&gt;junit &lt;artifactId&gt;junit &lt;version&gt;4.10 &lt;scope&gt;test ...

    java调用浏览器实现百度签到功能

    operadriver-1.5.jar phantomjsdriver-1.1.0.jar protobuf-java-2.4.1.jar sac-1.3.jar selenium-java-2.44.0-srcs.jar selenium-java-2.44.0.jar serializer-2.7.1.jar testng-6.8.5.jar xalan-2.7.1.jar ...

    chromedriver-win64_122.0.6233.0.zip

    5. **跨平台测试**:除了Windows,Selenium还支持其他操作系统,如macOS和Linux,它们各自的驱动程序(如geckodriver for Firefox或operadriver for Opera)也需要正确配置。 了解这些知识点后,你可以更有效地利用...

Global site tag (gtag.js) - Google Analytics