From: "Mattias A." Date: 2012-12-05T04:19:36+09:00 Subject: Re: selenium-webdriver + puts page title 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,) @driver.find_element (:id, "q") puts "Page title is #{@driver.title}" end def by_name #By name - driver.find_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/.