On Monday, March 2, 2015 at 10:35:27 PM UTC-8, Ping-0t wrote:
>
> Hello Guys,
>
> Can someone help me with this:
>
> require 'rubygems'
> require 'watir'
> require 'test/unit'
> require 'win32ole'
> gem "test-unit"
>
> class View_OrderDetails < Test::Unit::TestCase
>
>     $sales_order_no = "SO1"    
>     # $fields = ["order_no", "customer_name", "username"]
>     # $success = 0
>     # $error = 0
>
>     def test_in()
>   
>         @browser = Watir::Browser.new :firefox
>         @browser.goto(pageUrl)
>         accept_next_alert = true
>         @browser.driver.manage.window.maximize
>
>         excel = WIN32OLE::new("excel.Application")
>         wrkbook = excel.Workbooks.Open("C:\\toFocus\\test.xlsx")
>         wrksheet = wrkbook.worksheets(1)
>         wrksheet.select
>
>
>         # -------- Authentication / Login Part ---------------
>         rows = 2
>         while rows <= 4
>             $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
>
>         @browser.wait_until{@browser.link(:text, "Sales").click}
>         @browser.link(:text, "Orders").click
>         sleep 3
>         @browser.wait_until{@browser.link(:text, $sales_order_no).click}
>
>         (0..2).each do |i|
>             if @browser.element(:class => $fields[i]) == /\A[+-]?\d+\Z/
>                 puts "Success"
>                 $success = $success + 1
>             else
>                 puts "Erroneous"
>                 $error = $error + 1
>             end
>         end
>
>         @browser.button(:data_role, "edit").click
>         sleep 5
>         puts "Number of Success: #{$success}"
>         puts "Number of Errors: #{$error}"
>
>         @browser.close
>
>     end
> end
>   I want to check the details from the view details if it is numeric, 
> alphanumeric, a varchar or etc. , 
>
>
> Any help is much appreciated.
>
>
> Thanks in advance :)
>
>
> Ping
>
>
First off, way more code than we need to see, try to limit code samples to 
the minimum someone needs to see in order to assist you, For example, I 
don't need to see login code unless your issue is with logging in.  it's 
just noise and makes it harder for folks to help you.
.
Second, a bit of the html you are trying to work with would be useful.

Third: you say ''when I view details"  when is that?  there are no 
comments, no variables named 'details' in short not a single thing to tell 
us where in the code you consider yourself to be 'viewing details'

Fourth  HTML does not really have data- typing.. everything is text 
(strings basically).  and Ruby does not declare types and is pretty good 
about casting to other types, so if you extract HTML Text into a variable, 
and ask what type it is, you are most likely going to get 'string' even if 
the contents are 12345.67.  if you try to test by casting the value to a 
specific type, it will often succeed (eg casting a string holding 12345 to 
a float will work.

So the best thing you could do is check to see if the value matches a 
regular expression pattern.  Do some googling to research regular 
expressions in ruby.  Use a site like http://rubular.com/ to play with 
regular expressions, throw various test values at a regex you create and 
see if it behaves as you expect.  Be sure your expressions specify to match 
the entire thing, or a match for an 'int' would return true against "my 
favorite number? 5 for sure"  Also do bear in mind that many 'types' are 
also subtypes..  e.g. an int (numbers with no decimal) is also technically 
'alphanumeric' which normally means numbers or letters.

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

--- 
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 watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to