### Home Classes Methods

### In Files

- firefox/src/rb/lib/selenium/webdriver/firefox/profile.rb

### Parent

Object

### Methods

- ::from_name
- ::ini
- ::new
- #[]=
- #absolute_path
- #add_webdriver_extension
- #assume_untrusted_certificate_issuer=
- #assume_untrusted_certificate_issuer?
- #delete_extensions_cache
- #extensions_dir
- #load_no_focus_lib?
- #modify_link_library_path
- #native_events?
- #secure_ssl?
- #update_user_prefs
- #user_prefs_path

### Class/Module Index

Quicksearch

- Selenium
- Selenium::WebDriver
- Selenium::WebDriver::BridgeHelper
- Selenium::WebDriver::ChildProcess
- Selenium::WebDriver::ChildProcess::IronRubyProcess
- Selenium::WebDriver::ChildProcess::JRubyProcess
- Selenium::WebDriver::ChildProcess::WindowsProcess
- Selenium::WebDriver::Chrome
- Selenium::WebDriver::Chrome::Bridge
- Selenium::WebDriver::Chrome::CommandExecutor
- Selenium::WebDriver::Chrome::Launcher
- Selenium::WebDriver::Chrome::Launcher::MacOSXLauncher
- Selenium::WebDriver::Chrome::Launcher::UnixLauncher
- Selenium::WebDriver::Chrome::Launcher::WindowsLauncher
- Selenium::WebDriver::Driver
- Selenium::WebDriver::DriverExtensions
- Selenium::WebDriver::DriverExtensions::TakesScreenshot
- Selenium::WebDriver::Element
- Selenium::WebDriver::Error
- Selenium::WebDriver::Error::ElementNotDisplayedError
- Selenium::WebDriver::Error::ElementNotEnabledError
- Selenium::WebDriver::Error::ElementNotSelectableError
- Selenium::WebDriver::Error::ExpectedError
- Selenium::WebDriver::Error::IndexOutOfBoundsError
- Selenium::WebDriver::Error::InvalidCookieDomainError
- Selenium::WebDriver::Error::NoCollectionError
- Selenium::WebDriver::Error::NoScriptResultError
- Selenium::WebDriver::Error::NoStringError
- Selenium::WebDriver::Error::NoStringLengthError
- Selenium::WebDriver::Error::NoStringWrapperError
- Selenium::WebDriver::Error::NoSuchCollectionError
- Selenium::WebDriver::Error::NoSuchDocumentError
- Selenium::WebDriver::Error::NoSuchDriverError
- Selenium::WebDriver::Error::NoSuchElementError
- Selenium::WebDriver::Error::NoSuchFrameError
- Selenium::WebDriver::Error::NoSuchWindowError
- Selenium::WebDriver::Error::NullPointerError
- Selenium::WebDriver::Error::ObsoleteElementError
- Selenium::WebDriver::Error::ServerError
- Selenium::WebDriver::Error::TimeOutError
- Selenium::WebDriver::Error::UnableToSetCookieError
- Selenium::WebDriver::Error::UnexpectedJavascriptError
- Selenium::WebDriver::Error::UnhandledError
- Selenium::WebDriver::Error::UnknownCommandError
- Selenium::WebDriver::Error::UnknownScriptResultError
- Selenium::WebDriver::Error::UnsupportedOperationError
- Selenium::WebDriver::Error::WebDriverError
- Selenium::WebDriver::FileReaper
- Selenium::WebDriver::Find
- Selenium::WebDriver::Firefox
- Selenium::WebDriver::Firefox::Binary
- Selenium::WebDriver::Firefox::Bridge
- Selenium::WebDriver::Firefox::Launcher
- Selenium::WebDriver::Firefox::Profile
- Selenium::WebDriver::Firefox::ProfilesIni
- Selenium::WebDriver::Firefox::Util
- Selenium::WebDriver::IE
- Selenium::WebDriver::IE::Bridge
- Selenium::WebDriver::IE::Kernel32
- Selenium::WebDriver::IE::Lib
- Selenium::WebDriver::IE::Util
- Selenium::WebDriver::Keys
- Selenium::WebDriver::Navigation
- Selenium::WebDriver::Options
- Selenium::WebDriver::Platform
- Selenium::WebDriver::Remote
- Selenium::WebDriver::Remote::Bridge
- Selenium::WebDriver::Remote::Capabilities
- Selenium::WebDriver::Remote::Http
- Selenium::WebDriver::Remote::Http::Common
- Selenium::WebDriver::Remote::Http::Curb
- Selenium::WebDriver::Remote::Http::Default
- Selenium::WebDriver::Remote::Response
- Selenium::WebDriver::TargetLocator
- Selenium::WebDriver::Timeouts
- Dir
- SocketError
- String

No matching classes.

# Selenium::WebDriver::Firefox::Profile

### Constants

ANONYMOUS_PROFILE_NAME
DEFAULT_EXTENSION_SOURCE
DEFAULT_PREFERENCES
EM_NAMESPACE_URI
EXTENSION_NAME
NATIVE_LINUX
NATIVE_WINDOWS
NO_FOCUS
NO_FOCUS_LIBRARY_NAME
OVERRIDABLE_PREFERENCES
SHARED
XPTS

### Attributes

directory[R]
load_no_focus_lib[W]
name[R]
native_events[W]
port[RW]
secure_ssl[W]

### Public Class Methods

from_name(name) click to toggle source

    # File firefox/src/rb/lib/selenium/webdriver/firefox/profile.rb, line 47
    def from_name(name)
      ini[name]
    end

ini() click to toggle source

    # File firefox/src/rb/lib/selenium/webdriver/firefox/profile.rb, line 43
    def ini
      @ini ||= ProfilesIni.new
    end

new(directory = nil) click to toggle source

Create a new Profile instance

@example User configured profile

    profile = Selenium::WebDriver::Firefox::Profile.new
    profile['network.proxy.http'] = 'localhost'
    profile['network.proxy.http_port'] = 9090

    driver = Selenium::WebDriver.for :firefox, :profile => profile

    # File firefox/src/rb/lib/selenium/webdriver/firefox/profile.rb, line 64
    def initialize(directory = nil)
      @directory = directory ? create_tmp_copy(directory) : Dir.mktmpdir("webdriver-profile")

      unless File.directory? @directory
        raise Error::WebDriverError, "Profile directory does not exist: #{@directory.inspect}"
      end

      FileReaper << @directory

      # TODO: replace constants with options hash
      @port              = DEFAULT_PORT
      @extension_source  = DEFAULT_EXTENSION_SOURCE
      @native_events     = DEFAULT_ENABLE_NATIVE_EVENTS
      @secure_ssl        = DEFAULT_SECURE_SSL
      @untrusted_issuer  = DEFAULT_ASSUME_UNTRUSTED_ISSUER
      @load_no_focus_lib = DEFAULT_LOAD_NO_FOCUS_LIB

      @additional_prefs  = {}
    end

### Public Instance Methods

[]=(key, value) click to toggle source

Set a preference for this particular profile. @see preferential.mozdev.org/preferences.html

    # File firefox/src/rb/lib/selenium/webdriver/firefox/profile.rb, line 89
    def []=(key, value)
      case value
      when String
        if Util.stringified?(value)
          raise ArgumentError, "preference values must be plain strings: #{key.inspect} => #{value.inspect}"
        end

        value = %{"#{value}"}
      when TrueClass, FalseClass, Integer, Float
        value = value.to_s
      else
        raise TypeError, "invalid preference: #{value.inspect}:#{value.class}"
      end

      @additional_prefs[key.to_s] = value
    end

absolute_path() click to toggle source

    # File firefox/src/rb/lib/selenium/webdriver/firefox/profile.rb, line 106
    def absolute_path
      if Platform.win?
        directory.gsub("/", "\\")
      else
        directory
      end
    end

add_webdriver_extension(force_creation = false) click to toggle source

    # File firefox/src/rb/lib/selenium/webdriver/firefox/profile.rb, line 132
    def add_webdriver_extension(force_creation = false)
      ext_path = File.join(extensions_dir, EXTENSION_NAME)

      if File.exists?(ext_path)
        return unless force_creation
      end

      FileUtils.rm_rf ext_path
      FileUtils.mkdir_p File.dirname(ext_path), :mode => 0700
      FileUtils.cp_r @extension_source, ext_path

      from_to = XPTS + SHARED

      if native_events?
        case Platform.os
        when :linux
          NATIVE_LINUX.each do |lib|
            from_to << lib
          end
        when :windows
          from_to << NATIVE_WINDOWS
        else
          raise Error::WebDriverError, "can't enable native events on #{Platform.os.inspect}"
        end
      end

      if load_no_focus_lib?
        from_to += NO_FOCUS
        modify_link_library_path(NO_FOCUS.map { |source, dest| File.join(ext_path, File.dirname(dest)) })
      end

      from_to.each do |source, destination|
        dest = File.join(ext_path, destination)
        FileUtils.mkdir_p File.dirname(dest)
        FileUtils.cp source, dest
      end

      delete_extensions_cache
    end

assume_untrusted_certificate_issuer=(bool) click to toggle source

    # File firefox/src/rb/lib/selenium/webdriver/firefox/profile.rb, line 214
    def assume_untrusted_certificate_issuer=(bool)
      @untrusted_issuer = bool
    end

assume_untrusted_certificate_issuer?() click to toggle source

    # File firefox/src/rb/lib/selenium/webdriver/firefox/profile.rb, line 210
    def assume_untrusted_certificate_issuer?
      @untrusted_issuer == true
    end

delete_extensions_cache() click to toggle source

    # File firefox/src/rb/lib/selenium/webdriver/firefox/profile.rb, line 182
    def delete_extensions_cache
      cache = File.join(directory, "extensions.cache")
      FileUtils.rm_f cache if File.exist?(cache)
    end

extensions_dir() click to toggle source

TODO: add_extension

    # File firefox/src/rb/lib/selenium/webdriver/firefox/profile.rb, line 174
    def extensions_dir
      @extensions_dir ||= File.join(directory, "extensions")
    end

load_no_focus_lib?() click to toggle source

    # File firefox/src/rb/lib/selenium/webdriver/firefox/profile.rb, line 202
    def load_no_focus_lib?
      @load_no_focus_lib == true
    end

modify_link_library_path(paths) click to toggle source

    # File firefox/src/rb/lib/selenium/webdriver/firefox/profile.rb, line 187
    def modify_link_library_path(paths)
      old_path = ENV['LD_LIBRARY_PATH']

      unless [nil, ''].include?(old_path)
        paths << old_path
      end

      ENV['LD_LIBRARY_PATH'] = paths.join(File::PATH_SEPARATOR)
      ENV['LD_PRELOAD']      = NO_FOCUS_LIBRARY_NAME
    end

native_events?() click to toggle source

    # File firefox/src/rb/lib/selenium/webdriver/firefox/profile.rb, line 198
    def native_events?
      @native_events == true
    end

secure_ssl?() click to toggle source

    # File firefox/src/rb/lib/selenium/webdriver/firefox/profile.rb, line 206
    def secure_ssl?
      @secure_ssl == true
    end

update_user_prefs() click to toggle source

    # File firefox/src/rb/lib/selenium/webdriver/firefox/profile.rb, line 114
    def update_user_prefs
      prefs = current_user_prefs

      prefs.merge! OVERRIDABLE_PREFERENCES
      prefs.merge! @additional_prefs
      prefs.merge! DEFAULT_PREFERENCES

      prefs['webdriver_firefox_port']            = @port
      prefs['webdriver_accept_untrusted_certs']  = !secure_ssl?
      prefs['webdriver_enable_native_events']    = native_events?
      prefs['webdriver_assume_untrusted_issuer'] = assume_untrusted_certificate_issuer?

      # If the user sets the home page, we should also start up there
      prefs["startup.homepage_welcome_url"] = prefs["browser.startup.homepage"]

      write_prefs prefs
    end

user_prefs_path() click to toggle source

    # File firefox/src/rb/lib/selenium/webdriver/firefox/profile.rb, line 178
    def user_prefs_path
      @user_prefs_path ||= File.join(directory, "user.js")
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.