Thank you everyone, i figured out the answer for that issue. I used regular expressions with iteration and it did work perfectly.
*Browser=$b.table(:id, /Grid/) $Browser.rows.each do |row| if (row[4].text =~ /Acct(.*) /) puts "Dropdown selected" row[5].select_list(:id, /dispositionList/).select "Value from dropdown" end end * On Fri, May 20, 2011 at 2:38 PM, Ashok Tulachan <tulachanas...@gmail.com>wrote: > Thank you very much Chuck, for your response. I will take your advice and > follow it graciously. > > However, When i tried to put your code as given below., i got the following > error message. > > browser.table(:id, /grid/).rows.each do |row| > row[5].select("Value from the dropdown") if row[4].text.exists? > end > > Error > > *C:/Watir Scripts/Project/Debit.rb:58:in `block in report': undefined > method `exists?' for "Account Number":String (NoMethodError) > from > C:/Ruby192/lib/ruby/gems/1.9.1/gems/watir-webdriver-0.2.3/lib/watir-webdriver/element_collection.rb:21:in > `each' > from > C:/Ruby192/lib/ruby/gems/1.9.1/gems/watir-webdriver-0.2.3/lib/watir-webdriver/element_collection.rb:21:in > `each' > from C:/Watir Scripts/Project/Debit.rb:57:in `report' > from driver.rb:36:in `run' > from driver.rb:42:in `<main>'* > ** > So i tried to tweak the script and wrote as below. > > browser.table(:id, /Grid/).rows.each do |row| > if row[4].text!= "" > > row[5].select("Value from the dropdown") > end > > Then i got the following error message. > *C:/Ruby192/lib/ruby/gems/1.9.1/gems/watir-webdriver-0.2.3/lib/watir-webdriver/container.rb:36:in > `extract_selector': expected Hash or (:how, 'what'), got ["Exclude: > Duplicate Account"] (ArgumentError) > from > C:/Ruby192/lib/ruby/gems/1.9.1/gems/watir-webdriver-0.2.3/lib/watir-webdriver/elements/generated.rb:2163:in > `select' > from C:/Watir Scripts/Project/Credit.rb:53:in `block in liability_report' > from > C:/Ruby192/lib/ruby/gems/1.9.1/gems/watir-webdriver-0.2.3/lib/watir-webdriver/element_collection.rb:21:in > `each' > from > C:/Ruby192/lib/ruby/gems/1.9.1/gems/watir-webdriver-0.2.3/lib/watir-webdriver/element_collection.rb:21:in > `each' > from C:/Watir Scripts/Project/Credit.rb:51:in `liability_report' > from driver.rb:36:in `run' > from driver.rb:42:in `<main>'* > ** > So i think we need to use (how, what) expressions, can you help me how to > use those expressions in 'each' command? > > Thanks > * * > Ashok Tulachan > > On Fri, May 20, 2011 at 11:43 AM, Chuck van der Linden <sqa...@gmail.com > > wrote: > >> Try something along these lines. >> >> browser.table(:id, /grid/).rows.each do |row| >> row[5].select("Value from the dropdown") if row[4].text.exists? >> end >> >> and for the sake of anyone having to read your code (including >> yourself) start using variable names that mean something instead of c >> or d (which reminds me of code I wrote back in 1974 in early versions >> of basic) >> >> >> On May 20, 7:11 am, Ashok Tulachan <tulachanas...@gmail.com> wrote: >> > No answers yet :(... >> > >> > I am able to select the dropdown for the respective row but i'm not just >> > able to iterate it. >> > >> > Table name: $b.table(:id, /grid/) >> > 1 2 3 4 5 2 100 100 3 100 100 text dropdown 4 100 100 5 >> 100 >> > 100 text dropdown n 100 100 >> > >> > *i=0* >> > *c=$b.table(:id, /grid/)[2][4]* >> > *d=$b.table(:id, /grid/)[2][5]* >> > >> > I can select the dropdown in column 5 if i use the following code >> > >> > while i>$b.table(:id, /grid/).row.length >> > >> > if c.text.exist?== true >> > >> > $d.select "Value from the dropdown" >> > >> > else >> > >> > exit >> > >> > end >> > >> > However since the row is infinite and n, i am not able to iterate, any >> help >> > would be highly appreciated. >> > >> > Thanks, >> > >> > On Thu, May 19, 2011 at 9:51 AM, Ashok Tulachan < >> tulachanas...@gmail.com>wrote: >> > >> > >> > >> > >> > >> > >> > >> > >> > >> > > Hello everyone, >> > >> > > I am trying to do 'For' loop for the table but i am having a hard time >> as >> > > it involves iteration. >> > >> > > *Scenario description:* >> > >> > > I have a table where there are 'n' number of rows but fixed number(5) >> of >> > > columns as shown below. I need to select the dropdown in column 5 if >> the >> > > text presents in Column 4. >> > > Just to make clear the rows are infinite and can be any no. >> > > Table name: $b.table(:id, /grid/) >> > > 1 2 3 4 5 2 100 100 3 100 100 text dropdown 4 100 100 5 >> 100 >> > > 100 text dropdown n 100 100 >> > >> > > Here's what i come up with. >> > >> > > *i=0* >> > > *c=$b.table(:id, /grid/)[i][4]* >> > > *d=$b.table(:id, /grid/)[i][5]* >> > > ** >> > > ** >> > > *while i<$b.table(:id, /grid/).row.length* >> > > * if c.text.exist?==true* >> > > *$d.select_list.select "dropdown"* >> > > *else* >> > > *puts "No value present"* >> > > *end* >> > > *end* >> > >> > > i need to use for loop for iteration on this code. Any help from ruby >> > > expert will be appreciated. >> > >> > > Regards, >> > >> > > Ashok Tulachan >> > >> > -- >> > Regards, >> > >> > Ashok Tulachan >> >> -- >> Before posting, please read http://watir.com/support. In short: search >> before you ask, be nice. >> >> watir-general@googlegroups.com >> http://groups.google.com/group/watir-general >> watir-general+unsubscr...@googlegroups.com >> > > > > -- > Regards, > > Ashok Tulachan > > > -- Regards, Ashok Tulachan -- Before posting, please read http://watir.com/support. In short: search before you ask, be nice. watir-general@googlegroups.com http://groups.google.com/group/watir-general watir-general+unsubscr...@googlegroups.com