### Home Classes Methods

### In Files

- common/src/rb/lib/selenium/webdriver/driver.rb

### Parent

Object

### Methods

- ::for
- ::new
- #[]
- #close
- #current_url
- #execute_script
- #get
- #inspect
- #manage
- #navigate
- #page_source
- #quit
- #ref
- #script
- #switch_to
- #title
- #visible=
- #visible?
- #window_handle
- #window_handles

### Included Modules

- Selenium::WebDriver::Find

### 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::Driver

The main class through which you control the browser.

@see Find @see Navigation @see TargetLocator @see Options

### Attributes

bridge[R]

### Public Class Methods

for(browser, *args) click to toggle source

Create a new Driver instance with the correct bridge for the given browser

@param browser [:ie, :internet_explorer, :remote, :chrome, :firefox, :ff]

    the driver type to use

@param *rest

    arguments passed to Bridge.new

@return [Driver]

@example

    Driver.for :firefox, :profile => "some-profile"
    Driver.for :firefox, :profile => Profile.new
    Driver.for :remote,  :url => "http://localhost:4444/wd/hub", :desired_capabilities => caps

    # File common/src/rb/lib/selenium/webdriver/driver.rb, line 37
    def for(browser, *args)
      bridge = case browser
               when :ie, :internet_explorer
                 IE::Bridge.new(*args)
               when :remote
                 Remote::Bridge.new(*args)
               when :chrome
                 Chrome::Bridge.new(*args)
               when :firefox, :ff
                 Firefox::Bridge.new(*args)
               else
                 raise ArgumentError, "unknown driver: #{browser.inspect}"
               end

       new(bridge)
    end

new(bridge) click to toggle source

A new Driver instance with the given bridge

@api private

    # File common/src/rb/lib/selenium/webdriver/driver.rb, line 61
    def initialize(bridge)
      @bridge = bridge

      # TODO: refactor this away
      unless @bridge.driver_extensions.empty?
        extend(*@bridge.driver_extensions)
      end
    end

### Public Instance Methods

[](id) click to toggle source

Get the first element matching the given id.

@param [String] id @return [WebDriver::Element]

    driver['someElementId'] #=> #<WebDriver::Element:0x1011c3b88>

    # File common/src/rb/lib/selenium/webdriver/driver.rb, line 240
    def [](id)
      find_element :id, id
    end

close() click to toggle source

Close the current window, or the browser if no windows are left.

    # File common/src/rb/lib/selenium/webdriver/driver.rb, line 171
    def close
      bridge.close
    end

current_url() click to toggle source

Get the URL of the current page

@return [String]

    # File common/src/rb/lib/selenium/webdriver/driver.rb, line 115
    def current_url
      bridge.getCurrentUrl
    end

execute_script(script, *args) click to toggle source

Execute the given JavaScript

@param [String] script

    JavaScript source to execute

@param [WebDriver::Element,Integer, Float, Boolean, NilClass, String, Array] *args

    Arguments will be available in the given script as the 'arguments' array.

@return [WebDriver::Element,Integer,Float,Boolean,NilClass,String,Array]

    The value returned from the script.

    # File common/src/rb/lib/selenium/webdriver/driver.rb, line 208
    def execute_script(script, *args)
      bridge.executeScript(script, *args)
    end

Also aliased as: script
get(url) click to toggle source

Opens the specified URL in the browser.

    # File common/src/rb/lib/selenium/webdriver/driver.rb, line 105
    def get(url)
      navigate.to(url)
    end

inspect() click to toggle source

    # File common/src/rb/lib/selenium/webdriver/driver.rb, line 70
    def inspect
      '#<%s:0x%x browser=%s>' % [self.class, hash*2, bridge.browser.inspect]
    end

manage() click to toggle source

@return [Options] @see Options

    # File common/src/rb/lib/selenium/webdriver/driver.rb, line 97
    def manage
      @manage ||= WebDriver::Options.new(self)
    end

navigate() click to toggle source

@return [Navigation] @see Navigation

    # File common/src/rb/lib/selenium/webdriver/driver.rb, line 79
    def navigate
      @navigate ||= WebDriver::Navigation.new(self)
    end

page_source() click to toggle source

Get the source of the current page

@return [String]

    # File common/src/rb/lib/selenium/webdriver/driver.rb, line 135
    def page_source
      bridge.getPageSource
    end

quit() click to toggle source

Quit the browser

    # File common/src/rb/lib/selenium/webdriver/driver.rb, line 163
    def quit
      bridge.quit
    end

ref() click to toggle source

for Find

@private

    # File common/src/rb/lib/selenium/webdriver/driver.rb, line 251
    def ref
      nil
    end

script(script, *args) click to toggle source

driver.script(‘function() { … };’)

Alias for: execute_script
switch_to() click to toggle source

@return [TargetLocator] @see TargetLocator

    # File common/src/rb/lib/selenium/webdriver/driver.rb, line 88
    def switch_to
      @switch_to ||= WebDriver::TargetLocator.new(self)
    end

title() click to toggle source

Get the title of the current page

@return [String]

    # File common/src/rb/lib/selenium/webdriver/driver.rb, line 125
    def title
      bridge.getTitle
    end

visible=(bool) click to toggle source

Set the visibility of the browser. Not applicable for all browsers.

@param [Boolean]

    # File common/src/rb/lib/selenium/webdriver/driver.rb, line 155
    def visible=(bool)
      bridge.setBrowserVisible bool
    end

visible?() click to toggle source

Get the visibility of the browser. Not applicable for all browsers.

@return [Boolean]

    # File common/src/rb/lib/selenium/webdriver/driver.rb, line 145
    def visible?
      bridge.getBrowserVisible
    end

window_handle() click to toggle source

Get the current window handle

@return [String]

    # File common/src/rb/lib/selenium/webdriver/driver.rb, line 192
    def window_handle
      bridge.getCurrentWindowHandle
    end

window_handles() click to toggle source

Get the window handles of open browser windows.

@return [Array] @see TargetLocator#window

    # File common/src/rb/lib/selenium/webdriver/driver.rb, line 182
    def window_handles
      bridge.getWindowHandles
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.