Class Selenium::WebDriver::Driver
In: lib/selenium/webdriver/common/driver.rb
Parent: Object

The main class through which you control the browser.

@see SearchContext @see Navigation @see TargetLocator @see Options

Methods

Included Modules

SearchContext

External Aliases

find_element -> first
  driver.first(:id, ‘foo’)
find_elements -> all
  driver.all(:class, ‘bar’) #=> [#<WebDriver::Element:0x1011c3b88, …]

Public Class methods

A new Driver instance with the given bridge. End users should use Selenium::WebDriver.for instead of using this directly.

@api private

Public Instance methods

Get the first element matching the given selector. If given a String or Symbol, it will be used as the id of the element.

@param [String,Hash] id or selector @return [WebDriver::Element]

Examples:

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

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

Get the URL of the current page

@return [String]

Execute an asynchronous piece of JavaScript in the context of the currently selected frame or window. Unlike executing execute_script (synchronous JavaScript), scripts executed with this method must explicitly signal they are finished by invoking the provided callback. This callback is always injected into the executed function as the last argument.

@param [String] script

  JavaSCript source to execute

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

  Arguments to the script. May be empty.

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

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 in the 'arguments' pseudo-array.

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

  The value returned from the script.

Opens the specified URL in the browser.

@return [Options] @see Options

Get the source of the current page

@return [String]

Quit the browser

@api private @see SearchContext

script(script, *args)

Get the title of the current page

@return [String]

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

@param [Boolean]

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

@return [Boolean]

Get the current window handle

@return [String]

Get the window handles of open browser windows.

@return [Array] @see TargetLocator#window

[Validate]