Reputation: 149
I am trying to run my first selenium webdriver script using ruby. I have ruby installed, as well as the gem for webdriver. Googling this question for several hours has been fairly fruiteless - any help is appreciated!
require "selenium-webdriver"
driver = Selenium::WebDriver.for :firefox
driver.navigate.to "http://google.com"
element = driver.find_element(:name, 'q')
element.send_keys "Hello WebDriver!"
element.submit
puts driver.title
driver.quit
I get this error message:
testb.rb:2:in `<main>': undefined local variable or method `‘selenium' for main:Object (NameError)
ruby -v ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-darwin12.0]
gem list returns selenium-webdriver (2.40.0) as part of the list
Can someone guide me a little? I think ruby simply isn't recognizing selenium and can't get past the second line of code - is there another step to 'link up' selenium with this simple ruby script?
Upvotes: 0
Views: 2885
Reputation: 149
Line two was using single quotes (') rather than double for "selenium-webdriver". This is fixed.
Upvotes: 5