### Home Classes Methods

### In Files

- lib/selenium/webdriver/common/platform.rb

### Methods

- #assert_executable
- #assert_file
- #bitsize
- #cygwin?
- #cygwin_path
- #engine
- #exit_hook
- #find_binary
- #find_in_program_files
- #home
- #interfaces
- #ip
- #ironruby?
- #jruby?
- #linux?
- #localhost
- #mac?
- #make_writable
- #null_device
- #os
- #ruby187?
- #ruby19?
- #windows?
- #wrap_in_quotes_if_necessary

### Class/Module Index

Quicksearch

- Selenium
- Selenium::Client
- Selenium::Client::Base
- Selenium::Client::CommandError
- Selenium::Client::Driver
- Selenium::Client::Extensions
- Selenium::Client::GeneratedDriver
- Selenium::Client::Idiomatic
- Selenium::Client::JavascriptExpressionBuilder
- Selenium::Client::JavascriptFrameworks
- Selenium::Client::JavascriptFrameworks::JQuery
- Selenium::Client::JavascriptFrameworks::Prototype
- Selenium::Client::Protocol
- Selenium::Client::ProtocolError
- Selenium::Client::SeleniumHelper
- Selenium::Rake
- Selenium::Rake::MissingJarFileError
- Selenium::Rake::ServerTask
- Selenium::Server
- Selenium::Server::Error
- Selenium::WebDriver
- Selenium::WebDriver::ActionBuilder
- Selenium::WebDriver::Alert
- Selenium::WebDriver::Android
- Selenium::WebDriver::Android::Bridge
- Selenium::WebDriver::BridgeHelper
- Selenium::WebDriver::Chrome
- Selenium::WebDriver::Chrome::Bridge
- Selenium::WebDriver::Chrome::Profile
- Selenium::WebDriver::Chrome::Service
- Selenium::WebDriver::Driver
- Selenium::WebDriver::DriverExtensions
- Selenium::WebDriver::DriverExtensions::HasBrowserConnection
- Selenium::WebDriver::DriverExtensions::HasInputDevices
- Selenium::WebDriver::DriverExtensions::HasLocation
- Selenium::WebDriver::DriverExtensions::HasSessionId
- Selenium::WebDriver::DriverExtensions::HasTouchScreen
- Selenium::WebDriver::DriverExtensions::HasWebStorage
- Selenium::WebDriver::DriverExtensions::Rotatable
- Selenium::WebDriver::DriverExtensions::TakesScreenshot
- Selenium::WebDriver::DriverExtensions::UploadsFiles
- Selenium::WebDriver::Element
- Selenium::WebDriver::Error
- Selenium::WebDriver::Error::ElementNotDisplayedError
- Selenium::WebDriver::Error::ElementNotSelectableError
- Selenium::WebDriver::Error::ElementNotVisibleError
- Selenium::WebDriver::Error::ExpectedError
- Selenium::WebDriver::Error::IMEEngineActivationFailedError
- Selenium::WebDriver::Error::IMENotAvailableError
- Selenium::WebDriver::Error::IndexOutOfBoundsError
- Selenium::WebDriver::Error::InvalidCookieDomainError
- Selenium::WebDriver::Error::InvalidElementCoordinatesError
- Selenium::WebDriver::Error::InvalidElementStateError
- Selenium::WebDriver::Error::InvalidSelectorError
- Selenium::WebDriver::Error::JavascriptError
- Selenium::WebDriver::Error::MoveTargetOutOfBoundsError
- Selenium::WebDriver::Error::NoAlertOpenError
- Selenium::WebDriver::Error::NoAlertPresentError
- 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::ScriptTimeOutError
- Selenium::WebDriver::Error::ServerError
- Selenium::WebDriver::Error::StaleElementReferenceError
- Selenium::WebDriver::Error::TimeOutError
- Selenium::WebDriver::Error::UnableToSetCookieError
- Selenium::WebDriver::Error::UnexpectedJavascriptError
- Selenium::WebDriver::Error::UnhandledAlertError
- Selenium::WebDriver::Error::UnhandledError
- Selenium::WebDriver::Error::UnknownCommandError
- Selenium::WebDriver::Error::UnknownError
- Selenium::WebDriver::Error::UnsupportedOperationError
- Selenium::WebDriver::Error::WebDriverError
- Selenium::WebDriver::Error::XPathLookupError
- Selenium::WebDriver::FileReaper
- Selenium::WebDriver::Firefox
- Selenium::WebDriver::Firefox::Binary
- Selenium::WebDriver::Firefox::Bridge
- Selenium::WebDriver::Firefox::Extension
- Selenium::WebDriver::Firefox::Launcher
- Selenium::WebDriver::Firefox::Profile
- Selenium::WebDriver::Firefox::ProfilesIni
- Selenium::WebDriver::Firefox::SocketLock
- Selenium::WebDriver::Firefox::Util
- Selenium::WebDriver::HTML5
- Selenium::WebDriver::HTML5::LocalStorage
- Selenium::WebDriver::HTML5::SessionStorage
- Selenium::WebDriver::HTML5::SharedWebStorage
- Selenium::WebDriver::IE
- Selenium::WebDriver::IE::Bridge
- Selenium::WebDriver::IE::Server
- Selenium::WebDriver::IPhone
- Selenium::WebDriver::IPhone::Bridge
- Selenium::WebDriver::JsonHelper
- Selenium::WebDriver::Keyboard
- Selenium::WebDriver::Keys
- Selenium::WebDriver::LogEntry
- Selenium::WebDriver::Mouse
- Selenium::WebDriver::Navigation
- Selenium::WebDriver::Opera
- Selenium::WebDriver::Opera::Bridge
- Selenium::WebDriver::Opera::Service
- Selenium::WebDriver::Options
- Selenium::WebDriver::PhantomJS
- Selenium::WebDriver::PhantomJS::Bridge
- Selenium::WebDriver::PhantomJS::Service
- Selenium::WebDriver::Platform
- Selenium::WebDriver::PortProber
- Selenium::WebDriver::ProfileHelper
- Selenium::WebDriver::ProfileHelper::ClassMethods
- Selenium::WebDriver::Proxy
- 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::Http::Persistent
- Selenium::WebDriver::Remote::Response
- Selenium::WebDriver::Safari
- Selenium::WebDriver::Safari::Bridge
- Selenium::WebDriver::Safari::Browser
- Selenium::WebDriver::Safari::Extension
- Selenium::WebDriver::Safari::Server
- Selenium::WebDriver::SearchContext
- Selenium::WebDriver::SocketPoller
- Selenium::WebDriver::Support
- Selenium::WebDriver::Support::AbstractEventListener
- Selenium::WebDriver::Support::BlockEventListener
- Selenium::WebDriver::Support::Color
- Selenium::WebDriver::Support::EventFiringBridge
- Selenium::WebDriver::Support::Select
- Selenium::WebDriver::Support::Select::Escaper
- Selenium::WebDriver::TargetLocator
- Selenium::WebDriver::Timeouts
- Selenium::WebDriver::TouchActionBuilder
- Selenium::WebDriver::TouchScreen
- Selenium::WebDriver::Wait
- Selenium::WebDriver::Window
- Selenium::WebDriver::Zipper
- Base64
- Dir
- SocketError
- String

No matching classes.

# Selenium::WebDriver::Platform

@api private

### Public Instance Methods

assert_executable(path) click to toggle source

    # File lib/selenium/webdriver/common/platform.rb, line 122
    def assert_executable(path)
      assert_file(path)

      unless File.executable? path
        raise Error::WebDriverError, "not executable: #{path.inspect}"
      end
    end

assert_file(path) click to toggle source

    # File lib/selenium/webdriver/common/platform.rb, line 116
    def assert_file(path)
      unless File.file? path
        raise Error::WebDriverError, "not a file: #{path.inspect}"
      end
    end

bitsize() click to toggle source

    # File lib/selenium/webdriver/common/platform.rb, line 45
    def bitsize
      @bitsize ||= (
        if defined?(FFI::Platform::ADDRESS_SIZE)
          FFI::Platform::ADDRESS_SIZE
        elsif defined?(FFI)
          FFI.type_size(:pointer) == 4 ? 32 : 64
        elsif jruby?
          Integer(ENV_JAVA['sun.arch.data.model'])
        else
          1.size == 4 ? 32 : 64
        end
      )
    end

cygwin?() click to toggle source

    # File lib/selenium/webdriver/common/platform.rb, line 87
    def cygwin?
      !!(RUBY_PLATFORM =~ /cygwin/)
    end

cygwin_path(path, opts = {}) click to toggle source

    # File lib/selenium/webdriver/common/platform.rb, line 105
    def cygwin_path(path, opts = {})
      flags = []
      opts.each { |k,v| flags << "--#{k}" if v }

      `cygpath #{flags.join ' '} "#{path}"`.strip
    end

engine() click to toggle source

    # File lib/selenium/webdriver/common/platform.rb, line 17
    def engine
      @engine ||= (
        if defined? RUBY_ENGINE
          RUBY_ENGINE.to_sym
        else
          :ruby
        end
      )
    end

exit_hook(&blk) click to toggle source

    # File lib/selenium/webdriver/common/platform.rb, line 130
    def exit_hook(&blk)
      pid = Process.pid

      at_exit do
        yield if Process.pid == pid
      end
    end

find_binary(*binary_names) click to toggle source

    # File lib/selenium/webdriver/common/platform.rb, line 138
    def find_binary(*binary_names)
      paths = ENV['PATH'].split(File::PATH_SEPARATOR)
      binary_names.map! { |n| "#{n}.exe" } if windows?

      binary_names.each do |binary_name|
        paths.each do |path|
          exe = File.join(path, binary_name)
          return exe if File.executable?(exe)
        end
      end

      nil
    end

find_in_program_files(*binary_names) click to toggle source

    # File lib/selenium/webdriver/common/platform.rb, line 152
    def find_in_program_files(*binary_names)
      paths = [
        ENV['PROGRAMFILES'] || "\\Program Files",
        ENV['ProgramFiles(x86)'] || "\\Program Files (x86)"
      ]

      paths.each do |root|
        binary_names.each do |name|
          exe = File.join(root, name)
          return exe if File.executable?(exe)
        end
      end

      nil
    end

home() click to toggle source

    # File lib/selenium/webdriver/common/platform.rb, line 12
    def home
      # jruby has an issue with ENV['HOME'] on Windows
      @home ||= jruby? ? ENV_JAVA['user.home'] : ENV['HOME']
    end

interfaces() click to toggle source

    # File lib/selenium/webdriver/common/platform.rb, line 194
    def interfaces
      interfaces = Socket.getaddrinfo("localhost", 8080).map { |e| e[3] }
      interfaces += ["0.0.0.0", Platform.ip]

      interfaces.compact.uniq
    end

ip() click to toggle source

    # File lib/selenium/webdriver/common/platform.rb, line 178
    def ip
      orig = Socket.do_not_reverse_lookup
      Socket.do_not_reverse_lookup = true

      begin
        UDPSocket.open do |s|
          s.connect '8.8.8.8', 53
          return s.addr.last
        end
      ensure
        Socket.do_not_reverse_lookup = orig
      end
    rescue Errno::ENETUNREACH, Errno::EHOSTUNREACH
      # no external ip
    end

ironruby?() click to toggle source

    # File lib/selenium/webdriver/common/platform.rb, line 63
    def ironruby?
      engine == :ironruby
    end

jruby?() click to toggle source

    # File lib/selenium/webdriver/common/platform.rb, line 59
    def jruby?
      engine == :jruby
    end

linux?() click to toggle source

    # File lib/selenium/webdriver/common/platform.rb, line 83
    def linux?
      os == :linux
    end

localhost() click to toggle source

    # File lib/selenium/webdriver/common/platform.rb, line 168
    def localhost
      info = Socket.getaddrinfo "localhost", 80, Socket::AF_INET, Socket::SOCK_STREAM

      if info.empty?
        raise Error::WebDriverError, "unable to translate 'localhost' for TCP + IPv4"
      end

      info[0][3]
    end

mac?() click to toggle source

    # File lib/selenium/webdriver/common/platform.rb, line 79
    def mac?
      os == :macosx
    end

make_writable(file) click to toggle source

    # File lib/selenium/webdriver/common/platform.rb, line 112
    def make_writable(file)
      File.chmod 0766, file
    end

null_device() click to toggle source

    # File lib/selenium/webdriver/common/platform.rb, line 91
    def null_device
      @null_device ||= (
        if defined?(File::NULL)
          File::NULL
        else
          Platform.windows? ? 'NUL' : '/dev/null'
        end
      )
    end

os() click to toggle source

    # File lib/selenium/webdriver/common/platform.rb, line 27
    def os
      @os ||= (
        host_os = RbConfig::CONFIG['host_os']
        case host_os
        when /mswin|msys|mingw|cygwin|bccwin|wince|emc/
          :windows
        when /darwin|mac os/
          :macosx
        when /linux/
          :linux
        when /solaris|bsd/
          :unix
        else
          raise Error::WebDriverError, "unknown os: #{host_os.inspect}"
        end
      )
    end

ruby187?() click to toggle source

    # File lib/selenium/webdriver/common/platform.rb, line 67
    def ruby187?
      !!(RUBY_VERSION =~ /^1\.8\.7/)
    end

ruby19?() click to toggle source

    # File lib/selenium/webdriver/common/platform.rb, line 71
    def ruby19?
      !!(RUBY_VERSION =~ /^1\.9/)
    end

windows?() click to toggle source

    # File lib/selenium/webdriver/common/platform.rb, line 75
    def windows?
      os == :windows
    end

wrap_in_quotes_if_necessary(str) click to toggle source

    # File lib/selenium/webdriver/common/platform.rb, line 101
    def wrap_in_quotes_if_necessary(str)
      windows? && !cygwin? ? %{"#{str}"} : str
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.