ActiveRecord是rails的框架,我们在selenium测试中肯定需要初始化数据或者清理数据库数据以保证各个测试之间的独立性,可以这样用ActiveRecord来初始化或清理数据库
ruby 代码
- require 'test/unit'
- require 'selenium'
- require 'active_record'
- ActiveRecord::Base.establish_connection(
- :adapter => "mysql",
- :host => "localhost",
- :username => "dcrm",
- :password => "dcrm",
- :database => "dcrm2_test"
- )
-
- class FunctionalTestCase < Test::Unit::TestCase
-
- @wait_default_time="30000"
-
- def setup
- initBrowser unless @selenium
- end
-
- def teardown
- logout
- clear_database
- closeBrowser
- end
-
- def logout
- @selenium.open "http://localhost:3000/logout"
- wait_default
- end
-
- def closeBrowser()
- @selenium.stop
- end
-
- def initBrowser
- @selenium = Selenium::SeleniumDriver.new("localhost", 4444, "*iexplore", "http://localhost:4444", 10000);
- @selenium.start
- end
-
- def wait_default
- @selenium.wait_for_page_to_load @wait_default_time
- end
-
- def test_logout
- logout
- @selenium.is_text_present("用户登录")
- end
-
- def clear_database
- connection = ActiveRecord::Base.connection
- connection.execute("DELETE from channels")
- ......
- end
-
- end
其中
ruby 代码
- require 'active_record'
- ActiveRecord::Base.establish_connection(
- :adapter => "mysql",
- :host => "localhost",
- :username => "dcrm",
- :password => "dcrm",
- :database => "dcrm2_development"
- )
建立了DB Connection
分享到:
- 2007-08-10 18:15
- 浏览 5106
- 评论(1)
- 论坛回复 / 浏览 (1 / 3377)
- 查看更多
相关推荐
python selenium 测试报告
《Selenium测试实践:基于电子商务平台》对开源自动化测试工具Selenium进行了详细介绍,帮助读者熟练掌握Selenium的使用方法。《Selenium测试实践:基于电子商务平台》将电子商务平台下的Selenium测试技巧通过具有代 ...
Selenium测试工具研究报告,一款适合软件测试的工具
Selenium是现在使用最为广泛的一款开源自动化测试工具,也是非商业支持的稳定性易用性最好的一款自动化测试工具...以下介绍的内容会通过和QTP在各方面的比较中进行,并针对简单的测试样例,对基本的使用进行简单说明。
selenium测试脚本编写详细说明大全
selenium+junit+TestNg 测试环境搭建
selenium-builder, 在浏览器中,创建 selenium 测试 selenium-生成器在浏览器中创建 selenium 测试。网站安装在 Firefox 服务器上邮件列表维护者) ( zarkonnen 电子邮件贡献者David Stark ( zarkonnen ))
selenium测试工具搭建,web测试详细讲解
使用 Selenium 和在浏览器中运行测试还有很多其他好处。下面是主要的两大好处: • 通过编写模仿用户操作的 Selenium 测试脚本,可以从终端用户的角度来测试应用程序。 • 通过在不同浏览器中运行测试,更容易发现...
闲,所以有幸接触到 QTP、Selenium 等自动化测试工具,由于当时水平有限,学习也只停留在录制与回放的水 平上。再次学习 Selenium 是时隔一年之后,笔者有幸跳槽到一家互联网公司继续做 web 软件测试,发现项目适 合...
selenium测试所需的jar包
Selenium是ThoughtWorks公司开发的一套基于WEB应用的测试工具,直接运行在浏览器中,模拟用户的操作,主要包括三个部分selenium-IDE,selenium-core,selenium-rc 。它可以被用于单元测试,回归测试,冒烟测试,集成...
selenium IDE使用手册,写的很好,请大家参考,多多学习
Selenium是一个主要用于Web应用程序自动化测试的工具集合,在行业内已经得到广泛的应用。本书介绍了如何用Python语言调用Selenium WebDriver接口进行自动化测试。主要内容为:基于Python 的 Selenium WebDriver 入门...
Selenium 官方中文文档
综述Web系统功能测试工—selenium的安装使用及问题.综述Web系统功能测试工—selenium的安装使用及问题.综述Web系统功能测试工—selenium的安装使用及问题.
Selenium自动录制脚本,java版本;所需要的jar包。包含(Selenium-client.jar,selenium-server.jar;junit.jar)
基于Selenium 2的自动化测试 完整版 selenium 自动化 测试
使用selenium进行软件测试,里面有很多常用的方法。
Selenium测试直接运行在浏览器中,就像真正的用户在操作一样。支持的浏览器包括IE(7, 8, 9, 10, 11),Mozilla Firefox,Safari,Google Chrome,Opera等。selenium 是一套完整的web应用程序测试系统,包含了测试的...