Am 04.12.2012 20:19, schrieb Mattias A.:
> -------------------
> I did a new try with below but it insists on running the method by_id
> even if i not call it? Any ides?

I do not think it does. Try including statements like
"puts 'method by_id'" and "puts 'method by_name'"
in the respective method.

> -------------------
> 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")

You should remove the space before the argument parentheses
(it causes an error in Ruby 1.9.3).

   @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


-- 
<https://github.com/stomar/>