模拟浏览器,人工测试 http://hlee.iteye.com/blog/768459
1. 文本框填充:
直接填充 :
fill_in("#{@user.id}_name",:with=>"jdo")
通过节点赋值 :
find(:xpath,"//html/body/div[2]/div[2]/div/div/div[3]").set("123456")
2. 点击操作超链接
点击元素: 通过Id 找到名为tab_user 的元素点击
find(:id,"tab_user").click
直接点击 'edit' 的超链接
find_link("edit").click
3. 点击按钮
find_button('Submit').click
click_button('submit')
4. test confirm dialog 确认对话框
page.evaluate_script('window.confirm = function() { return true; }')
page.click('Remove')
5. 判断确认对话框返回值
When /^I (accept|dismiss) the "([^"]*)" alert$/ do |action, text|
alert = page.driver.browser.switch_to.alert
alert.text.should eq(text)
alert.send(action)
end
it "更新用户密码--成功" do
visit "/orgunits"
find(:id,"tab_user").click
find_link("chgpwd").click
page.should have_content("为用户“#{@user.login}”设置新的密码")
find(:xpath,"//html/body/div[2]/div[2]/div/div/div[2]/input").set("123456")
find(:xpath,"//html/body/div[2]/div[2]/div/div/div[3]/input").set("123456")
find(:xpath, '//html/body/div[2]/div[2]/div[2]/div/a').click
sleep Capybara.default_wait_time 异步休眠, 等待返回结果
alert =page.driver.browser.switch_to.alert
assert alert.text.should == "更新密码成功"
end
6. 判断内容
判断当前路径:
page.current_path.should==url
page.should have_content("表单显示名")
page.should_not have_xpath('link')
page.should_not have_content("Show")
7.
page.select 'entos', :from => 'flex_table_orgunit_id'
page.choose("flex_table_for_workflow_1")
8.
page.evaluate_script('window.confirm = function() { return true; }')
9.上传文件输入
Dir["/home/jidong/Downloads/财务部/2.xsn"].each { |f|
page.attach_file 'file' , f
page.click_button "Upload"
page.should have_content("表单名")
page.click_button "Submit"
page.should have_content("视图")
}
10. cannot fill in, no text field, text area or password field with id, name, or label
11. 判断该元素是否存在通过xpath
page.should have_no_xpath("//html/body/div/div[4]/div/table/tbody/tr/td[2]/div/div/div/div[2]/div[4]/div/div/div[2]/div[2]/div/div")
page.find(:xpath,"//html/body/div/div[4]/div/table/tbody/tr/td[2]/div/div/div/div[2]/div/div/div/div/div[2]/div/div").text.should_not=="#{@orgunit.name}"
分享到:
相关推荐
rspec-mocks 是一个 rspec 的 test-double 框架,支持 method stubs, fakes 和生成 test-doubls 和类似真的对象的预期消息。 标签:rspec
自述文件 该自述文件通常会记录启动和运行应用程序所需的所有步骤。 您可能要讲的内容: Ruby版本 系统依赖 配置 数据库创建 数据库初始化 如何运行测试套件 服务(作业队列,缓存服务器,搜索引擎等) ...
Instant RSpec Test-Driven Development How-to – Free Pdf Book
RSpec supports Test Driven Development in Ruby through the BDD lens, keeping your focus on design and documentation while also supporting thorough testing and quick fault isolation. Cucumber, RSpec's...
安装gem install rspec # for rspec-core, rspec-expectations, rspec-mocksgem install rspec-mocks # for rspec-mocks only想要与main分支对抗吗? 您还需要包括相关的RSpec存储库。 将以下内容添加到您的Gemfile ...
Rails test described by RSpec
Fobless 键盘安全建筑物的自动访问要求带有电话号码的Redis安装使用电话号码设置输入 twilio 电话号码的请求网址运行bundle install 部署应用设置环境变量测试运行测试套件rspec test.rb配置必需的环境变量 ...
调整Plist到Junit ... $ rspec test/tuneup_plist_to_junit_utils_spec.rb 用法 要使用,只需使用 $ tuneup_plist_to_junit_parser Usage: TuneUpPlistToJunit.rb [options] Specific options: -i, --input FIL
i18n任务 i18n任务可帮助您查找和管理缺失和未使用的... 复制rspec test作为套件的一部分来测试缺失和未使用的翻译(可选): $ cp $( i18n-tasks gem-path ) /templates/rspec/i18n_spec.rb spec/ 或用于最小测试
db-query-matchers, 用于数据库查询的RSpec匹配器 db-query-matchers 用于数据库查询的RSpec匹配器。安装在你的应用程序中添加这一行,最好在你的test 组中:gem 'db-query-matchers'然后执行:bundle
添加rspec-rails ,以两个:development和:test组的应用程式中Gemfile : # Run against the latest stable releasegroup :development , :test do gem 'rspec-rails' , '~> 4.0.2'end# Or, run
将此添加到您的Gemfile中: gem 'rspec_api_helpers'然后执行: $ bundle或将其自己安装为: $ gem install rspec_api_helpers将其包含在您的spec_helper中 RSpec . configure do | config | # ... config . ...
旧的自述文件Testbot是一个测试分发工具,可与Rails,RSpec,RSpec2,Test :: Unit和Cucumber一起使用。 基本思想是让testbot将测试的负载分散到多台计算机上,以使测试运行更快。 在11台机器(25个内核)上使用...
手机编程20210311设置要求- Ruby: 2.7.2安装$ bundle install用法运行测试$ bundle exec rspec test.rb
flavor-gem generate rspec # adds rspec test flavor flavor-gem generate minitest # adds rails test macro flavor flavor-gem generate thor # adds thor flavor to make executable in bin to use it flavor-...
Your Ruby on Rails ...This new edition has been updated to Rails 5.2 and RSpec 3.7 and contains full coverage of new Rails features, including system tests and the Webpack-based JavaScript setup.
为Visual Studio Code(vscode)运行RSpec扩展 该扩展提供了基本命令,用于在内置vscode终端中运行规范文件。 特征 仅使用cmd + 1运行当前行(RSpec:RSpec上的运行行) 使用cmd + alt + l搜索并运行基于Spec的当前...
RSpec JUnit格式器 CI可以读取的 2和3结果。 , , , ,也许还有更多。用法安装gem: gem install rspec_junit_formatter 用它: ... group :test do gem "rspec" gem "rspec_junit_formatter"end 将与上述命令相同
欢迎@ packrat386作为rspec-sidekiq新维护者! Sidekiq的RSpec 通过匹配器和帮助器的集合对Sidekiq作业进行... 因此,仅在要求这种行为的环境(例如test组)中包括gem "rspec-sidekiq" 。 配置 如果要修改默认行为
group :test do gem 'mongoid-rspec' end 兼容性 该宝石与Mongoid 3、4、5、6和7兼容。 组态 滑轨 添加到您的rails_helper.rb文件 require 'mongoid-rspec' RSpec . configure do | config | config . include ...