I am learning automation and have no prior programming knowledge. I am trying to learn Selenium with ruby: I am having issues with launching the firefox browser.What am i doing wrong?
My code is
require 'rubygems'
require 'selenium-webdriver'
System.setProperty("webdriver.gecko.driver","path of geckodriver.exe");
WebDriver = new FirefoxDriver();
driver = Selenium::WebDriver.for :firefox
driver.navigate.to "http://facebook.com"
puts"facebook is loaded in FF browser"
I am getting the following error:
3:in '':uninitialized constant System (NameError)
Did you mean? SysytemExit
Related
I am attempting to run the following ruby code via RubyMine:
require 'rubygems'
require 'watir-webdriver'
browser = Watir::Browser.new :firefox
browser.goto 'http://www.apple.com'
When I run I get the following error:
firefox connection in 60 seconds (127.0.0.1:7055) (Selenium::WebDriver::Error::WebDriverError)
from /Users/mark/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/firefox/launcher.rb:55:in block in launch'
from /Users/mark/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/common/socket_lock.rb:43:inlocked'
from /Users/mark/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/firefox/launcher.rb:51:in launch'
from /Users/mark/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/firefox/bridge.rb:43:ininitialize'
from /Users/mark/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/common/driver.rb:53:in new'
from /Users/mark/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/common/driver.rb:53:infor'
from /Users/mark/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver.rb:84:in for'
from /Users/mark/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/watir-webdriver-0.9.3/lib/watir-webdriver/browser.rb:46:ininitialize'
from /Users/mark/cheezy/first_script.rb:3:in new'
from /Users/mark/cheezy/first_script.rb:3:in'
from -e:1:in load'
from -e:1:in'
I have the latest Watir-Webdriver gem installed .
Any ideas please?
Thanks
For Firefox 48+ you need to use geckodriver.
Download from here: https://github.com/mozilla/geckodriver/releases
Selenium instructions: https://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette/WebDriver
Watir instructions: http://watir.github.io/watir-6-beta/
Please let me know if you have any further issues.
When I try to open/attach to an IE browser, I am getting the below error. I have the Watir gem installed in my system, but still I am facing the below error. Earlier, they were no issues when I tried to open the IE browser.
irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'watir'
=> true
irb(main):003:0> include Watir
=> Object
irb(main):004:0> #ie=Watir::IE.new
NameError: uninitialized constant Watir::IE
from (irb):4
My system configurations:
Windows-7
IE-8
Watir::IE has been deprecated in the newer versions of Watir (Classic). In the current version of Watir (Classic and Webdriver), it needs to be Watir::Browser.
In other words:
#ie = Watir::Browser.new
I'm trying to use the Selenium Webdriver gem to write a test but am getting the following error.
"test.rb:4:in `': uninitialized constant Selenium (NameError)"
I can't seem to figure out why its giving me this error. I have pasted the code for the test below.
"require rubygems"
"require selenium-webdriver"
driver = Selenium::WebDriver.for :chrome
that is where it fails. The rest of the test is pretty page-specific js executions.
Your requires do nothing, you just wrote unused String literals, change it to:
require "rubygems"
require "selenium-webdriver"
I am trying to run webdriver tests on IE. My script works on Firefox but not on IE9. I am using selenium-webdriver version 2.5.0 with ruby 1.8.7 patch level 352
Here is my ruby script:
require 'rubygems'
require 'selenium-webdriver'
driver = Selenium::WebDriver.for :ie
driver.navigate.to "http://www.gapinc.com/"
element = driver.find_element(:name, 'search')
element.send_keys 'Employees'
element.submit
puts driver.title
driver.quit
On IE9, I get Unable to find element with name == search (Selenium::WebDriver::Error::NoSuchElementError) and it passes on Firefox
It may be sync issue. Did you try using ImplicitlyWait or WebDriverWait?
I've been using the following code to test run using Capybara with IE8 in pure Ruby, i.e. NOT a rails app but every time I run the script IE8 pops up but then Firefox pops up and the tests run through Firefox leaving IE8 sitting in the background:
$:.unshift(File.dirname(__FILE__) + '/../../lib')
begin require 'rspec/expectations'; rescue LoadError; end
require 'rubygems'
require 'capybara'
require 'capybara/dsl'
Capybara.run_server = false
Capybara.app_host = 'http://www.google.com'
require 'selenium-webdriver'
Selenium::WebDriver.for :internet_explorer
Capybara.default_driver = :selenium
require 'cukesalad'
begin require 'rspec/expectations'; rescue LoadError; require 'spec/expectations'; end
This isn't too old maybe you can find some useful information from it:
Run Capybara & Cucumber Features In Internet Explorer On Remote Windows