[Wtr-general] Data driven tests
Balakrishna
balakrishna.venkatappa at ionidea.com
Mon Jan 8 13:42:26 EST 2007
Chris ,
You have understood it correct. The result of each printf are shown only at
the End. I'll try to explain what I'm trying to do
drv = Driver.new
drv.name = 'Driver1'
drv.attrs['driver'] = 'Microsoft Access Driver (*.mdb)'
drv.attrs['dbq'] = 'C:\dl_alpha.mdb'
dbh = Database.new.drvconnect(drv)
sth = dbh.run("Select * from tbl_dl")
#sth.each do |row| # Start processing each row.
var_TNOrder = row[0] # Assign the value to a variable
which is to be used later.
var_LEC = row[1]
var_TN = row[2]
#printf " tempcounter: %d",$tempcounter
#printf "Entered while loop, TNORder: %s",$var_TNOrder
ie.link(:index,37).click # navigate the application
sleep(2)
ie2 = Watir::IE.attach(:title,/LSOG 9/) # attach a popup
window
ie2.frame("mainFrame").text_field(:name,"LSRForm__ADM__PON").set(var_TNOrder
) # Set the value of the variable read from database
ie2.frame("mainFrame").text_field(:name,"LSRForm__ADM__LOCQTY").set("1")
ie2.frame("mainFrame").select_list(:name,"EUForm__EULOC__STATE").select("New
York")
ie2.frame("mainFrame").select_list(:name,"LSRForm__ADM__REQTYP").select("Dir
ectory Listing Firm Order")
ie2.frame("mainFrame").select_list(:name,"LSRForm__ADM__AGAUTH").select("Yes
")
ie2.frame("mainFrame").select_list(:name,"null__OC").select("Order Creator
Wizard")
ie2.frame("mainFrame").image(:index,10).click # Goto Next
Screen . But error because the var_TNORder was not set as it's not
assigned. The variable will not be assigned until the end is executed.
end
Hope u understood the problem I'm facing. How do I get the value into the
variable while still in the loop ?
Thanks
Balu
ie.link(:index,37).click
sleep(2)
ie2 = Watir::IE.attach(:title,/LSOG 9/)
printf "Variable value: %s, Variable value: %s\n",var_TNOrder,var_LEC
ie2.frame("mainFrame").text_field(:name,"LSRForm__ADM__PON").set(var_TNOrder
.to_s)
ie2.frame("mainFrame").text_field(:name,"LSRForm__ADM__LOCQTY").set("1")
ie2.frame("mainFrame").select_list(:name,"EUForm__EULOC__STATE").select("New
York")
ie2.frame("mainFrame").select_list(:name,"LSRForm__ADM__REQTYP").select("Dir
ectory Listing Firm Order")
ie2.frame("mainFrame").select_list(:name,"LSRForm__ADM__AGAUTH").select("Yes
")
ie2.frame("mainFrame").select_list(:name,"null__OC").select("Order Creator
Wizard")
ie2.frame("mainFrame").image(:index,10).click
From: wtr-general-bounces at rubyforge.org
[mailto:wtr-general-bounces at rubyforge.org] On Behalf Of Chris McMahon
Sent: Monday, January 08, 2007 1:04 PM
To: wtr-general at rubyforge.org
Subject: Re: [Wtr-general] Data driven tests
On 1/8/07, Balakrishna <balakrishna.venkatappa at ionidea.com> wrote:
Hello Chris,
Thanks for the response. I will try this solution. If you have an example of
the same ,plz share it to me.
Any methods to find the size of array .
irb(main):001:0> ary = [5,10,15,20]
=> [5, 10, 15, 20]
irb(main):002:0> ary.length
=> 4
irb(main):003:0>
Also my question regarding the while loop does not execute the statements
until End is reached. How do I overcome this ?
There are several odd things in your code. For one, I wouldn't use global
variables, they'll cause you trouble eventually. For another, use "puts"
instead of "printf". Your "while" loop should fetch each row, but your
commented-out line " sth.each" is a lot more Ruby-like way to do it.
I assume by "not execute" you mean that the results of each printf are shown
only at the end? That's probably just an artifact of your output mode. Are
you sure that your execution mode doesn't just flush the buffer at the end
of the run?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/wtr-general/attachments/20070108/1a3b5b41/attachment.html
More information about the Wtr-general
mailing list