Think you need this

if @browser.text.include?("Signed in!") == true
  # Something...elseend
Think there's more than one spreadsheet library but you should be able to query 
the spreadsheet object for the number of of rows that it has (take a look at 
the rdocs for it.) Then you could do something like 
spreadsheet.rows.each do
  # Something ...end
And there should be a way of omitting the header row or you could do something 
like spreadsheet.rows.to_a[1..-1] to get a collection of rows without the 
header (don't know if to_a would be necessary)      From: Mohan MK 
<[email protected]>
 To: [email protected] 
 Sent: Thursday, December 18, 2014 4:17 AM
 Subject: [wtr-general] Problem with Logger and condition if/else Watir | 
Testwise
   
Hi All,

In below code I am trying to iterate 2 loops of data from data sheet one 
positive and one negative scenario and using “logger” to log “PASS” and “FAIL”. 
Problem I am facing are 

1. When I run the script with negative “say invalid password” the script stops 
at line marked in Red bold “if @browser.text.include?("Signed in!").should 
then” 


Login with Data file Login with Datafile
Failure/Error: if @browser.text.include?("Signed in!").should == true then
expected: true
got: false (using ==)


I don’t want the script to stop, it should log as “FAIL” and continue with next 
iteration with positive condition. What is that I am doing wrong here also is 
there better way to handle this? Below is the code I am using
 2.      Is there a way to get the row count of active spreadsheet instead of 
hardcoding while @rows <= 2 It would be of great help if someone can answer to 
abovequestions. Thanks in advance.
Code :while @rows <= 2

$log.info("** PAGE URL **")

$log.info @browser.url


[email protected](@rows,"A") ['text']

[email protected](@rows,"B") 
['text'][email protected](@rows,"c") ['text']



 @browser.text_field(:id, "username").set(username)

$log.info("** UserName Entered **")$log.info username


@browser.text_field(:id, "password").set(password)$log.info("** Password 
Entered **")$log.info password


@browser.button(:value,"Sign in").click


if @browser.text.include?("Signed in!").should == true then


$log.info "PASS"


else


$log.info "FAIL"


end
 
@rows=@rows+1

 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.

Reply via email to