标签:
The WebDriver implementation.
Bases: object
Controls a browser by sending commands to a remote server. This server is expected to be running the WebDriver wire protocol as defined here: http://code.google.com/p/selenium/wiki/JsonWireProtocol
Attributes: |
|
---|
Adds a cookie to your current session.
Args: |
|
---|
Goes one step backward in the browser history.
Usage: | driver.back() |
---|
Closes the current window.
Usage: | driver.close() |
---|
Creates a web element with the specified element_id.
Delete all cookies in the scope of the session.
Usage: | driver.delete_all_cookies() |
---|
Deletes a single cookie with the given name.
Usage: | driver.delete_cookie(‘my_cookie’) |
---|
Sends a command to be executed by a command.CommandExecutor.
Args: |
|
---|---|
Returns: |
The command’s JSON response loaded into a dictionary object. |
Asynchronously Executes JavaScript in the current window/frame.
Args: |
|
---|---|
Usage: |
driver.execute_async_script(‘document.title’) |
Synchronously Executes JavaScript in the current window/frame.
Args: |
|
---|---|
Usage: |
driver.execute_script(‘document.title’) |
‘Private’ method used by the find_element_by_* methods.
Usage: | Use the corresponding find_element_by_* instead of this. |
---|---|
Return type: | WebElement |
Finds an element by class name.
Args: |
|
---|---|
Usage: |
driver.find_element_by_class_name(‘foo’) |
Finds an element by css selector.
Args: |
|
---|---|
Usage: |
driver.find_element_by_css_selector(‘#foo’) |
Finds an element by id.
Args: |
|
---|---|
Usage: |
driver.find_element_by_id(‘foo’) |
Finds an element by link text.
Args: |
|
---|---|
Usage: |
driver.find_element_by_link_text(‘Sign In’) |
Finds an element by name.
Args: |
|
---|---|
Usage: |
driver.find_element_by_name(‘foo’) |
Finds an element by a partial match of its link text.
Args: |
|
---|---|
Usage: |
driver.find_element_by_partial_link_text(‘Sign’) |
Finds an element by tag name.
Args: |
|
---|---|
Usage: |
driver.find_element_by_tag_name(‘foo’) |
Finds an element by xpath.
Args: |
|
---|---|
Usage: |
driver.find_element_by_xpath(‘//div/td[1]’) |
‘Private’ method used by the find_elements_by_* methods.
Usage: | Use the corresponding find_elements_by_* instead of this. |
---|---|
Return type: | list of WebElement |
Finds elements by class name.
Args: |
|
---|---|
Usage: |
driver.find_elements_by_class_name(‘foo’) |
Finds elements by css selector.
Args: |
|
---|---|
Usage: |
driver.find_elements_by_css_selector(‘.foo’) |
Finds multiple elements by id.
Args: |
|
---|---|
Usage: |
driver.find_element_by_id(‘foo’) |
Finds elements by link text.
Args: |
|
---|---|
Usage: |
driver.find_elements_by_link_text(‘Sign In’) |
Finds elements by name.
Args: |
|
---|---|
Usage: |
driver.find_elements_by_name(‘foo’) |
Finds elements by a partial match of their link text.
Args: |
|
---|---|
Usage: |
driver.find_element_by_partial_link_text(‘Sign’) |
Finds elements by tag name.
Args: |
|
---|---|
Usage: |
driver.find_elements_by_tag_name(‘foo’) |
Finds multiple elements by xpath.
Args: |
|
---|---|
Usage: |
driver.find_elements_by_xpath(“//div[contains(@class, ‘foo’)]”) |
Goes one step forward in the browser history.
Usage: | driver.forward() |
---|
Loads a web page in the current browser session.
Get a single cookie by name. Returns the cookie if found, None if not.
Usage: | driver.get_cookie(‘my_cookie’) |
---|
Returns a set of dictionaries, corresponding to cookies visible in the current session.
Usage: | driver.get_cookies() |
---|
Gets the log for a given log type
Args: |
|
---|---|
Usage: |
driver.get_log(‘browser’) driver.get_log(‘driver’) driver.get_log(‘client’) driver.get_log(‘server’) |
Usage: | driver.get_screenshot_as_base64() |
---|
Args: |
|
---|---|
Usage: |
driver.get_screenshot_as_file(‘/Screenshots/foo.png’) |
Gets the screenshot of the current window as a binary data.
Usage: | driver.get_screenshot_as_png() |
---|
Gets the x,y position of the current window.
Usage: | driver.get_window_position() |
---|
Gets the width and height of the current window.
Usage: | driver.get_window_size() |
---|
Args: |
|
---|---|
Usage: |
driver.implicitly_wait(30) |
Maximizes the current window that webdriver is using
Quits the driver and closes every associated window.
Usage: | driver.quit() |
---|
Refreshes the current page.
Usage: | driver.refresh() |
---|
Args: |
|
---|---|
Usage: |
driver.get_screenshot_as_file(‘/Screenshots/foo.png’) |
Args: |
|
---|---|
Usage: |
driver.set_page_load_timeout(30) |
Args: |
|
---|---|
Usage: |
driver.set_script_timeout(30) |
Sets the x,y position of the current window. (window.moveTo)
Args: |
|
---|---|
Usage: |
driver.set_window_position(0,0) |
Sets the width and height of the current window. (window.resizeTo)
Args: |
|
---|---|
Usage: |
driver.set_window_size(800,600) |
Called before starting a new session. This method may be overridden to define custom startup behavior.
Creates a new session with the desired capabilities.
Args: |
|
---|
Called after executing a quit command. This method may be overridden to define custom shutdown behavior.
Deprecated use driver.switch_to.active_element
Deprecated use driver.switch_to.alert
Deprecated use driver.switch_to.default_content
Deprecated use driver.switch_to.frame
Deprecated use driver.switch_to.window
Returns a ApplicationCache Object to interact with the browser app cache
Gets the URL of the current page.
Usage: | driver.current_url |
---|
Returns the handle of the current window.
Usage: | driver.current_window_handle |
---|
returns the drivers current desired capabilities being used
Gets a list of the available log types
Usage: | driver.log_types |
---|
Returns the name of the underlying browser for this instance.
Usage: |
|
---|
Gets the current orientation of the device
Usage: | orientation = driver.orientation |
---|
Gets the source of the current page.
Usage: | driver.page_source |
---|
Returns the title of the current page.
Usage: | driver.title |
---|
Returns the handles of all windows within the current session.
Usage: | driver.window_handles |
---|
webDriver API——第11部分Remote WebDriver
标签:
原文地址:http://www.cnblogs.com/hushaojun/p/4467660.html