- 浏览: 2081888 次
- 性别:
- 来自: NYC
-
文章分类
- 全部博客 (628)
- Linux (53)
- RubyOnRails (294)
- HTML (8)
- 手册指南 (5)
- Mysql (14)
- PHP (3)
- Rails 汇总 (13)
- 读书 (22)
- plugin 插件介绍与应用 (12)
- Flex (2)
- Ruby技巧 (7)
- Gem包介绍 (1)
- javascript Jquery ext prototype (21)
- IT生活 (6)
- 小工具 (4)
- PHP 部署 drupal (1)
- javascript Jquery sort plugin 插件 (2)
- iphone siri ios (1)
- Ruby On Rails (106)
- 编程概念 (1)
- Unit Test (4)
- Ruby 1.9 (24)
- rake (1)
- Postgresql (6)
- ruby (5)
- respond_to? (1)
- method_missing (1)
- git (8)
- Rspec (1)
- ios (1)
- jquery (1)
- Sinatra (1)
最新评论
-
dadadada2x:
user模型里加上 protected def email ...
流行的权限管理 gem devise的定制 -
Sev7en_jun:
shrekting 写道var pattern = /^(0| ...
强悍的ip格式 正则表达式验证 -
jiasanshou:
好文章!!!
RPM包rpmbuild SPEC文件深度说明 -
寻得乐中乐:
link_to其实就是个a标签,使用css控制,添加一个参数: ...
Rails在link_to中加参数 -
aiafei0001:
完全看不懂,不知所然.能表达清楚一点?
"$ is not defined" 的问题怎么办
一些资源
- http://gitrdoc.com/brynary/webrat
- http://groups.google.com/group/webrat
- http://webrat.lighthouseapp.com/
- http://github.com/brynary/webrat
关于触发link
可以通过文本 title属性,和id属性]
webrat的源码定义
而表单的输入框,可以通过id name属性或者label的inner text属性定位,例子如下:
输入框包括text fields, password fields和text areas
对于隐藏字段的设定
下拉菜单可以通过文本,name属性,label text属性来选中
操作多选框
操作单选框
判定页面是否有文字
在范围内的界定,老猪上文已经提到selenium不支持
- http://gitrdoc.com/brynary/webrat
- http://groups.google.com/group/webrat
- http://webrat.lighthouseapp.com/
- http://github.com/brynary/webrat
关于触发link
可以通过文本 title属性,和id属性]
<a href="/signup" title="Sign up" id="signup_link">Click here to join!</a>click_link "Click here to join!" # substring text
click_link /join/i # regexp text click_link "Sign up" # substring title click_link /sign.*up/i # regexp title click_link /signup.*link/i # regexp id click_link "signup_link" # exact id
webrat的源码定义
def click_link(text_or_title_or_id, options = {}) find_link(text_or_title_or_id).click(options) end
而表单的输入框,可以通过id name属性或者label的inner text属性定位,例子如下:
输入框包括text fields, password fields和text areas
#<label for="user[email]">Enter your Email</label><input type="text" name="user[email]" id="user_name"> fill_in "user_email", :with => "good@example" # exact id fill_in /user.*email/, :with => "good@example" # regexp id fill_in "user[email]", :with => "good@example" # substring name fill_in /user[.*mail.*]/, :with => "good@example" # substring name fill_in "Email", :with => "good@example.com" # substring label text fill_in /enter your email/i, :with => "good@example.com" # regexp label text
对于隐藏字段的设定
# Hidden fields can be set set_hidden_field 'user[l337_hax0r]', :to => 'true'
下拉菜单可以通过文本,name属性,label text属性来选中
# Select options can be 'selected' by inner text (an exact String or a Regexp to match). It can optionally be selected from a particular select field, using the usual id, name, or label text. select "Free account" select "Free account", :from => "Account Types" select "Free account", :from => "user[account_type]" select "Free account", :from => "user_account_type"
操作多选框
# Check boxes can be 'checked' and 'unchecked' check 'Remember me' uncheck 'Remember me'
操作单选框
# Radio buttons can be choosen, using the usual label text, name, or id. choose "Yes" click_button "Register"
# check for text in the body of html tags # can be a string or regexp assert_contain("BURNINATOR") assert_contain(/trogdor/i) assert_not_contain("peasants") # check for a css3 selector assert_have_selector 'div.pagination' assert_have_no_selector 'form input#name'
判定页面是否有文字
# check for text in the body of html tags # can be a string or regexp # Matchers are verbs used with auxillary verbs should, should_not, etc. response.should contain("BURNINATOR") response.should contain(/trogdor/i) response.should_not contain("peasants") # check for a css3 selector response.should have_selector('div.pagination') response.should_not have_selector('form input#name')
在范围内的界定,老猪上文已经提到selenium不支持
# selectors syntax is defined here: http://www.w3.org/TR/css3-selectors/ within 'div.pagination' do |scope| scope.click_link "1" end within '.shows' do |scope| scope.should contain("NFL") # unfortunately, assertions don't support this currently end within 'form[name="search"] select[name="type"]' do |scope| scope.should have_selector 'option[value="blah"]' scope.should have_selector 'option[value="gah"]' scope.should have_selector 'option[value="eep"]' scope.should have_selector 'input:only-of-type' scope.should have_selector 'input[name="query"]' scope.should have_selector 'input[type="text"]' end
发表评论
-
Destroying a Postgres DB on Heroku
2013-04-24 10:58 946heroku pg:reset DATABASE -
VIM ctags setup ack
2012-04-17 22:13 3265reference ctags --extra=+f --e ... -
alias_method_chain方法在3.1以后的替代使用方式
2012-02-04 02:14 3310alias_method_chain() 是rails里的一个 ... -
一些快速解决的问题
2012-01-19 12:35 1479问题如下: 引用Could not open library ... -
API service 安全问题
2011-12-04 08:47 1393这是一个长期关注的课题 rest api Service的 ... -
Module方法调用好不好
2011-11-20 01:58 1364以前说,用module给class加singleton方法,和 ... -
一个ajax和rails交互的例子
2011-11-19 01:53 1914首先,这里用了一个,query信息解析的包,如下 https: ... -
Rails 返回hash给javascript
2011-11-19 01:43 2282这是一个特别的,不太正统的需求, 因为,大部分时候,ajax的 ... -
关于Rubymine
2011-11-18 23:21 2279开个帖子收集有关使用上的问题 前一段时间,看到半价就买了。想 ... -
ruby中和javascript中,动态方法的创建
2011-11-18 21:01 1252class Klass def hello(*args) ... -
textmate快捷键 汇总
2011-11-16 07:20 8159TextMate 列编辑模式 按住 Alt 键,用鼠标选择要 ... -
Ruby面试系列六,面试继续面试
2011-11-15 05:55 2036刚才受到打击了,充分报漏了自己基础不扎实,不肯向虎炮等兄弟学习 ... -
说说sharding
2011-11-13 00:53 1511这个东西一面试就有人 ... -
rails面试碎碎念
2011-11-12 23:51 1956面试继续面试 又有问ru ... -
最通常的git push reject 和non-fast forward是因为
2011-11-12 23:29 17248git push To git@github.com:use ... -
Rails 自身的many to many关系 self has_many
2011-11-12 01:43 2748简单点的 #注意外键在person上people: id ... -
Rails 3下的 in place editor edit in place
2011-11-12 01:20 956第一个版本 http://code.google.com/p ... -
Heroku 的诡异问题集合
2011-11-11 07:22 1704开个Post记录,在用heroku过程中的一些诡异问题和要注意 ... -
SCSS 和 SASS 和 HAML 和CoffeeScript
2011-11-07 07:52 12971Asset Pipeline 提供了内建 ... -
Invalid gemspec because of the date format in specification
2011-11-07 02:14 2138又是这个date format的错误。 上次出错忘了,记录下 ...
评论
acceptance test