From: Wes Bailey Date: 2010-06-01T15:39:09+09:00 Subject: Re: If else condition in ruby not working ----- "King Maker" wrote: > i write simple code for button if button pressed than result is > passed > other wise failed. > > but every time condition goes to the Failed. > i try may things but every time i face this problem. > > > > begin > if(ie.button(:value,"Continue").click) > @result = 'PASSED' > @log = "Clicked Continue button" > log.info "Clicked Continue button\n" > else > @result = 'FAILED' > @log = "Clicked Continue button not pressed" > log.info "Clicked Continue button not pressed\n" > end > Readfrom_file(@file1,"Continue button",@log,@result) > rescue > end > -- > Posted via http://www.ruby-forum.com/. Without knowing the failure you describe and what libraries you are using perhaps better organization of your code might be: begin ie.button( :value, 'Continue' ).click @result = 'PASSED' @log = 'Clicked Continue button' Readfrom_file(@file1,"Continue button",@log,@result) rescue Exception => e @result = 'Failed' @log = 'Clicked Continue button not pressed: ' + e.message ensure log.info @log + "\n" end