Class: Firefox

Inherits:
Object
  • Object
show all
Defined in:
lib/testnow/firefox.rb

Overview

module TestNow

Instance Method Summary collapse

Instance Method Details

#get_tmp_dirObject



34
35
36
37
38
39
40
41
42
43
# File 'lib/testnow/firefox.rb', line 34

def get_tmp_dir
  case RUBY_PLATFORM
    when /mswin|msys|mingw|cygwin|bccwin|wince|emc/
      return `echo %TEMP%`
    when /darwin|mac os/
      return "/tmp/"
    else
      return "/tmp/"
  end
end

#launch_driver_firefoxObject

Firefox browser



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/testnow/firefox.rb', line 5

def launch_driver_firefox
  ENV['IS_UPA'] = "false" if ENV['IS_UPA'].nil?
  if ENV['IS_UPA']=="true"
    ENV['HAR_DIR'] = get_tmp_dir if ENV['HAR_DIR'].nil?
    puts "=>=>=>  Your HAR (UPA) files will be created here : #{ENV['HAR_DIR']}"
    firebug = File.absolute_path(File.dirname(__FILE__)+"/../../data/firebug-2.0.13.xpi")
    net_export = File.absolute_path(File.dirname(__FILE__)+"/../../data/netExport-0.8.xpi")
    profile = Selenium::WebDriver::Firefox::Profile.new
    profile.add_extension(firebug)
    profile.add_extension(net_export)
    profile['extensions.firebug.currentVersion'] = "2.0.13"
    profile['extensions.firebug.allPagesActivation'] = "on"
    profile['extensions.firebug.defaultPanelName'] = "net"
    profile['extensions.firebug.net.enableSites'] = "true"
    profile['extensions.firebug.netexport.alwaysEnableAutoExport'] = "true"
    profile['extensions.firebug.netexport.showPreview'] = "false"
    profile['extensions.firebug.netexport.defaultLogDir'] = ENV['HAR_DIR'].to_s
    profile['extensions.firebug.netexport.defaultFileName'] = "upaReport.har"
    profile['extensions.firebug.netexport.jsonpCallback'] = "jsonCallback"
    @driver = Selenium::WebDriver.for :firefox, :profile => profile
  else
    @driver = Selenium::WebDriver.for :firefox
  end
  @driver.manage.timeouts.implicit_wait = 30
  @driver.manage.timeouts.page_load = 120
  @driver.manage.window.maximize
  @driver
end

#launch_watir_firefoxObject



45
46
47
48
49
50
51
# File 'lib/testnow/firefox.rb', line 45

def launch_watir_firefox
  browser = Watir::Browser.new
  browser.driver.manage.timeouts.implicit_wait = 30
  browser.driver.manage.timeouts.page_load = 120
  browser.driver.manage.window.maximize
  return browser
end