Class: TestRunner

Inherits:
Object
  • Object
show all
Defined in:
lib/coba-testrunner.rb

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ TestRunner



6
7
8
9
10
11
12
13
14
# File 'lib/coba-testrunner.rb', line 6

def initialize(config)
  @config = config
  @driver = ""
  @time = Hash.new
  @index = config['keyIndex']
  @testCase = ""
  # @screenshotPath = "#{Dir.pwd}/log/#{@config['browsers']}/#{@config['screenshotPath']}/#{@index+1}"

  @screenshotPath = "#{Dir.pwd}/log/#{@config['browsers']}/screenshot/#{@index+1}"
end

Instance Method Details

#configObject



71
72
73
# File 'lib/coba-testrunner.rb', line 71

def config
  @config
end

#initObject



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
# File 'lib/coba-testrunner.rb', line 15

def init()
  start = Time.new

  case @config['browsers']
  when "firefox"
    options = Selenium::WebDriver::Firefox::Options.new
    options.profile = "Driver"
    @driver = Selenium::WebDriver.for :firefox, options: options
  when "phantomjs"
    @driver = Selenium::WebDriver.for :phantomjs
  when "chrome"
    @driver = Selenium::WebDriver.for :chrome
  when "iexplore"
    caps = Selenium::WebDriver::Remote::Capabilities.internet_explorer(
      'ie.ensureCleanSession' => true,
      'ie.forceCreateProcessApi' => true, 
      'ie.browserCommandLineSwitches' => '-private'
      )
    @driver = Selenium::WebDriver.for(:internet_explorer, :desired_capabilities => caps)
  when "safari"
    # opts = Selenium::WebDriver::Safari::Options.new

    # opts.add_extension "#{Dir.pwd}/../selenium/SafariDriver.safariextz"

    @driver = Selenium::WebDriver.for :safari
  when "opera"
    Selenium::WebDriver::Chrome.driver_path = "#{Dir.pwd}/../selenium/operadriver.exe"
    @driver = Selenium::WebDriver.for :chrome
    # @driver = Selenium::WebDriver.for :ie

  else
    puts "Browser you specified not supported yet"
  end

  finish = Time.new

  logTime "initialize", start, finish
end

#start(testCase = nil) ⇒ Object



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/coba-testrunner.rb', line 50

def start(testCase=nil)
  @testCase = testCase

  if(@config['overrideConfig'] === true)
    @config = overrideConfig(@config,@testCase)
  end

  beforeExecution

  loadUrl(@config['startingUrl'])

  mainTest(testCase)

  afterExecution
end

#stopObject



65
66
67
68
69
70
# File 'lib/coba-testrunner.rb', line 65

def stop
  @driver.quit
  @testCase['time'] = @time
  puts "====================== Finish : Test Case Number #{@index+1}"
  return @testCase
end