It wont work the way you have this expressed in your example. I would suggest you look read the cucumber book and pose this question there as it has nothing to do with watir. In Cucumber when you want to run a scenario several times (scenario outline you put the examples in the feature after it. If you got all the data before a scenario, then iterated over that during the scenario it would just be one scenario.
On Mon, Mar 24, 2014 at 6:55 AM, akshaya vivek <[email protected]>wrote: > Hi, > I want to iterate the given below feature file n times(it must execute > number of times i mentioned). Here i have got all the datas from the excel > and stored it in an array using that array im filling the credentials and > for each iteration it must take the value from the next row. > Can you please help me how to do it..... > > Thanks and Regards, > Akshaya > > > test.feature > -------------- > > Feature: Sample test > Scenario: Login page > > Given I am a user > When I enter my username > And I enter my password > And I Click submit button > Then It will navigate next page > > test.rb > --------- > > require "cucumber" > require "watir_webdriver" > require "win32ole" > require 'c:\Users\Desktop\test\testData.rb' > > Given /^I am a user$/ do > @browser=Watir::Browser.new:ie > @browser.goto("http://www.gmail.com") > end > > Testing=ruby.new > userName1=Array.new(5) > userName1=Testing.userName() > password1=Testing.password() > > > When /^I entered my username$/do > @browser.text_field(:id,"username").set(userName[i]) > end > > And /^I enter my password$/ > @browser.text_field(:id,"password").set(password[i]) > end > > And /^I Click submit button$/do > @browser.button(:id,"submit").click > end > > Then /^It will navigate next page$/ do > @browser.goto("https://www.google.com") #the required url should be given > > end > > > > testData.rb: > ------------ > Class ruby > > > def Excel() > X1=Win32OLE.new("Excel.Application") > @sht=X1.workbooks.open('c:\Users\Desktop\test\data.xls') > @[email protected](1) > @row=2 > end > > def userName() > Excel() > userName=Array.new(5) > i=0 > loop do > if(@wrksheet.Range("a#{@row}").value)!=nil then > > userName[i][email protected]("a#{@row}").value > @row+=1 > i+=1 > else > break > end > end > @sht.close > return userName > end > > > > > > > -- > -- > Before posting, please read http://watir.com/support. In short: search > before you ask, be nice. > > [email protected] > http://groups.google.com/group/watir-general > [email protected] > > --- > You received this message because you are subscribed to the Google Groups > "Watir General" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- -- Before posting, please read http://watir.com/support. In short: search before you ask, be nice. [email protected] http://groups.google.com/group/watir-general [email protected] --- You received this message because you are subscribed to the Google Groups "Watir General" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
