我正在尝试从excel文件中读取数据以自动化网站,使用RubyMine作为我的编辑器和watir-webdriver来自动化我的测试。执行此操作时,我在rubyMine编辑器中出现错误"无法加载此类文件 - win32_ole(LoadError)"。
require 'watir'
require 'rubygems'
require 'roo'
require 'win32_ole'
browser = Watir::Browser.new :firefox
Given(/^Iam on guru99 site page$/) do
browser.goto "http://demo.guru99.com/v4/index.php"
xl = WIN32OLE.new('Excel.Application')
workbook = xl.Workbooks.open("C:\\Users\TekUser\Desktop.practiceExcel.xlsx")
wrksheet= workbook.Worksheets(1)
wrksheet.Select
username1= wrksheet.Range("a1").Value
password1= wrksheet.Range("b1").Value
end
When(/^I enter Username and password in the respected field$/) do
browser.text_field(:name, "uid").set(username1)
browser.text_field(:name,"password").set(password1)
end
Then(/^I click on login button$/) do
browser.button(:name,"btnLogin").click
end
答案 0 :(得分:0)
库名称没有下划线。它应该是:
require 'win32ole'