unknown wrote in post #1087821:
> Am 04.12.2012 18:43, schrieb Mattias A.:
>>      @driver.find_element(:id, "q")
>>      puts "Page title is #{@driver.title}"
>>    end
>>
>> test = Find_element.new
>> test.by_id
>> end
>
> First, you have a misplaced `end' (the last one).
>
> I cannot reproduce your error messages, but for me the
> code results in a TimeOut error, because there is no element
> with id='q'. Changing :id to :name works fine (or try with
> an id that actually exists on the page).

Thanks for your reply, so it should be as below?

...
    puts "Page title is #{@driver.title}"
  end
end
test = Find_element.new
test.by_id

-------------------
I did a new try with below but it insists on running the method by_id 
even if i not call it? Any ides?
-------------------
require 'selenium-webdriver'
class Find_element

  def initialize
    @driver = Selenium::WebDriver.for :firefox
    @driver.get "http://google.com"
  end

  def by_id
    #By ID - driver.find_element(:id,<elementID>)
    @driver.find_element (:id, "q")
    puts "Page title is #{@driver.title}"
  end

  def by_name
    #By name - driver.find_element(:name,<element name>)
    @driver.find_element (:name, "q")
    puts "Page title is #{@driver.title}"
  end

end

test = Find_element.new
#test.by_id
test.by_name

-- 
Posted via http://www.ruby-forum.com/.