Watir自动测试应用(3):数据库连接篇

我们的项目没有考虑使用Watir直接访问数据库,但是另外一个项目使用到了,我就在网上找了一个解决方案,如果使用Sqlite就挺简单的如果使用SqlServer就用点麻烦了:

  1. 首先要下载DevKit 
  2. 安装DBI 使用gem install dbi
  3. 安装 dbd-odbc gem install dbd-odbc 
  4. 安装 dbi  gem install dbi 
  5. 安装 ruby-odbc gem install ruby-odbc 如果遇到以下情况:下载DevKit https://github.com/oneclick/rubyinstaller/wiki/development-kit

Fetching: ruby-odbc-0.99994.gem (100%) 
ERROR:  Error installing ruby-odbc: 
The 'ruby-odbc' native gem requires installed build tools. 
Please update your PATH to include build tools or download the DevKit 
from 'http://rubyinstaller.org/downloads' and follow the instructions 
at 'http://github.com/oneclick/rubyinstaller/wiki/Development-Kit' 

OK,可以使用ODBC连接你的SqlServer数据库了,在这里要注意的就是自己电脑要装相对应的ODBC类库哦。

因为这里说的自动测试没有相关数据库方面的,所以在这里不介绍相关数据库方面的测试,本系列文章只关于页面级测试内容。

原文地址:https://www.cnblogs.com/yangqianming/p/1954726.html