The following is the code that I am using to select one particular option from a select tag:
select = driver.find_element(:id, "lang")
wait = Selenium::WebDriver::Wait.new(:timeout => 20)
begin
all_options = wait.until { driver.find_elements(:tag_name => "option") }
end
all_options.each do |option|
if (option.attribute("value")=="11")
option.click
end
end
I am using jruby. When I execute the commands line by line in the IRB, there is no problem. But, when I run the whole code together, it gives me an error of unexpected End-of-File encountered. Why am I getting this error? Why does it work when executed command by command and not when it is executed as a whole? How do I overcome this?
The error is as follows-
SyntaxError: (irb):364: syntax error, unexpected end-of-file
from org/jruby/RubyKernel.java:1061:in `eval'
from C:/jruby-1.7.1/lib/ruby/1.8/irb.rb:158:in `eval_input'
from C:/jruby-1.7.1/lib/ruby/1.8/irb.rb:271:in `signal_status'
from C:/jruby-1.7.1/lib/ruby/1.8/irb.rb:270:in `signal_status'
from C:/jruby-1.7.1/lib/ruby/1.8/irb.rb:155:in `eval_input'
from org/jruby/RubyKernel.java:1392:in `loop'
from org/jruby/RubyKernel.java:1160:in `catch'
from C:/jruby-1.7.1/lib/ruby/1.8/irb.rb:154:in `eval_input'
from C:/jruby-1.7.1/lib/ruby/1.8/irb.rb:71:in `start'
from org/jruby/RubyKernel.java:1160:in `catch'
from C:/jruby-1.7.1/lib/ruby/1.8/irb.rb:70:in `start'
from C:\jruby-1.7.1\/bin/jirb_swing:54:in `(root)'
SyntaxError: (irb):364: syntax error, unexpected kEND
end
^
from org/jruby/RubyKernel.java:1061:in `eval'
from C:/jruby-1.7.1/lib/ruby/1.8/irb.rb:158:in `eval_input'
from C:/jruby-1.7.1/lib/ruby/1.8/irb.rb:271:in `signal_status'
from C:/jruby-1.7.1/lib/ruby/1.8/irb.rb:270:in `signal_status'
from C:/jruby-1.7.1/lib/ruby/1.8/irb.rb:155:in `eval_input'
from org/jruby/RubyKernel.java:1392:in `loop'
from org/jruby/RubyKernel.java:1160:in `catch'
from C:/jruby-1.7.1/lib/ruby/1.8/irb.rb:154:in `eval_input'
from C:/jruby-1.7.1/lib/ruby/1.8/irb.rb:71:in `start'
from org/jruby/RubyKernel.java:1160:in `catch'
from C:/jruby-1.7.1/lib/ruby/1.8/irb.rb:70:in `start'
from C:\jruby-1.7.1\/bin/jirb_swing:54:in `(root)'
SyntaxError: (irb):367: syntax error, unexpected end-of-file
from org/jruby/RubyKernel.java:1061:in `eval'
from C:/jruby-1.7.1/lib/ruby/1.8/irb.rb:158:in `eval_input'
from C:/jruby-1.7.1/lib/ruby/1.8/irb.rb:271:in `signal_status'
from C:/jruby-1.7.1/lib/ruby/1.8/irb.rb:270:in `signal_status'
from C:/jruby-1.7.1/lib/ruby/1.8/irb.rb:155:in `eval_input'
from org/jruby/RubyKernel.java:1392:in `loop'
from org/jruby/RubyKernel.java:1160:in `catch'
from C:/jruby-1.7.1/lib/ruby/1.8/irb.rb:154:in `eval_input'
from C:/jruby-1.7.1/lib/ruby/1.8/irb.rb:71:in `start'
from org/jruby/RubyKernel.java:1160:in `catch'
from C:/jruby-1.7.1/lib/ruby/1.8/irb.rb:70:in `start'
from C:\jruby-1.7.1\/bin/jirb_swing:54:in `(root)'
NameError: undefined local variable or method `option' for main:Object
from (irb):367:in `evaluate'
from org/jruby/RubyKernel.java:1061:in `eval'
from C:/jruby-1.7.1/lib/ruby/1.8/irb.rb:158:in `eval_input'
from C:/jruby-1.7.1/lib/ruby/1.8/irb.rb:271:in `signal_status'
from C:/jruby-1.7.1/lib/ruby/1.8/irb.rb:270:in `signal_status'
from C:/jruby-1.7.1/lib/ruby/1.8/irb.rb:155:in `eval_input'
from org/jruby/RubyKernel.java:1392:in `loop'
from org/jruby/RubyKernel.java:1160:in `catch'
from C:/jruby-1.7.1/lib/ruby/1.8/irb.rb:154:in `eval_input'
from C:/jruby-1.7.1/lib/ruby/1.8/irb.rb:71:in `start'
from org/jruby/RubyKernel.java:1160:in `catch'
from C:/jruby-1.7.1/lib/ruby/1.8/irb.rb:70:in `start'
from C:\jruby-1.7.1\/bin/jirb_swing:54:in `(root)'
SyntaxError: (irb):368: syntax error, unexpected kEND
end
^
from org/jruby/RubyKernel.java:1061:in `eval'
from C:/jruby-1.7.1/lib/ruby/1.8/irb.rb:158:in `eval_input'
from C:/jruby-1.7.1/lib/ruby/1.8/irb.rb:271:in `signal_status'
from C:/jruby-1.7.1/lib/ruby/1.8/irb.rb:270:in `signal_status'
from C:/jruby-1.7.1/lib/ruby/1.8/irb.rb:155:in `eval_input'
from org/jruby/RubyKernel.java:1392:in `loop'
from org/jruby/RubyKernel.java:1160:in `catch'
from C:/jruby-1.7.1/lib/ruby/1.8/irb.rb:154:in `eval_input'
from C:/jruby-1.7.1/lib/ruby/1.8/irb.rb:71:in `start'
from org/jruby/RubyKernel.java:1160:in `catch'
from C:/jruby-1.7.1/lib/ruby/1.8/irb.rb:70:in `start'
from C:\jruby-1.7.1\/bin/jirb_swing:54:in `(root)'
SyntaxError: (irb):369: syntax error, unexpected kEND
end
^
from org/jruby/RubyKernel.java:1061:in `eval'
from C:/jruby-1.7.1/lib/ruby/1.8/irb.rb:158:in `eval_input'
from C:/jruby-1.7.1/lib/ruby/1.8/irb.rb:271:in `signal_status'
from C:/jruby-1.7.1/lib/ruby/1.8/irb.rb:270:in `signal_status'
from C:/jruby-1.7.1/lib/ruby/1.8/irb.rb:155:in `eval_input'
from org/jruby/RubyKernel.java:1392:in `loop'
from org/jruby/RubyKernel.java:1160:in `catch'
from C:/jruby-1.7.1/lib/ruby/1.8/irb.rb:154:in `eval_input'
from C:/jruby-1.7.1/lib/ruby/1.8/irb.rb:71:in `start'
from org/jruby/RubyKernel.java:1160:in `catch'
from C:/jruby-1.7.1/lib/ruby/1.8/irb.rb:70:in `start'
from C:\jruby-1.7.1\/bin/jirb_swing:54:in `(root)'
You have too many ends:
Or, if you need a rescue: