Hi Chitta, I'm not quite sure what you're trying to do here, but it looks like your checkcondition method is in the test case. And you're calling, based on this code, your checkcondition method inside itself. It's a bit hard to even know where to begin with this. Some more context might help, or maybe someone else on the list wants to do more parsing of the code and work through it.
There's an excel interface class which I haven't used, but might help simplify some of what you're doing here: http://wiki.openqa.org/display/WTR/Excel+interface+class Quick guesswork and of dubious value... class TC_1 < Test::Unit::TestCase def test_sign_up # figure out what values you need here to call this method with all it's parameters which are quite a few checkcondition(checktext, cell1, cell2, messagepass, messagefail, passcheck, failcheck) end end checkcondition being a method in another class or module, which it may be already. -Charley On 3/20/07, chitta <[EMAIL PROTECTED]> wrote:
Hi All, Please Help me how can i declare a method here.. # Test to automate Sign-up # Author : Chitta Ranjan # Verson : 0.2 require 'watir' require 'test/unit' #Test Suite for Sign up verifications class TC_1 < Test::Unit::TestCase def test_sign_up def checkcondition(checktext, cell1, cell2, messagepass, messagefail, passcheck, failcheck) if ie.contains_text("#{checktext}") p 'messagepass' excel.Range("#{cell1}")['Value'] = "#{passcheck}"; excel.Range("#{cell2}")['Value'] = "#{pass}"; else p 'messagefail' excel.Range("#{cell1}")['Value'] = "#{failcheck}"; excel.Range("#{cell2}")['Value'] = "#{fail}"; end require 'win32ole' excel = WIN32OLE.new("excel.application") # Workbook holding the test data and test case workbook = excel.Workbooks.Open('C:\SetupData.xls') # Refernce to Test Data in the worksheet worksheet = workbook.Worksheets('Test Data') #Variable for handling null nullvariable = worksheet.Range('b1')['Value'] # First Name firstname = worksheet.Range('b2')['Value'] # Last Name lastname = worksheet.Range('b3')['Value'] # Correct Email Address email1 = worksheet.Range('b4')['Value'] #Invalid Email Address email2 = worksheet.Range('c4')['Value'] # Correct Password password1 = worksheet.Range('b5')['Value'] # Incorrect Password- invalid length password2 = worksheet.Range('c5')['Value'] # Incorrect Password - invalid length password3 = worksheet.Range('d5')['Value'] # Incorrect Password - invalid length password4 = worksheet.Range('e5')['Value'] # Password Reminder - Correct passwordreminder1 = worksheet.Range('b6')['Value'] # Password Reminder - Incorrect passwordreminder2 = worksheet.Range('c6')['Value'] # Answer to password reminder answer = worksheet.Range("B#{1 + 6}")['Text'].strip.to_s # Contact Phone number contactphonenumber1 = worksheet.Range("B#{1 + 7}")['Text'].strip.to_s # Invalid Contact Phone Number - Invalid length contactphonenumber2 = worksheet.Range("C#{1 + 7}")['Text'].strip.to_s # Invalid Contact Phone Number - Invalid length contactphonenumber3 = worksheet.Range('d8')['Value'] # Internet Provider internetprovider = worksheet.Range('b9')['Value'] # Street Number streetno = worksheet.Range("B#{1 + 9}")['Text'].strip.to_s # Street Name streetname = worksheet.Range('b11')['Value'] # City city = worksheet.Range('b12')['Value'] # Valid State state1 = worksheet.Range('b13')['Value'] # Invalid State - No Selection state2 = worksheet.Range('c13')['Value'] # Zip Code zipcode1 = worksheet.Range("B#{1 + 13}")['Text'].strip.to_s # Invalid Zip Code zipcode2 = worksheet.Range("C#{1 + 13}")['Text'].strip.to_s # Invalid Zip Code zipcode3 = worksheet.Range("D#{1 + 13}")['Text'].strip.to_s # Invalid Zip Code zipcode4 = worksheet.Range("E#{1 + 13}")['Text'].strip.to_s #valid NPA npa = worksheet.Range("B#{1 + 14}")['Text'].strip.to_s #Valid NXX nxx = worksheet.Range("B#{1 + 15}")['Text'].strip.to_s #Valid Creditcard Name cardname = worksheet.Range('b17')['Value'] #Credit Card Type cardtype1 = worksheet.Range('b18')['Value'] #Credit Card Type cardtype2 = worksheet.Range('c18')['Value'] #Invalid Credit Card Number creditcardnumber = worksheet.Range('b19')['Value'] #Credit Card security code securitycode1 = worksheet.Range("B#{1 + 19}")['Text'].strip.to_s #invalid Security code securitycode2 = worksheet.Range("C#{1 + 19}")['Text'].strip.to_s #invalid Security code securitycode3 = worksheet.Range("D#{1 + 19}")['Text'].strip.to_s #invalid Security code securitycode4 = worksheet.Range("E#{1 + 19}")['Text'].strip.to_s #Credit Card exp. Month expirationmonth = worksheet.Range("B#{1 + 20}")['Text'].strip.to_s #Credit Card exp. year expirationyear1 = worksheet.Range("B#{1 + 21}")['Text'].strip.to_s #Credit Card exp. year invalid expirationyear2 = worksheet.Range("C#{1 + 21}")['Text'].strip.to_s #Test result If Passd pass = worksheet.Range('b24')['Value'] #Test result If Faild fail = worksheet.Range('b25')['Value'] #Sign-up URL url = worksheet.Range('b23')['Value'] #get hold of the Second worksheet worksheet = workbook.Worksheets('Test Case') #call the testcases testcaseno = worksheet.Range('a1')['Value']#call the testcases description = worksheet.Range('b1')['Value'] expectedresult = worksheet.Range('c1')['Value'] actualresult = worksheet.Range('d1')['Value'] passfail = worksheet.Range('f1')['Value'] #Call the testcase no, test description, expected result from the testcase sheet urlverificationno = worksheet.Range('a3')['Value'] urlverificationdescription = worksheet.Range('b3')['Value'] urlverificationexpectedresult = worksheet.Range('c3')['Value'] urlverificationactualpass = worksheet.Range('d3')['Value'] urlverificationactualfail = worksheet.Range('e3')['Value'] #write the test result in the BOOK1 excel['Visible'] = TRUE; workbook = excel.Workbooks.Add(); excel.Range("a1")['Value'] = testcaseno; excel.Range("b1")['Value'] = description; excel.Range("c1")['Value'] = expectedresult; excel.Range("d1")['Value'] = actualresult; excel.Range("e1")['Value'] = passfail; puts (urlverificationno) puts (urlverificationdescription) ie = Watir::IE.new test_site = url ie.goto(test_site) excel.Range("a3")['Value'] = urlverificationno; excel.Range("b3")['Value'] = urlverificationdescription; excel.Range("c3")['Value'] = urlverificationexpectedresult; checkcondition("Choose Plan", "d3", "e3", "Choose plan page is opening pass", "Choose plan page is not opening fail", "urlverificationactualpass", "urlverificationactualfail") ie.close #Verifies that the sign_up page opens if the user hits the URL -" http://192.168.4.169/sign_up/beginSignup.do" end end end _______________________________________________ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
_______________________________________________ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general