SeleniumHQ / selenium-google-code-issue-archive

Archive, please see main selenium repo
https://github.com/seleniumhq/selenium
346 stars 194 forks source link

Selenium 2 - Unable to run Se2 test in Firefox: #1036

Closed lukeis closed 8 years ago

lukeis commented 8 years ago

Originally reported on Google Code with ID 1036

I have the following test script (after having installed selenium-webdriver 0.1.0)

require File.expand_path(File.dirname(__FILE__) + "/../spec_helper_2.rb")

def driver_browser
  if WHICH_BROWSER == "firefox"
    @browser = Selenium::WebDriver.for(:firefox)
  elsif WHICH_BROWSER == ""
    @browser = Selenium::WebDriver.for()
  elsif WHICH_BROWSER == ""
    @browser = Selenium::WebDriver.for()
  elsif WHICH_BROWSER == ""
    @browser = Selenium::WebDriver.for()
  else
    @browser = Selenium::WebDriver.for()
  end

end

describe "test" do

  before(:all) do
    driver_browser
  end

  after(:all) do
    @browser.quit
  end

  it "Should be a test" do
    @browser.navigate.to SECURE_HOST
    sleep 10 
  end

end

When I run this test for :firefox the browser starts but I get the following:

Problem while setting context on example startundefined local variable or method `selenium_driver'
for #<Spec::Example::ExampleGroup::Subclass_1:0x10244e9d8>

I then get:

Problem while capturing system stateundefined local variable or method `selenium_driver'
for #<Spec::Example::ExampleGroup::Subclass_1:0x10244e9d8>

and the browser closes.

Not sure what this is as my tests seem to be setup properly based on the documentation
I could find.

Reported by qablogmbox on 2010-11-24 19:36:10

lukeis commented 8 years ago
These appear to be warnings and don't actually stop the execution of a test script.

Reported by qablogmbox on 2010-11-24 20:34:54

lukeis commented 8 years ago
So does the browser close, or does your test run?

Please post the full code needed to reproduce the problem. 

I'm 99% sure the warning isn't coming from our code. The fact that it can't find a
"selenium_driver" method on a Spec::Example class indicates that you're referring to
a selenium_driver variable inside an rspec example somewhere - i.e. it's your own code
that's throwing this error.

Reported by jari.bakken on 2010-11-25 22:16:58

lukeis commented 8 years ago
Yes browser closes. Here is the full code:

describe "test" do

  before(:all) do
    driver_browser
    setup_testing
    get_student_email
    create_trial_user_through_api("gmat_v2", @student_email)
    login_to_site
  end

  after(:all) do
    @browser.quit
  end

  def login_to_site
    email_address = @browser.find_element(:name, 'email')
    email_address.send_keys(@student_email)
    password = @browser.find_element(:name, 'password')
    password.send_keys("test")
    @browser.find_element(:class_name, 'primary-button').click()
  end

  it "Should validate that the element exists" do
    #@browser.wait_for_element "css=#video_knewton_experience", :timeout_in_seconds
=> 20 #this is Se RC code. Need the SE2 equivalent
    sleep 10 
  end

end

Associated Functions:

def setup_testing
  ensure_user_logged_out
end

def ensure_user_logged_out
  @browser.navigate.to SECURE_HOST + "/logout"
end

def driver_browser
  if WHICH_BROWSER == "firefox"
    @browser = Selenium::WebDriver.for(:firefox)
  elsif WHICH_BROWSER == "ie"
    @browser = Selenium::WebDriver.for(:ie)
  elsif WHICH_BROWSER == "chrome"
    @browser = Selenium::WebDriver.for(:chrome)
  elsif WHICH_BROWSER == ""
    @browser = Selenium::WebDriver.for()
  else
    @browser = Selenium::WebDriver.for()
  end
end

The other 2 functions:   get_student_email and create_trial_user_through_api don't
have any selenium driver code in them.

Reported by qablogmbox on 2010-11-29 21:57:39

lukeis commented 8 years ago
Issues resolved. Was combining webdriver and selenium rc requires in my spec helper.
Removed the rc ones and the warnings are gone. 

Reported by qablogmbox on 2010-12-21 20:51:33

lukeis commented 8 years ago

Reported by antlong on 2011-01-20 16:47:08

lukeis commented 8 years ago

Reported by luke.semerau on 2015-09-17 18:11:37