Hi sir, I change my codes into this:

require 'watir-webdriver'

gem "test-unit"
require 'test/unit'
require "win32ole"

class Login < Test::Unit::TestCase

    $number_of_fails = 0
    $number_of_success = 0

    $fields = ["first_name", "middle_name", "last_name", "sss_number", 
"tin_number"]

    def test_in()
        @browser =Watir::Browser.new :firefox
        @browser.goto 'http://gw01.nextix.org/login'
        accept_next_alert=true
        @browser.driver.manage.window.maximize

        excel= WIN32OLE::new("excel.Application")
        wrkbook=excel.Workbooks.Open("C:\\testing\\inputs.xlsx")
        wrksheet = wrkbook.worksheets(1)
        wrksheet.select


        # -------- Authentication / Login Part ---------------
        rows = 2
        while rows <= 5
            $username = wrksheet.cells(rows, "A").value
            $password = wrksheet.cells(rows, "B").value

            @browser.text_field(:name, "username").set($username)
            sleep 3
            @browser.text_field(:name, "password").set($password)
            sleep 3
            @browser.button(:name => 'login').click
            sleep 3

            rows = rows + 1
        end

        # ------------- Before Adding a new User
        $Dashboard = @browser.link(:text, "Dashboard")
        $Dashboard.exists?
        $Dashboard.click
        @browser.link(:text, "Users").click
        @browser.button(:value,"Add New User").click


        # >>>>>> Add new User <<<<<<<
        # Personal Information Block
        # @browser.send_keys :f12
        rows = 8
        while rows <= 13
            $to_enter = [wrksheet.cells(rows, "A").value, wrksheet.cells(
rows, "B").value, wrksheet.cells(rows, "C").value, wrksheet.cells(rows, "D"
).value, wrksheet.cells(rows, "E").value]

            @browser.text_field(:id, $fields[0]).set($to_enter[0])
            sleep 5
            @browser.text_field(:id, $fields[1]).set($to_enter[1])
            sleep 5
            @browser.text_field(:id, $fields[2]).set($to_enter[2])
            sleep 5
            @browser.text_field(:id, $fields[3]).set($to_enter[3])
            sleep 5
            @browser.text_field(:id, $fields[4]).set($to_enter[4])
            @browser.send_keys :tab

            rows += 1

            (0..4).each do |i|
                if @browser.text_field(:id => $fields[i], :aria_invalid => 
"true").exist?
                    $number_of_success = $number_of_success + 1
                    puts @browser.execute_script('return 
document.getElementsByClassName("form-control")[0];')
                else
                    $number_of_fails = $number_of_fails + 1
                end
            end
        end
      

        puts "Number of Success: #{$number_of_success}"
        puts "Number of Failures: #{$number_of_fails}"

    end
end

And then I have this output: 


User1@DOCUMENTATIONS /c/testing
$ ruby revised_login.rb
Loaded suite revised_login
Started
#<Watir::Input:0x349e888>
#<Watir::Input:0x1e2bfe0>
#<Watir::Input:0x257c538>
#<Watir::Input:0x282ad88>
#<Watir::Input:0x28f77f0>
#<Watir::Input:0x341b3b0>
#<Watir::Input:0x346f500>
#<Watir::Input:0x348ba60>
#<Watir::Input:0x2469ab0>
#<Watir::Input:0x2818488>
#<Watir::Input:0x28d6c58>
#<Watir::Input:0x27dfd28>
#<Watir::Input:0x341a978>
#<Watir::Input:0x3495bd0>
#<Watir::Input:0x34ad600>
#<Watir::Input:0x245f910>
#<Watir::Input:0x28090f8>
#<Watir::Input:0x28d32f8>
#<Watir::Input:0x3411768>
#<Watir::Input:0x3448020>
#<Watir::Input:0x3473ce8>
#<Watir::Input:0x3499890>
#<Watir::Input:0x34ca298>
Number of Success: 23
Number of Failures: 7
.

Finished in 310.804865 seconds.
--------------------------------------------------------------------------------

1 tests, 0 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 
notifica
tions
100% passed
--------------------------------------------------------------------------------

0.00 tests/s, 0.00 assertions/s

User1@DOCUMENTATIONS /c/testing
$

Sir, I don't really understand the output. But when I will change my codes 
from
puts @browser.execute_script('return 
document.getElementsByClassName("form-control")[0];')

into
puts @browser.execute_script('return 
document.getElementsByClassName("form-control")[0];').html
I have this error:


User1@DOCUMENTATIONS /c/testing
$ ruby revised_login.rb
Loaded suite revised_login
Started
E
================================================================================

Error: test_in(Login)
: Selenium::WebDriver::Error::JavascriptError: invalid 'in' operand a
[remote server] http://gw01.nextix.org/user/ line 68 > Function:18:in `G'
[remote server] http://gw01.nextix.org/user/ line 68 > Function:18:in 
`anonymous
/</<'
[remote server] http://gw01.nextix.org/user/ line 68 > Function:15:in 
`anonymous
/<'
[remote server] http://gw01.nextix.org/user/ line 68 > Function:15:in 
`anonymous
'
[remote server] http://gw01.nextix.org/user/:68:in `handleEvaluateEvent'
c:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.44.0/lib/selenium/
webdr
iver/remote/response.rb:52:in `assert_ok'
c:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.44.0/lib/selenium/webdr
iver/remote/response.rb:15:in `initialize'
c:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.44.0/lib/selenium/webdr
iver/remote/http/common.rb:59:in `new'
c:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.44.0/lib/selenium/
webdr
iver/remote/http/common.rb:59:in `create_response'
c:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.44.0/lib/selenium/webdr
iver/remote/http/default.rb:66:in `request'
c:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.44.0/lib/selenium/webdr
iver/remote/http/common.rb:40:in `call'
c:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.44.0/lib/selenium/
webdr
iver/remote/bridge.rb:640:in `raw_execute'
c:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.44.0/lib/selenium/webdr
iver/remote/bridge.rb:618:in `execute'
c:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.44.0/lib/selenium/webdr
iver/remote/bridge.rb:339:in `executeScript'
c:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.44.0/lib/selenium/
webdr
iver/common/driver.rb:193:in `execute_script'
c:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-webdriver-0.6.11/lib/watir-webdriver/a
toms.rb:20:in `execute_atom'
c:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-webdriver-0.6.11/lib/watir-webdriver/e
lements/element.rb:290:in `outer_html'
revised_login.rb:73:in `block in test_in'
     70:                (0..4).each do |i|
     71:                                if @browser.text_field(:id => 
$fields[i]
, :aria_invalid => "true").exist?
     72:                                        $number_of_success = 
$number_of_
success + 1
  => 73:                                        puts 
@browser.execute_script('re
turn document.getElementsByClassName("form-control")[0];').html
     74:                                else
     75:                                        $number_of_fails = 
$number_of_fa
ils + 1
     76:                                end
revised_login.rb:70:in `each'
revised_login.rb:70:in `test_in'
================================================================================



Finished in 244.609441 seconds.
--------------------------------------------------------------------------------

1 tests, 0 assertions, 0 failures, 1 errors, 0 pendings, 0 omissions, 0 
notifica
tions
0% passed
--------------------------------------------------------------------------------

0.00 tests/s, 0.00 assertions/s




-- 
-- 
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.

Reply via email to