Module: Sauce::SeleniumForTestUnit

Included in:
RailsTestCase
Defined in:
lib/sauce/test_unit.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#browserObject (readonly) Also known as: page, s, selenium

Returns the value of attribute browser



6
7
8
# File 'lib/sauce/test_unit.rb', line 6

def browser
  @browser
end

Instance Method Details

#run(*args, &blk) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/sauce/test_unit.rb', line 12

def run(*args, &blk)
  if self.respond_to? :name
    my_name = self.name
  else
    my_name = self.__name__
  end
  unless my_name =~ /^default_test/
    config = Sauce::Config.new
    if config[:application_host]
      unless ENV['TEST_ENV_NUMBER'].to_i > 1
        Sauce::Connect.ensure_connected(:host => config[:application_host], :port => config[:application_port] || 80)
      end
    end

    unless defined?(@@server)
      unless ENV['TEST_ENV_NUMBER'].to_i > 1
        if config[:start_local_application] &&
            Sauce::Utilities::RailsServer.is_rails_app?
          @@server = Sauce::Utilities::RailsServer.new
          @@server.start
          at_exit do
            @@server.stop
          end
        end
      end
    end

    config[:browsers].each do |os, browser, version|
      options = self.class.sauce_config
      options.merge!({:os => os, :browser => browser,
                      :browser_version => version,
                      :job_name => my_name.to_s})
      @browser = Sauce::Selenium2.new(options)
      Sauce.driver_pool[Thread.current.object_id] = @browser

      super(*args, &blk)

      SauceWhisk::Jobs.change_status @browser.session_id, passed?
      @browser.stop
      Sauce.driver_pool.delete Thread.current.object_id
    end
  end
end