-1

私はRuby-Watirが初めてです..そして、Excelシートからの(無効なユーザーとパスワード、有効なユーザー名とパスワード)のような複数の値を持つ1つのアプリケーションのログイン機能をチェックしています。

reqire'watir-webdriver'
require 'win32ole'
require 'roo'

b = Watir::Browser.new

b.goto 'http://tech/mellingcarsweb/Admin/Login.aspx'

xl = WIN32OLE.new('excel.application')

wrkbook= xl.Workbooks.Open("C:\\Excel\\cars.xlsx")

wrksheet= wrkbook.Worksheets(1)

wrksheet.select

$username= wrksheet.Range("A1").Value

$password= wrksheet.Range("B1").Value

b.text_field(:id, "MainContent_txtUsername").set($username)


b.text_field(:id, "MainContent_txtPassword").set($password)


b.button(:id, "MainContent_btnLogin").click

b.alert.ok

$username1= wrksheet.Range("A2").Value

$password1= wrksheet.Range("B2").Value

b.text_field(:id, "MainContent_txtUsername").set($username1)


b.text_field(:id, "MainContent_txtPassword").set($password1)


b.button(:id, "MainContent_btnLogin").click

puts "Authorised Entry"

このコードは正常に動作しています。私のニーズは何ですか..ループステートメントを使用して、複数回実行する必要があります。

Excel でループ条件を使用する方法がわかりません。多くの例を見てきましたが、どれも明確ではありません。申し訳ありませんが理解できません。Excel ルビーでループ条件を使用する適切な方法を説明してください。

ありがとう

4

2 に答える 2

0

Googlefor ruby loops。これは良い紹介のように見えます:http ://www.tutorialspoint.com/ruby/ruby_loops.htm

于 2013-03-23T07:53:07.397 に答える