2007年8月23日星期四

Watir 方法

Class Watir::IE
In: watir.rb
Parent: Object

Constants

REVISION = "$Revision: 1.211.2.2 $"
The revision number ( according to CVS )
VERSION = "1.4.1"
the Release number
READYSTATE_COMPLETE = 4
Used internally to determine when IE has finished loading a page
DEFAULT_TYPING_SPEED = 0.08
The default delay when entering text on a web page.
DEFAULT_SLEEP_TIME = 0.1
The default time we wait after a page has loaded.
DEFAULT_HIGHLIGHT_COLOR = "yellow"
The default color for highlighting objects as they are accessed.

Attributes

activeObjectHighLightColor [RW] The color we want to use for the active object. This can be any valid web-friendly color.
defaultSleepTime [RW] This is used to change how long after a page has finished loading that we wait for.
down_load_time [R] use this to get the time for the last page download
enable_spinner [RW] use this to switch the spinner on and off
ie [R] Use this to gain access to the ‘raw’ internet explorer object.
logger [RW] access to the logger object
newWindow [RW] When a new window is created it is stored in newWindow
typingspeed [RW] This is used to change the typing speed when entering text on a page.
url_list [R] this contains the list of unique urls that have been visited

Public Class methods

Attach to an existing IE window, either by url or title. IE.attach(:url, ‘www.google.com’) IE.attach(:title, ‘Google’)

Create a new IE Window, starting at the specified url. If no url is given, start empty.

Public Instance methods

this method is used to add an error checker that gets executed on every page load

  • checker Proc Object, that contains the code to be run

this method is used internally to attach to an existing window dont make private

Go to the previous page - the same as clicking the browsers back button an WIN32OLERuntimeError exception is raised if the browser cant go back

Make the window come to the front

This method checks the currently displayed page for http errors, 404, 500 etc It gets called internally by the wait method, so a user does not need to call it explicitly

clear the list of urls that we have visited

Closes the Browser

Search the current page for specified text or regexp. Returns true if the specified text was found. Returns matchdata object if the specified regexp was found.

 * text - string or regular expression - the string to look for

used by the popup code only

this allows a checker to be disabled

  • checker Proc Object, the checker that is to be disabled

Return the current document

This method gives focus to the frame It may be removed and become part of the frame object

Go to the next page - the same as clicking the browsers forward button an WIN32OLERuntimeError exception is raised if the browser cant go forward

Deprecated: Use IE#ie instead This method returns the Internet Explorer object. Methods, properties, etc. that the IE object does not support can be accessed.

Navigate to the specified URL.

 * url  - string - the URL to navigate to

The HTML of the current page

Maximize the window (expands to fill the screen)

Minimize the window (appears as icon on taskbar)

Refresh the current page - the same as clicking the browsers refresh button an WIN32OLERuntimeError exception is raised if the browser cant refresh

Restore the window (after minimizing or maximizing)

this method runs the predefined error checks

Send key events to IE window. See www.autoitscript.com/autoit3/docs/appendix/SendKeys.htm for complete documentation on keys supported and syntax.

deprecated: use logger= instead

this method shows the name, id etc of the object that is currently active - ie the element that has focus its mostly used in irb when creating a script

This method shows the available objects on the current page. This is usually only used for debugging or writing new test scripts. This is a nice feature to help find out what HTML objects are on a page when developing a test case using Watir.

this method shows all the divs availble in the document

Show all forms displays all the forms that are on a web page.

This method is used to display the available html frames that Internet Explorer currently has loaded. This method is usually only used for debugging test scripts.

this method shows all the images availble in the document

this method shows all the links availble in the document

this method shows all the spans availble in the document

this method is used to show all the tables that are available

Return the status of the window, typically from the status bar at the bottom.

The text of the current document

Return the title of the window

returns the current url, as displayed in the address bar of the browser

This method is used internally to cause an execution to stop until the page has loaded in Internet Explorer.

没有评论: