Hi,

my code is as...


####requires

require 'watir'
#require 'autoit'

require 'test/unit'
require 'test/unit/ui/console/testrunner'
require 'test/unit/assertions'
#require 'watir/setFileDialog'
#require 'popups_test'
#require 'enabled_popup'


#logger requires
require 'example_logger1'
require 'workbookfunction'

#java_pophadler requires
require 'WindowHelper'
require 'win32ole'
#require 'javapopup'
#require 'winClickers'




####includes
include Watir


class TC_PSC_userlogin < Test::Unit::TestCase

 def startClicker( button , waitTime = 3)
w = WinClicker.new
longName = $ie.dir.gsub("/" , "\\" )
shortName = w.getShortFileName(longName)

c = "start ruby #{shortName}\\watir\\clickJSDialog.rb #{button} #{waitTime}
"
puts "Starting #{c}"
w.winsystem(c)
w=nil
###end of function StartClicker
end

 def text(wait_seconds = 2)
            sleep 0.3
           autoit = WIN32OLE.new("AutoItX3.Control")
           autoit.WinWait("Microsoft Internet Explorer", nil, wait_seconds)
if wait_seconds
           s = autoit.WinGetText("Microsoft Internet Explorer")
           file = File.open("c:\\test.txt", "w")           # DONT MAKE YOUR
VARIABLES GLOBAL UNNECESSARILY
           file.puts(s.to_s)
           puts s
           file.close
           #s unless s == "1"            # NOT SURE WHY YOU ARE DOING THIS
end

  def start
  #open the IE browser
   $ie = IE.new

   #create a logger
   filePrefix = "logger"
   $logger = LoggerFactory.start_xml_logger(filePrefix)
   $ie.set_logger($logger)

   ##Excel file functions
   $lgn=Excel_file.new #making object of workbookfunction
   $wrk_sht=$lgn.ExcelOpen("c:\\PSC\\PSCuserlogin.xls")

   ##java popup hadling
   #$pop=Jave_PopUps.new ##making object of javapopup
   #$oPopup    = Watir::autoit
 end








 def test_PSCLogin


 #call start method...
 start #fires up the IE browser and a logger object

 #variables-URL
  test_site = 'https://www.philipnow.com/envcss/'
 $logger.log("## PSCUser_Login_Logoff_4")
  $logger.log("")
  $logger.log("Description- Do not enter anything in the E-mail Address and
Password field and click Login button.") #logs only to corelogger file
  $logger.log("Expected Output-The user should not be able to login.")
  $logger.log("")
  $logger.log("Step 1: Go to the Philipnow.com :- '
https://www.philipnow.com/envcss/'")
  $ie.goto(test_site)
  $logger.log(" Action-1: entered " + test_site + " in the address bar.")
  $logger.log(":Step 2: Do not enter any thing in user id")
  val_userid=$lgn.TakeData("a",1,$wrk_sht)
  $ie.text_field(:name, "username").set(val_userid.to_s)
  $logger.log("  Action-2: entered Nothing in in e-mail address")

  $logger.log(":Step-3: Do not enter any thing in password field")
  val_password=$lgn.TakeData("b",1,$wrk_sht)
  $ie.text_field(:name,"password").set(val_password.to_s)
  $logger.log(":Action-3: entered Nothing in password field")


=begin     oPopup      = Watir::autoit
           # Change into the WinTitleMatchMode that supports classnames and
handles
           oPopup.AutoItSetOption("WinTitleMatchMode", 4)
           0.upto(timeout) { |i|}
               ret = oPopup.WinWait("Microsoft Internet Explorer","",1)
               win_text = oPopup.WinGetText("Microsoft Internet Explorer")
               if 1 == ret && !(win_text == '') then
                   bPopupFound     = true
                   oPopup.WinActivate("Microsoft Internet Explorer",'')
                   win_text  = oPopup.ControlGetText(what, '',
'Static2').strip
                   if '' == win_text then win_text  =
oPopup.ControlGetText(what,
'', 'Static1').strip end
                   break
=end

  startClicker("OK",3)

  #require 'js_dialog'
  #assert_js_dialog do

    $ie.button(:name, "login").click
    text(2)

 #end



  $logger.log(":Step-4: Click the Login button")


  $logger.log("Action-4: clicked the Login button.")


  begin
       assert($ie.contains_text("Welcome to Client Self-service Portal,
Alex Reyes!") )
       $logger.log("*FAILED*." + e.message + "\n" + e.backtrace.join("\n"))
       $logger.log("Test Failed:Expected result has not been achieved:-
User is able to login ")
       $logger.log_results( "PSCUser_Login_Logoff_4","Description-Do not
enter anything in the E-mail Address and Password field and click Login
button.","Expected Output-The user should not be able to login.","TEST
FAILED:") #logs to both the XML file and corelogger
  rescue => e
       $logger.log("Test Passed:Expected result has  been achieved:- User
is not able to login ")
       $logger.log_results( "PSCUser_Login_Logoff_4","Description-Do not
enter anything in the E-mail Address and Password field and click Login
button.","Expected Output-The user should not be able to login.","TEST
PASSED:") #logs to both the XML file and corelogger
     end

     $ie.close
     $logger.log("Close excel file")
  $lgn.excel_close
  $logger.log("Closed excel file")
  $logger.log "## End of test: PSC login\n"
end
end
Regards
     shalini gupta
_______________________________________________
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

Reply via email to