Selenium Ruby绑定功能文档 [英] Selenium Ruby Binding Capabilities Documentation
问题描述
我是Selenium Ruby绑定的新手.我想知道文档网站,在这里可以找到Ruby Driver功能可用的选项.
I am new to Selenium Ruby binding. I want to know the document website where I can find the options available for Ruby Driver capabilities.
我搜索了网络,发现大部分与Java相关的帖子:
I have searched the web and found mostly Java related posting:
https://code.google.com/p/selenium/wiki/DesiredCapabilities
我需要特别了解Ruby的等效功能:" unexpectedAlertBehaviour "功能.
I need to know the especially Ruby equivalent for : "unexpectedAlertBehaviour" capability.
谢谢.
添加了代码:
代码
def initialize(driverType)
begin
cap = Selenium::WebDriver::Remote::Capabilities.ie(:ignore_protected_mode_settings=>true)
@@driver = Selenium::WebDriver.for driverType,:desired_capabilities=>cap
@@driver.manage.window.maximize
rescue Exception=>e
puts e.message
end
结束
推荐答案
从链接- 读写功能 我发现了以下信息:
From the link - Read-write capabilities I found information :
在抛出UnhandledAlertException之前,浏览器应如何处理未处理的警报.可能的值为"accept","dismiss"和"ignore".
What the browser should do with an unhandled alert before throwing out the UnhandledAlertException. Possible values are "accept", "dismiss" and "ignore".
Key : unexpectedAlertBehaviour
type : string ( "accept"/"dismiss"/"ignore")
您需要做的是:
require 'selenium-webdriver'
driver = Selenium::WebDriver.for :firefox
driver.get "https://www.google.com/"
ob = driver.capabilities
ob[:unexpectedAlertBehaviour] = "dismiss" # or "accept"/"ignore"
driver.capabilities
将为您提供
driver.capabilities
will give you Selenium::WebDriver::Remote::Capabilities
class's instance. Now if you want to set any custom capabilities, you need to call the method #[]=
on the instance you got from the call driver.capabilities
.
设置自定义选项后,您可以调用 #to_json
方法查看驱动程序设置的所有当前功能:
After setting the custom one you can call #to_json
method to see all the current capabilities set with your driver :
puts ob.to_json
# >> { "browserName":"firefox","version":"21.0","platform":"WINNT","javascriptEnabled"
# >> :true,"cssSelectorsEnabled":true,"takesScreenshot":true,"nativeEvents":true,"rot
# >> atable":false,"handlesAlerts":true,"webStorageEnabled":true,"applicationCacheEna
# >> bled":true,"databaseEnabled":true,"locationContextEnabled":true,"browserConnecti
# >> onEnabled":true,"acceptSslCerts":true,"unexpectedAlertBehaviour":"dismiss"}
If you want to verify if the custom one got set, as you want it to be, verify the same by calling the method #[]
:
puts ob[:unexpectedAlertBehaviour] # => dismiss
这篇关于Selenium Ruby绑定功能文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!