From: Josh Cheek Date: 2010-06-01T16:16:39+09:00 Subject: Re: If else condition in ruby not working --0016e64c3986fad6a00487f2c03e Content-Type: text/plain; charset=ISO-8859-1 On Tue, Jun 1, 2010 at 1:15 AM, 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/. > > Hi, King, You need to give more context. I assume you are using watir and logger, I don't know anything else, but regardless, I shouldn't have to guess. Also, I assume by "goes to the Failed" you mean the condition is false, as opposed to raises an error, for example. Anyway Try making sure the browser is on the page you think it is on. Try looking at the html and making sure that there is only one button with a value of "Continue". Try inspecting that button before you click it. Make sure it is there, make sure it is the button you want to click. Maybe use the debugger to get an interactive irb session into your code right at that moment, so you can play with that object, make sure it looks how you think it should look. (There is a nice Railscast gives an example of how to use ruby-debug http://railscasts.com/episodes/54-debugging-with-ruby-debug) Also, I don't know what Readfrom_file is, but you should check that it is named correctly, it's context implies a function, but functions almost never begin with capital letters, and when they do, it's not for whatever you're trying to do with it. --0016e64c3986fad6a00487f2c03e--