selenium.py
Go to the documentation of this file.
00001 
00002 """
00003 Copyright 2006 ThoughtWorks, Inc.
00004 
00005 Licensed under the Apache License, Version 2.0 (the "License");
00006 you may not use this file except in compliance with the License.
00007 You may obtain a copy of the License at
00008 
00009     http://www.apache.org/licenses/LICENSE-2.0
00010 
00011 Unless required by applicable law or agreed to in writing, software
00012 distributed under the License is distributed on an "AS IS" BASIS,
00013 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014 See the License for the specific language governing permissions and
00015 limitations under the License.
00016 """
00017 __docformat__ = "restructuredtext en"
00018 
00019 # This file has been automatically generated via XSL
00020 
00021 import httplib
00022 import urllib
00023 import re
00024 
00025 class selenium:
00026     """
00027     Defines an object that runs Selenium commands.
00028     
00029     Element Locators
00030     ~~~~~~~~~~~~~~~~
00031     
00032     Element Locators tell Selenium which HTML element a command refers to.
00033     The format of a locator is:
00034     
00035     \ *locatorType*\ **=**\ \ *argument*
00036     
00037     
00038     We support the following strategies for locating elements:
00039     
00040     
00041     *   \ **identifier**\ =\ *id*: 
00042         Select the element with the specified @id attribute. If no match is
00043         found, select the first element whose @name attribute is \ *id*.
00044         (This is normally the default; see below.)
00045     *   \ **id**\ =\ *id*:
00046         Select the element with the specified @id attribute.
00047     *   \ **name**\ =\ *name*:
00048         Select the first element with the specified @name attribute.
00049         
00050         *   username
00051         *   name=username
00052         
00053         
00054         The name may optionally be followed by one or more \ *element-filters*, separated from the name by whitespace.  If the \ *filterType* is not specified, \ **value**\  is assumed.
00055         
00056         *   name=flavour value=chocolate
00057         
00058         
00059     *   \ **dom**\ =\ *javascriptExpression*: 
00060         
00061         Find an element by evaluating the specified string.  This allows you to traverse the HTML Document Object
00062         Model using JavaScript.  Note that you must not return a value in this string; simply make it the last expression in the block.
00063         
00064         *   dom=document.forms['myForm'].myDropdown
00065         *   dom=document.images[56]
00066         *   dom=function foo() { return document.links[1]; }; foo();
00067         
00068         
00069     *   \ **xpath**\ =\ *xpathExpression*: 
00070         Locate an element using an XPath expression.
00071         
00072         *   xpath=//img[@alt='The image alt text']
00073         *   xpath=//table[@id='table1']//tr[4]/td[2]
00074         *   xpath=//a[contains(@href,'#id1')]
00075         *   xpath=//a[contains(@href,'#id1')]/@class
00076         *   xpath=(//table[@class='stylee'])//th[text()='theHeaderText']/../td
00077         *   xpath=//input[@name='name2' and @value='yes']
00078         *   xpath=//\*[text()="right"]
00079         
00080         
00081     *   \ **link**\ =\ *textPattern*:
00082         Select the link (anchor) element which contains text matching the
00083         specified \ *pattern*.
00084         
00085         *   link=The link text
00086         
00087         
00088     *   \ **css**\ =\ *cssSelectorSyntax*:
00089         Select the element using css selectors. Please refer to CSS2 selectors, CSS3 selectors for more information. You can also check the TestCssLocators test in the selenium test suite for an example of usage, which is included in the downloaded selenium core package.
00090         
00091         *   css=a[href="#id3"]
00092         *   css=span#firstChild + span
00093         
00094         
00095         Currently the css selector locator supports all css1, css2 and css3 selectors except namespace in css3, some pseudo classes(:nth-of-type, :nth-last-of-type, :first-of-type, :last-of-type, :only-of-type, :visited, :hover, :active, :focus, :indeterminate) and pseudo elements(::first-line, ::first-letter, ::selection, ::before, ::after). 
00096         
00097     
00098     
00099     
00100     Without an explicit locator prefix, Selenium uses the following default
00101     strategies:
00102     
00103     
00104     *   \ **dom**\ , for locators starting with "document."
00105     *   \ **xpath**\ , for locators starting with "//"
00106     *   \ **identifier**\ , otherwise
00107     
00108     Element Filters
00109     ~~~~~~~~~~~~~~~
00110     
00111     Element filters can be used with a locator to refine a list of candidate elements.  They are currently used only in the 'name' element-locator.
00112     
00113     Filters look much like locators, ie.
00114     
00115     \ *filterType*\ **=**\ \ *argument*
00116     
00117     Supported element-filters are:
00118     
00119     \ **value=**\ \ *valuePattern*
00120     
00121     
00122     Matches elements based on their values.  This is particularly useful for refining a list of similarly-named toggle-buttons.
00123     
00124     \ **index=**\ \ *index*
00125     
00126     
00127     Selects a single element based on its position in the list (offset from zero).
00128     
00129     String-match Patterns
00130     ~~~~~~~~~~~~~~~~~~~~~
00131     
00132     Various Pattern syntaxes are available for matching string values:
00133     
00134     
00135     *   \ **glob:**\ \ *pattern*:
00136         Match a string against a "glob" (aka "wildmat") pattern. "Glob" is a
00137         kind of limited regular-expression syntax typically used in command-line
00138         shells. In a glob pattern, "\*" represents any sequence of characters, and "?"
00139         represents any single character. Glob patterns match against the entire
00140         string.
00141     *   \ **regexp:**\ \ *regexp*:
00142         Match a string using a regular-expression. The full power of JavaScript
00143         regular-expressions is available.
00144     *   \ **regexpi:**\ \ *regexpi*:
00145         Match a string using a case-insensitive regular-expression.
00146     *   \ **exact:**\ \ *string*:
00147         
00148         Match a string exactly, verbatim, without any of that fancy wildcard
00149         stuff.
00150     
00151     
00152     
00153     If no pattern prefix is specified, Selenium assumes that it's a "glob"
00154     pattern.
00155     
00156     
00157     
00158     For commands that return multiple values (such as verifySelectOptions),
00159     the string being matched is a comma-separated list of the return values,
00160     where both commas and backslashes in the values are backslash-escaped.
00161     When providing a pattern, the optional matching syntax (i.e. glob,
00162     regexp, etc.) is specified once, as usual, at the beginning of the
00163     pattern.
00164     
00165     
00166     """
00167 
00168 ### This part is hard-coded in the XSL
00169     def __init__(self, host, port, browserStartCommand, browserURL):
00170         self.host = host
00171         self.port = port
00172         self.browserStartCommand = browserStartCommand
00173         self.browserURL = browserURL
00174         self.sessionId = None
00175 
00176     def start(self):
00177         result = self.get_string("getNewBrowserSession", [self.browserStartCommand, self.browserURL])
00178         try:
00179             self.sessionId = result
00180         except ValueError:
00181             raise Exception, result
00182         
00183     def stop(self):
00184         self.do_command("testComplete", [])
00185         self.sessionId = None
00186 
00187     def do_command(self, verb, args):
00188         conn = httplib.HTTPConnection(self.host, self.port)
00189         commandString = u'/selenium-server/driver/?cmd=' + urllib.quote_plus(unicode(verb).encode('utf-8'))
00190         for i in range(len(args)):
00191             commandString = commandString + '&' + unicode(i+1) + '=' + urllib.quote_plus(unicode(args[i]).encode('utf-8'))
00192         if (None != self.sessionId):
00193             commandString = commandString + "&sessionId=" + unicode(self.sessionId)
00194         conn.request("GET", commandString)
00195     
00196         response = conn.getresponse()
00197         #print response.status, response.reason
00198         data = unicode(response.read(), "UTF-8")
00199         result = response.reason
00200         #print "Selenium Result: " + repr(data) + "\n\n"
00201         if (not data.startswith('OK')):
00202             raise Exception, data
00203         return data
00204     
00205     def get_string(self, verb, args):
00206         result = self.do_command(verb, args)
00207         return result[3:]
00208     
00209     def get_string_array(self, verb, args):
00210         csv = self.get_string(verb, args)
00211         token = ""
00212         tokens = []
00213         escape = False
00214         for i in range(len(csv)):
00215             letter = csv[i]
00216             if (escape):
00217                 token = token + letter
00218                 escape = False
00219                 continue
00220             if (letter == '\\'):
00221                 escape = True
00222             elif (letter == ','):
00223                 tokens.append(token)
00224                 token = ""
00225             else:
00226                 token = token + letter
00227         tokens.append(token)
00228         return tokens
00229 
00230     def get_number(self, verb, args):
00231         # Is there something I need to do here?
00232         return self.get_string(verb, args)
00233     
00234     def get_number_array(self, verb, args):
00235         # Is there something I need to do here?
00236         return self.get_string_array(verb, args)
00237 
00238     def get_boolean(self, verb, args):
00239         boolstr = self.get_string(verb, args)
00240         if ("true" == boolstr):
00241             return True
00242         if ("false" == boolstr):
00243             return False
00244         raise ValueError, "result is neither 'true' nor 'false': " + boolstr
00245     
00246     def get_boolean_array(self, verb, args):
00247         boolarr = self.get_string_array(verb, args)
00248         for i in range(len(boolarr)):
00249             if ("true" == boolstr):
00250                 boolarr[i] = True
00251                 continue
00252             if ("false" == boolstr):
00253                 boolarr[i] = False
00254                 continue
00255             raise ValueError, "result is neither 'true' nor 'false': " + boolarr[i]
00256         return boolarr
00257     
00258     
00259 
00260 ### From here on, everything's auto-generated from XML
00261 
00262 
00263     def click(self,locator):
00264         """
00265         Clicks on a link, button, checkbox or radio button. If the click action
00266         causes a new page to load (like a link usually does), call
00267         waitForPageToLoad.
00268         
00269         'locator' is an element locator
00270         """
00271         self.do_command("click", [locator,])
00272 
00273 
00274     def double_click(self,locator):
00275         """
00276         Double clicks on a link, button, checkbox or radio button. If the double click action
00277         causes a new page to load (like a link usually does), call
00278         waitForPageToLoad.
00279         
00280         'locator' is an element locator
00281         """
00282         self.do_command("doubleClick", [locator,])
00283 
00284 
00285     def context_menu(self,locator):
00286         """
00287         Simulates opening the context menu for the specified element (as might happen if the user "right-clicked" on the element).
00288         
00289         'locator' is an element locator
00290         """
00291         self.do_command("contextMenu", [locator,])
00292 
00293 
00294     def click_at(self,locator,coordString):
00295         """
00296         Clicks on a link, button, checkbox or radio button. If the click action
00297         causes a new page to load (like a link usually does), call
00298         waitForPageToLoad.
00299         
00300         'locator' is an element locator
00301         'coordString' is specifies the x,y position (i.e. - 10,20) of the mouse      event relative to the element returned by the locator.
00302         """
00303         self.do_command("clickAt", [locator,coordString,])
00304 
00305 
00306     def double_click_at(self,locator,coordString):
00307         """
00308         Doubleclicks on a link, button, checkbox or radio button. If the action
00309         causes a new page to load (like a link usually does), call
00310         waitForPageToLoad.
00311         
00312         'locator' is an element locator
00313         'coordString' is specifies the x,y position (i.e. - 10,20) of the mouse      event relative to the element returned by the locator.
00314         """
00315         self.do_command("doubleClickAt", [locator,coordString,])
00316 
00317 
00318     def context_menu_at(self,locator,coordString):
00319         """
00320         Simulates opening the context menu for the specified element (as might happen if the user "right-clicked" on the element).
00321         
00322         'locator' is an element locator
00323         'coordString' is specifies the x,y position (i.e. - 10,20) of the mouse      event relative to the element returned by the locator.
00324         """
00325         self.do_command("contextMenuAt", [locator,coordString,])
00326 
00327 
00328     def fire_event(self,locator,eventName):
00329         """
00330         Explicitly simulate an event, to trigger the corresponding "on\ *event*"
00331         handler.
00332         
00333         'locator' is an element locator
00334         'eventName' is the event name, e.g. "focus" or "blur"
00335         """
00336         self.do_command("fireEvent", [locator,eventName,])
00337 
00338 
00339     def focus(self,locator):
00340         """
00341         Move the focus to the specified element; for example, if the element is an input field, move the cursor to that field.
00342         
00343         'locator' is an element locator
00344         """
00345         self.do_command("focus", [locator,])
00346 
00347 
00348     def key_press(self,locator,keySequence):
00349         """
00350         Simulates a user pressing and releasing a key.
00351         
00352         'locator' is an element locator
00353         'keySequence' is Either be a string("\" followed by the numeric keycode  of the key to be pressed, normally the ASCII value of that key), or a single  character. For example: "w", "\119".
00354         """
00355         self.do_command("keyPress", [locator,keySequence,])
00356 
00357 
00358     def shift_key_down(self):
00359         """
00360         Press the shift key and hold it down until doShiftUp() is called or a new page is loaded.
00361         
00362         """
00363         self.do_command("shiftKeyDown", [])
00364 
00365 
00366     def shift_key_up(self):
00367         """
00368         Release the shift key.
00369         
00370         """
00371         self.do_command("shiftKeyUp", [])
00372 
00373 
00374     def meta_key_down(self):
00375         """
00376         Press the meta key and hold it down until doMetaUp() is called or a new page is loaded.
00377         
00378         """
00379         self.do_command("metaKeyDown", [])
00380 
00381 
00382     def meta_key_up(self):
00383         """
00384         Release the meta key.
00385         
00386         """
00387         self.do_command("metaKeyUp", [])
00388 
00389 
00390     def alt_key_down(self):
00391         """
00392         Press the alt key and hold it down until doAltUp() is called or a new page is loaded.
00393         
00394         """
00395         self.do_command("altKeyDown", [])
00396 
00397 
00398     def alt_key_up(self):
00399         """
00400         Release the alt key.
00401         
00402         """
00403         self.do_command("altKeyUp", [])
00404 
00405 
00406     def control_key_down(self):
00407         """
00408         Press the control key and hold it down until doControlUp() is called or a new page is loaded.
00409         
00410         """
00411         self.do_command("controlKeyDown", [])
00412 
00413 
00414     def control_key_up(self):
00415         """
00416         Release the control key.
00417         
00418         """
00419         self.do_command("controlKeyUp", [])
00420 
00421 
00422     def key_down(self,locator,keySequence):
00423         """
00424         Simulates a user pressing a key (without releasing it yet).
00425         
00426         'locator' is an element locator
00427         'keySequence' is Either be a string("\" followed by the numeric keycode  of the key to be pressed, normally the ASCII value of that key), or a single  character. For example: "w", "\119".
00428         """
00429         self.do_command("keyDown", [locator,keySequence,])
00430 
00431 
00432     def key_up(self,locator,keySequence):
00433         """
00434         Simulates a user releasing a key.
00435         
00436         'locator' is an element locator
00437         'keySequence' is Either be a string("\" followed by the numeric keycode  of the key to be pressed, normally the ASCII value of that key), or a single  character. For example: "w", "\119".
00438         """
00439         self.do_command("keyUp", [locator,keySequence,])
00440 
00441 
00442     def mouse_over(self,locator):
00443         """
00444         Simulates a user hovering a mouse over the specified element.
00445         
00446         'locator' is an element locator
00447         """
00448         self.do_command("mouseOver", [locator,])
00449 
00450 
00451     def mouse_out(self,locator):
00452         """
00453         Simulates a user moving the mouse pointer away from the specified element.
00454         
00455         'locator' is an element locator
00456         """
00457         self.do_command("mouseOut", [locator,])
00458 
00459 
00460     def mouse_down(self,locator):
00461         """
00462         Simulates a user pressing the mouse button (without releasing it yet) on
00463         the specified element.
00464         
00465         'locator' is an element locator
00466         """
00467         self.do_command("mouseDown", [locator,])
00468 
00469 
00470     def mouse_down_at(self,locator,coordString):
00471         """
00472         Simulates a user pressing the mouse button (without releasing it yet) at
00473         the specified location.
00474         
00475         'locator' is an element locator
00476         'coordString' is specifies the x,y position (i.e. - 10,20) of the mouse      event relative to the element returned by the locator.
00477         """
00478         self.do_command("mouseDownAt", [locator,coordString,])
00479 
00480 
00481     def mouse_up(self,locator):
00482         """
00483         Simulates the event that occurs when the user releases the mouse button (i.e., stops
00484         holding the button down) on the specified element.
00485         
00486         'locator' is an element locator
00487         """
00488         self.do_command("mouseUp", [locator,])
00489 
00490 
00491     def mouse_up_at(self,locator,coordString):
00492         """
00493         Simulates the event that occurs when the user releases the mouse button (i.e., stops
00494         holding the button down) at the specified location.
00495         
00496         'locator' is an element locator
00497         'coordString' is specifies the x,y position (i.e. - 10,20) of the mouse      event relative to the element returned by the locator.
00498         """
00499         self.do_command("mouseUpAt", [locator,coordString,])
00500 
00501 
00502     def mouse_move(self,locator):
00503         """
00504         Simulates a user pressing the mouse button (without releasing it yet) on
00505         the specified element.
00506         
00507         'locator' is an element locator
00508         """
00509         self.do_command("mouseMove", [locator,])
00510 
00511 
00512     def mouse_move_at(self,locator,coordString):
00513         """
00514         Simulates a user pressing the mouse button (without releasing it yet) on
00515         the specified element.
00516         
00517         'locator' is an element locator
00518         'coordString' is specifies the x,y position (i.e. - 10,20) of the mouse      event relative to the element returned by the locator.
00519         """
00520         self.do_command("mouseMoveAt", [locator,coordString,])
00521 
00522 
00523     def type(self,locator,value):
00524         """
00525         Sets the value of an input field, as though you typed it in.
00526         
00527         
00528         Can also be used to set the value of combo boxes, check boxes, etc. In these cases,
00529         value should be the value of the option selected, not the visible text.
00530         
00531         
00532         'locator' is an element locator
00533         'value' is the value to type
00534         """
00535         self.do_command("type", [locator,value,])
00536 
00537 
00538     def type_keys(self,locator,value):
00539         """
00540         Simulates keystroke events on the specified element, as though you typed the value key-by-key.
00541         
00542         
00543         This is a convenience method for calling keyDown, keyUp, keyPress for every character in the specified string;
00544         this is useful for dynamic UI widgets (like auto-completing combo boxes) that require explicit key events.
00545         
00546         Unlike the simple "type" command, which forces the specified value into the page directly, this command
00547         may or may not have any visible effect, even in cases where typing keys would normally have a visible effect.
00548         For example, if you use "typeKeys" on a form element, you may or may not see the results of what you typed in
00549         the field.
00550         
00551         In some cases, you may need to use the simple "type" command to set the value of the field and then the "typeKeys" command to
00552         send the keystroke events corresponding to what you just typed.
00553         
00554         
00555         'locator' is an element locator
00556         'value' is the value to type
00557         """
00558         self.do_command("typeKeys", [locator,value,])
00559 
00560 
00561     def set_speed(self,value):
00562         """
00563         Set execution speed (i.e., set the millisecond length of a delay which will follow each selenium operation).  By default, there is no such delay, i.e.,
00564         the delay is 0 milliseconds.
00565         
00566         'value' is the number of milliseconds to pause after operation
00567         """
00568         self.do_command("setSpeed", [value,])
00569 
00570 
00571     def get_speed(self):
00572         """
00573         Get execution speed (i.e., get the millisecond length of the delay following each selenium operation).  By default, there is no such delay, i.e.,
00574         the delay is 0 milliseconds.
00575         
00576         See also setSpeed.
00577         
00578         """
00579         return self.get_string("getSpeed", [])
00580 
00581 
00582     def check(self,locator):
00583         """
00584         Check a toggle-button (checkbox/radio)
00585         
00586         'locator' is an element locator
00587         """
00588         self.do_command("check", [locator,])
00589 
00590 
00591     def uncheck(self,locator):
00592         """
00593         Uncheck a toggle-button (checkbox/radio)
00594         
00595         'locator' is an element locator
00596         """
00597         self.do_command("uncheck", [locator,])
00598 
00599 
00600     def select(self,selectLocator,optionLocator):
00601         """
00602         Select an option from a drop-down using an option locator.
00603         
00604         
00605         
00606         Option locators provide different ways of specifying options of an HTML
00607         Select element (e.g. for selecting a specific option, or for asserting
00608         that the selected option satisfies a specification). There are several
00609         forms of Select Option Locator.
00610         
00611         
00612         *   \ **label**\ =\ *labelPattern*:
00613             matches options based on their labels, i.e. the visible text. (This
00614             is the default.)
00615             
00616             *   label=regexp:^[Oo]ther
00617             
00618             
00619         *   \ **value**\ =\ *valuePattern*:
00620             matches options based on their values.
00621             
00622             *   value=other
00623             
00624             
00625         *   \ **id**\ =\ *id*:
00626             
00627             matches options based on their ids.
00628             
00629             *   id=option1
00630             
00631             
00632         *   \ **index**\ =\ *index*:
00633             matches an option based on its index (offset from zero).
00634             
00635             *   index=2
00636             
00637             
00638         
00639         
00640         
00641         If no option locator prefix is provided, the default behaviour is to match on \ **label**\ .
00642         
00643         
00644         
00645         'selectLocator' is an element locator identifying a drop-down menu
00646         'optionLocator' is an option locator (a label by default)
00647         """
00648         self.do_command("select", [selectLocator,optionLocator,])
00649 
00650 
00651     def add_selection(self,locator,optionLocator):
00652         """
00653         Add a selection to the set of selected options in a multi-select element using an option locator.
00654         
00655         @see #doSelect for details of option locators
00656         
00657         'locator' is an element locator identifying a multi-select box
00658         'optionLocator' is an option locator (a label by default)
00659         """
00660         self.do_command("addSelection", [locator,optionLocator,])
00661 
00662 
00663     def remove_selection(self,locator,optionLocator):
00664         """
00665         Remove a selection from the set of selected options in a multi-select element using an option locator.
00666         
00667         @see #doSelect for details of option locators
00668         
00669         'locator' is an element locator identifying a multi-select box
00670         'optionLocator' is an option locator (a label by default)
00671         """
00672         self.do_command("removeSelection", [locator,optionLocator,])
00673 
00674 
00675     def remove_all_selections(self,locator):
00676         """
00677         Unselects all of the selected options in a multi-select element.
00678         
00679         'locator' is an element locator identifying a multi-select box
00680         """
00681         self.do_command("removeAllSelections", [locator,])
00682 
00683 
00684     def submit(self,formLocator):
00685         """
00686         Submit the specified form. This is particularly useful for forms without
00687         submit buttons, e.g. single-input "Search" forms.
00688         
00689         'formLocator' is an element locator for the form you want to submit
00690         """
00691         self.do_command("submit", [formLocator,])
00692 
00693 
00694     def open(self,url):
00695         """
00696         Opens an URL in the test frame. This accepts both relative and absolute
00697         URLs.
00698         
00699         The "open" command waits for the page to load before proceeding,
00700         ie. the "AndWait" suffix is implicit.
00701         
00702         \ *Note*: The URL must be on the same domain as the runner HTML
00703         due to security restrictions in the browser (Same Origin Policy). If you
00704         need to open an URL on another domain, use the Selenium Server to start a
00705         new browser session on that domain.
00706         
00707         'url' is the URL to open; may be relative or absolute
00708         """
00709         self.do_command("open", [url,])
00710 
00711 
00712     def open_window(self,url,windowID):
00713         """
00714         Opens a popup window (if a window with that ID isn't already open).
00715         After opening the window, you'll need to select it using the selectWindow
00716         command.
00717         
00718         
00719         This command can also be a useful workaround for bug SEL-339.  In some cases, Selenium will be unable to intercept a call to window.open (if the call occurs during or before the "onLoad" event, for example).
00720         In those cases, you can force Selenium to notice the open window's name by using the Selenium openWindow command, using
00721         an empty (blank) url, like this: openWindow("", "myFunnyWindow").
00722         
00723         
00724         'url' is the URL to open, which can be blank
00725         'windowID' is the JavaScript window ID of the window to select
00726         """
00727         self.do_command("openWindow", [url,windowID,])
00728 
00729 
00730     def select_window(self,windowID):
00731         """
00732         Selects a popup window using a window locator; once a popup window has been selected, all
00733         commands go to that window. To select the main window again, use null
00734         as the target.
00735         
00736         
00737         
00738         
00739         Window locators provide different ways of specifying the window object:
00740         by title, by internal JavaScript "name," or by JavaScript variable.
00741         
00742         
00743         *   \ **title**\ =\ *My Special Window*:
00744             Finds the window using the text that appears in the title bar.  Be careful;
00745             two windows can share the same title.  If that happens, this locator will
00746             just pick one.
00747             
00748         *   \ **name**\ =\ *myWindow*:
00749             Finds the window using its internal JavaScript "name" property.  This is the second 
00750             parameter "windowName" passed to the JavaScript method window.open(url, windowName, windowFeatures, replaceFlag)
00751             (which Selenium intercepts).
00752             
00753         *   \ **var**\ =\ *variableName*:
00754             Some pop-up windows are unnamed (anonymous), but are associated with a JavaScript variable name in the current
00755             application window, e.g. "window.foo = window.open(url);".  In those cases, you can open the window using
00756             "var=foo".
00757             
00758         
00759         
00760         
00761         If no window locator prefix is provided, we'll try to guess what you mean like this:
00762         
00763         1.) if windowID is null, (or the string "null") then it is assumed the user is referring to the original window instantiated by the browser).
00764         
00765         2.) if the value of the "windowID" parameter is a JavaScript variable name in the current application window, then it is assumed
00766         that this variable contains the return value from a call to the JavaScript window.open() method.
00767         
00768         3.) Otherwise, selenium looks in a hash it maintains that maps string names to window "names".
00769         
00770         4.) If \ *that* fails, we'll try looping over all of the known windows to try to find the appropriate "title".
00771         Since "title" is not necessarily unique, this may have unexpected behavior.
00772         
00773         If you're having trouble figuring out the name of a window that you want to manipulate, look at the Selenium log messages
00774         which identify the names of windows created via window.open (and therefore intercepted by Selenium).  You will see messages
00775         like the following for each window as it is opened:
00776         
00777         ``debug: window.open call intercepted; window ID (which you can use with selectWindow()) is "myNewWindow"``
00778         
00779         In some cases, Selenium will be unable to intercept a call to window.open (if the call occurs during or before the "onLoad" event, for example).
00780         (This is bug SEL-339.)  In those cases, you can force Selenium to notice the open window's name by using the Selenium openWindow command, using
00781         an empty (blank) url, like this: openWindow("", "myFunnyWindow").
00782         
00783         
00784         'windowID' is the JavaScript window ID of the window to select
00785         """
00786         self.do_command("selectWindow", [windowID,])
00787 
00788 
00789     def select_frame(self,locator):
00790         """
00791         Selects a frame within the current window.  (You may invoke this command
00792         multiple times to select nested frames.)  To select the parent frame, use
00793         "relative=parent" as a locator; to select the top frame, use "relative=top".
00794         You can also select a frame by its 0-based index number; select the first frame with
00795         "index=0", or the third frame with "index=2".
00796         
00797         
00798         You may also use a DOM expression to identify the frame you want directly,
00799         like this: ``dom=frames["main"].frames["subframe"]``
00800         
00801         
00802         'locator' is an element locator identifying a frame or iframe
00803         """
00804         self.do_command("selectFrame", [locator,])
00805 
00806 
00807     def get_whether_this_frame_match_frame_expression(self,currentFrameString,target):
00808         """
00809         Determine whether current/locator identify the frame containing this running code.
00810         
00811         
00812         This is useful in proxy injection mode, where this code runs in every
00813         browser frame and window, and sometimes the selenium server needs to identify
00814         the "current" frame.  In this case, when the test calls selectFrame, this
00815         routine is called for each frame to figure out which one has been selected.
00816         The selected frame will return true, while all others will return false.
00817         
00818         
00819         'currentFrameString' is starting frame
00820         'target' is new frame (which might be relative to the current one)
00821         """
00822         return self.get_boolean("getWhetherThisFrameMatchFrameExpression", [currentFrameString,target,])
00823 
00824 
00825     def get_whether_this_window_match_window_expression(self,currentWindowString,target):
00826         """
00827         Determine whether currentWindowString plus target identify the window containing this running code.
00828         
00829         
00830         This is useful in proxy injection mode, where this code runs in every
00831         browser frame and window, and sometimes the selenium server needs to identify
00832         the "current" window.  In this case, when the test calls selectWindow, this
00833         routine is called for each window to figure out which one has been selected.
00834         The selected window will return true, while all others will return false.
00835         
00836         
00837         'currentWindowString' is starting window
00838         'target' is new window (which might be relative to the current one, e.g., "_parent")
00839         """
00840         return self.get_boolean("getWhetherThisWindowMatchWindowExpression", [currentWindowString,target,])
00841 
00842 
00843     def wait_for_pop_up(self,windowID,timeout):
00844         """
00845         Waits for a popup window to appear and load up.
00846         
00847         'windowID' is the JavaScript window "name" of the window that will appear (not the text of the title bar)
00848         'timeout' is a timeout in milliseconds, after which the action will return with an error
00849         """
00850         self.do_command("waitForPopUp", [windowID,timeout,])
00851 
00852 
00853     def choose_cancel_on_next_confirmation(self):
00854         """
00855         By default, Selenium's overridden window.confirm() function will
00856         return true, as if the user had manually clicked OK; after running
00857         this command, the next call to confirm() will return false, as if
00858         the user had clicked Cancel.  Selenium will then resume using the
00859         default behavior for future confirmations, automatically returning 
00860         true (OK) unless/until you explicitly call this command for each
00861         confirmation.
00862         
00863         """
00864         self.do_command("chooseCancelOnNextConfirmation", [])
00865 
00866 
00867     def choose_ok_on_next_confirmation(self):
00868         """
00869         Undo the effect of calling chooseCancelOnNextConfirmation.  Note
00870         that Selenium's overridden window.confirm() function will normally automatically
00871         return true, as if the user had manually clicked OK, so you shouldn't
00872         need to use this command unless for some reason you need to change
00873         your mind prior to the next confirmation.  After any confirmation, Selenium will resume using the
00874         default behavior for future confirmations, automatically returning 
00875         true (OK) unless/until you explicitly call chooseCancelOnNextConfirmation for each
00876         confirmation.
00877         
00878         """
00879         self.do_command("chooseOkOnNextConfirmation", [])
00880 
00881 
00882     def answer_on_next_prompt(self,answer):
00883         """
00884         Instructs Selenium to return the specified answer string in response to
00885         the next JavaScript prompt [window.prompt()].
00886         
00887         'answer' is the answer to give in response to the prompt pop-up
00888         """
00889         self.do_command("answerOnNextPrompt", [answer,])
00890 
00891 
00892     def go_back(self):
00893         """
00894         Simulates the user clicking the "back" button on their browser.
00895         
00896         """
00897         self.do_command("goBack", [])
00898 
00899 
00900     def refresh(self):
00901         """
00902         Simulates the user clicking the "Refresh" button on their browser.
00903         
00904         """
00905         self.do_command("refresh", [])
00906 
00907 
00908     def close(self):
00909         """
00910         Simulates the user clicking the "close" button in the titlebar of a popup
00911         window or tab.
00912         
00913         """
00914         self.do_command("close", [])
00915 
00916 
00917     def is_alert_present(self):
00918         """
00919         Has an alert occurred?
00920         
00921         
00922         
00923         This function never throws an exception
00924         
00925         
00926         
00927         """
00928         return self.get_boolean("isAlertPresent", [])
00929 
00930 
00931     def is_prompt_present(self):
00932         """
00933         Has a prompt occurred?
00934         
00935         
00936         
00937         This function never throws an exception
00938         
00939         
00940         
00941         """
00942         return self.get_boolean("isPromptPresent", [])
00943 
00944 
00945     def is_confirmation_present(self):
00946         """
00947         Has confirm() been called?
00948         
00949         
00950         
00951         This function never throws an exception
00952         
00953         
00954         
00955         """
00956         return self.get_boolean("isConfirmationPresent", [])
00957 
00958 
00959     def get_alert(self):
00960         """
00961         Retrieves the message of a JavaScript alert generated during the previous action, or fail if there were no alerts.
00962         
00963         
00964         Getting an alert has the same effect as manually clicking OK. If an
00965         alert is generated but you do not get/verify it, the next Selenium action
00966         will fail.
00967         
00968         NOTE: under Selenium, JavaScript alerts will NOT pop up a visible alert
00969         dialog.
00970         
00971         NOTE: Selenium does NOT support JavaScript alerts that are generated in a
00972         page's onload() event handler. In this case a visible dialog WILL be
00973         generated and Selenium will hang until someone manually clicks OK.
00974         
00975         
00976         """
00977         return self.get_string("getAlert", [])
00978 
00979 
00980     def get_confirmation(self):
00981         """
00982         Retrieves the message of a JavaScript confirmation dialog generated during
00983         the previous action.
00984         
00985         
00986         
00987         By default, the confirm function will return true, having the same effect
00988         as manually clicking OK. This can be changed by prior execution of the
00989         chooseCancelOnNextConfirmation command. If an confirmation is generated
00990         but you do not get/verify it, the next Selenium action will fail.
00991         
00992         
00993         
00994         NOTE: under Selenium, JavaScript confirmations will NOT pop up a visible
00995         dialog.
00996         
00997         
00998         
00999         NOTE: Selenium does NOT support JavaScript confirmations that are
01000         generated in a page's onload() event handler. In this case a visible
01001         dialog WILL be generated and Selenium will hang until you manually click
01002         OK.
01003         
01004         
01005         
01006         """
01007         return self.get_string("getConfirmation", [])
01008 
01009 
01010     def get_prompt(self):
01011         """
01012         Retrieves the message of a JavaScript question prompt dialog generated during
01013         the previous action.
01014         
01015         
01016         Successful handling of the prompt requires prior execution of the
01017         answerOnNextPrompt command. If a prompt is generated but you
01018         do not get/verify it, the next Selenium action will fail.
01019         
01020         NOTE: under Selenium, JavaScript prompts will NOT pop up a visible
01021         dialog.
01022         
01023         NOTE: Selenium does NOT support JavaScript prompts that are generated in a
01024         page's onload() event handler. In this case a visible dialog WILL be
01025         generated and Selenium will hang until someone manually clicks OK.
01026         
01027         
01028         """
01029         return self.get_string("getPrompt", [])
01030 
01031 
01032     def get_location(self):
01033         """
01034         Gets the absolute URL of the current page.
01035         
01036         """
01037         return self.get_string("getLocation", [])
01038 
01039 
01040     def get_title(self):
01041         """
01042         Gets the title of the current page.
01043         
01044         """
01045         return self.get_string("getTitle", [])
01046 
01047 
01048     def get_body_text(self):
01049         """
01050         Gets the entire text of the page.
01051         
01052         """
01053         return self.get_string("getBodyText", [])
01054 
01055 
01056     def get_value(self,locator):
01057         """
01058         Gets the (whitespace-trimmed) value of an input field (or anything else with a value parameter).
01059         For checkbox/radio elements, the value will be "on" or "off" depending on
01060         whether the element is checked or not.
01061         
01062         'locator' is an element locator
01063         """
01064         return self.get_string("getValue", [locator,])
01065 
01066 
01067     def get_text(self,locator):
01068         """
01069         Gets the text of an element. This works for any element that contains
01070         text. This command uses either the textContent (Mozilla-like browsers) or
01071         the innerText (IE-like browsers) of the element, which is the rendered
01072         text shown to the user.
01073         
01074         'locator' is an element locator
01075         """
01076         return self.get_string("getText", [locator,])
01077 
01078 
01079     def highlight(self,locator):
01080         """
01081         Briefly changes the backgroundColor of the specified element yellow.  Useful for debugging.
01082         
01083         'locator' is an element locator
01084         """
01085         self.do_command("highlight", [locator,])
01086 
01087 
01088     def get_eval(self,script):
01089         """
01090         Gets the result of evaluating the specified JavaScript snippet.  The snippet may
01091         have multiple lines, but only the result of the last line will be returned.
01092         
01093         
01094         Note that, by default, the snippet will run in the context of the "selenium"
01095         object itself, so ``this`` will refer to the Selenium object.  Use ``window`` to
01096         refer to the window of your application, e.g. ``window.document.getElementById('foo')``
01097         
01098         If you need to use
01099         a locator to refer to a single element in your application page, you can
01100         use ``this.browserbot.findElement("id=foo")`` where "id=foo" is your locator.
01101         
01102         
01103         'script' is the JavaScript snippet to run
01104         """
01105         return self.get_string("getEval", [script,])
01106 
01107 
01108     def is_checked(self,locator):
01109         """
01110         Gets whether a toggle-button (checkbox/radio) is checked.  Fails if the specified element doesn't exist or isn't a toggle-button.
01111         
01112         'locator' is an element locator pointing to a checkbox or radio button
01113         """
01114         return self.get_boolean("isChecked", [locator,])
01115 
01116 
01117     def get_table(self,tableCellAddress):
01118         """
01119         Gets the text from a cell of a table. The cellAddress syntax
01120         tableLocator.row.column, where row and column start at 0.
01121         
01122         'tableCellAddress' is a cell address, e.g. "foo.1.4"
01123         """
01124         return self.get_string("getTable", [tableCellAddress,])
01125 
01126 
01127     def get_selected_labels(self,selectLocator):
01128         """
01129         Gets all option labels (visible text) for selected options in the specified select or multi-select element.
01130         
01131         'selectLocator' is an element locator identifying a drop-down menu
01132         """
01133         return self.get_string_array("getSelectedLabels", [selectLocator,])
01134 
01135 
01136     def get_selected_label(self,selectLocator):
01137         """
01138         Gets option label (visible text) for selected option in the specified select element.
01139         
01140         'selectLocator' is an element locator identifying a drop-down menu
01141         """
01142         return self.get_string("getSelectedLabel", [selectLocator,])
01143 
01144 
01145     def get_selected_values(self,selectLocator):
01146         """
01147         Gets all option values (value attributes) for selected options in the specified select or multi-select element.
01148         
01149         'selectLocator' is an element locator identifying a drop-down menu
01150         """
01151         return self.get_string_array("getSelectedValues", [selectLocator,])
01152 
01153 
01154     def get_selected_value(self,selectLocator):
01155         """
01156         Gets option value (value attribute) for selected option in the specified select element.
01157         
01158         'selectLocator' is an element locator identifying a drop-down menu
01159         """
01160         return self.get_string("getSelectedValue", [selectLocator,])
01161 
01162 
01163     def get_selected_indexes(self,selectLocator):
01164         """
01165         Gets all option indexes (option number, starting at 0) for selected options in the specified select or multi-select element.
01166         
01167         'selectLocator' is an element locator identifying a drop-down menu
01168         """
01169         return self.get_string_array("getSelectedIndexes", [selectLocator,])
01170 
01171 
01172     def get_selected_index(self,selectLocator):
01173         """
01174         Gets option index (option number, starting at 0) for selected option in the specified select element.
01175         
01176         'selectLocator' is an element locator identifying a drop-down menu
01177         """
01178         return self.get_string("getSelectedIndex", [selectLocator,])
01179 
01180 
01181     def get_selected_ids(self,selectLocator):
01182         """
01183         Gets all option element IDs for selected options in the specified select or multi-select element.
01184         
01185         'selectLocator' is an element locator identifying a drop-down menu
01186         """
01187         return self.get_string_array("getSelectedIds", [selectLocator,])
01188 
01189 
01190     def get_selected_id(self,selectLocator):
01191         """
01192         Gets option element ID for selected option in the specified select element.
01193         
01194         'selectLocator' is an element locator identifying a drop-down menu
01195         """
01196         return self.get_string("getSelectedId", [selectLocator,])
01197 
01198 
01199     def is_something_selected(self,selectLocator):
01200         """
01201         Determines whether some option in a drop-down menu is selected.
01202         
01203         'selectLocator' is an element locator identifying a drop-down menu
01204         """
01205         return self.get_boolean("isSomethingSelected", [selectLocator,])
01206 
01207 
01208     def get_select_options(self,selectLocator):
01209         """
01210         Gets all option labels in the specified select drop-down.
01211         
01212         'selectLocator' is an element locator identifying a drop-down menu
01213         """
01214         return self.get_string_array("getSelectOptions", [selectLocator,])
01215 
01216 
01217     def get_attribute(self,attributeLocator):
01218         """
01219         Gets the value of an element attribute. The value of the attribute may
01220         differ across browsers (this is the case for the "style" attribute, for
01221         example).
01222         
01223         'attributeLocator' is an element locator followed by an @ sign and then the name of the attribute, e.g. "foo@bar"
01224         """
01225         return self.get_string("getAttribute", [attributeLocator,])
01226 
01227 
01228     def is_text_present(self,pattern):
01229         """
01230         Verifies that the specified text pattern appears somewhere on the rendered page shown to the user.
01231         
01232         'pattern' is a pattern to match with the text of the page
01233         """
01234         return self.get_boolean("isTextPresent", [pattern,])
01235 
01236 
01237     def is_element_present(self,locator):
01238         """
01239         Verifies that the specified element is somewhere on the page.
01240         
01241         'locator' is an element locator
01242         """
01243         return self.get_boolean("isElementPresent", [locator,])
01244 
01245 
01246     def is_visible(self,locator):
01247         """
01248         Determines if the specified element is visible. An
01249         element can be rendered invisible by setting the CSS "visibility"
01250         property to "hidden", or the "display" property to "none", either for the
01251         element itself or one if its ancestors.  This method will fail if
01252         the element is not present.
01253         
01254         'locator' is an element locator
01255         """
01256         return self.get_boolean("isVisible", [locator,])
01257 
01258 
01259     def is_editable(self,locator):
01260         """
01261         Determines whether the specified input element is editable, ie hasn't been disabled.
01262         This method will fail if the specified element isn't an input element.
01263         
01264         'locator' is an element locator
01265         """
01266         return self.get_boolean("isEditable", [locator,])
01267 
01268 
01269     def get_all_buttons(self):
01270         """
01271         Returns the IDs of all buttons on the page.
01272         
01273         
01274         If a given button has no ID, it will appear as "" in this array.
01275         
01276         
01277         """
01278         return self.get_string_array("getAllButtons", [])
01279 
01280 
01281     def get_all_links(self):
01282         """
01283         Returns the IDs of all links on the page.
01284         
01285         
01286         If a given link has no ID, it will appear as "" in this array.
01287         
01288         
01289         """
01290         return self.get_string_array("getAllLinks", [])
01291 
01292 
01293     def get_all_fields(self):
01294         """
01295         Returns the IDs of all input fields on the page.
01296         
01297         
01298         If a given field has no ID, it will appear as "" in this array.
01299         
01300         
01301         """
01302         return self.get_string_array("getAllFields", [])
01303 
01304 
01305     def get_attribute_from_all_windows(self,attributeName):
01306         """
01307         Returns every instance of some attribute from all known windows.
01308         
01309         'attributeName' is name of an attribute on the windows
01310         """
01311         return self.get_string_array("getAttributeFromAllWindows", [attributeName,])
01312 
01313 
01314     def dragdrop(self,locator,movementsString):
01315         """
01316         deprecated - use dragAndDrop instead
01317         
01318         'locator' is an element locator
01319         'movementsString' is offset in pixels from the current location to which the element should be moved, e.g., "+70,-300"
01320         """
01321         self.do_command("dragdrop", [locator,movementsString,])
01322 
01323 
01324     def set_mouse_speed(self,pixels):
01325         """
01326         Configure the number of pixels between "mousemove" events during dragAndDrop commands (default=10).
01327         
01328         Setting this value to 0 means that we'll send a "mousemove" event to every single pixel
01329         in between the start location and the end location; that can be very slow, and may
01330         cause some browsers to force the JavaScript to timeout.
01331         
01332         If the mouse speed is greater than the distance between the two dragged objects, we'll
01333         just send one "mousemove" at the start location and then one final one at the end location.
01334         
01335         
01336         'pixels' is the number of pixels between "mousemove" events
01337         """
01338         self.do_command("setMouseSpeed", [pixels,])
01339 
01340 
01341     def get_mouse_speed(self):
01342         """
01343         Returns the number of pixels between "mousemove" events during dragAndDrop commands (default=10).
01344         
01345         """
01346         return self.get_number("getMouseSpeed", [])
01347 
01348 
01349     def drag_and_drop(self,locator,movementsString):
01350         """
01351         Drags an element a certain distance and then drops it
01352         
01353         'locator' is an element locator
01354         'movementsString' is offset in pixels from the current location to which the element should be moved, e.g., "+70,-300"
01355         """
01356         self.do_command("dragAndDrop", [locator,movementsString,])
01357 
01358 
01359     def drag_and_drop_to_object(self,locatorOfObjectToBeDragged,locatorOfDragDestinationObject):
01360         """
01361         Drags an element and drops it on another element
01362         
01363         'locatorOfObjectToBeDragged' is an element to be dragged
01364         'locatorOfDragDestinationObject' is an element whose location (i.e., whose center-most pixel) will be the point where locatorOfObjectToBeDragged  is dropped
01365         """
01366         self.do_command("dragAndDropToObject", [locatorOfObjectToBeDragged,locatorOfDragDestinationObject,])
01367 
01368 
01369     def window_focus(self):
01370         """
01371         Gives focus to the currently selected window
01372         
01373         """
01374         self.do_command("windowFocus", [])
01375 
01376 
01377     def window_maximize(self):
01378         """
01379         Resize currently selected window to take up the entire screen
01380         
01381         """
01382         self.do_command("windowMaximize", [])
01383 
01384 
01385     def get_all_window_ids(self):
01386         """
01387         Returns the IDs of all windows that the browser knows about.
01388         
01389         """
01390         return self.get_string_array("getAllWindowIds", [])
01391 
01392 
01393     def get_all_window_names(self):
01394         """
01395         Returns the names of all windows that the browser knows about.
01396         
01397         """
01398         return self.get_string_array("getAllWindowNames", [])
01399 
01400 
01401     def get_all_window_titles(self):
01402         """
01403         Returns the titles of all windows that the browser knows about.
01404         
01405         """
01406         return self.get_string_array("getAllWindowTitles", [])
01407 
01408 
01409     def get_html_source(self):
01410         """
01411         Returns the entire HTML source between the opening and
01412         closing "html" tags.
01413         
01414         """
01415         return self.get_string("getHtmlSource", [])
01416 
01417 
01418     def set_cursor_position(self,locator,position):
01419         """
01420         Moves the text cursor to the specified position in the given input element or textarea.
01421         This method will fail if the specified element isn't an input element or textarea.
01422         
01423         'locator' is an element locator pointing to an input element or textarea
01424         'position' is the numerical position of the cursor in the field; position should be 0 to move the position to the beginning of the field.  You can also set the cursor to -1 to move it to the end of the field.
01425         """
01426         self.do_command("setCursorPosition", [locator,position,])
01427 
01428 
01429     def get_element_index(self,locator):
01430         """
01431         Get the relative index of an element to its parent (starting from 0). The comment node and empty text node
01432         will be ignored.
01433         
01434         'locator' is an element locator pointing to an element
01435         """
01436         return self.get_number("getElementIndex", [locator,])
01437 
01438 
01439     def is_ordered(self,locator1,locator2):
01440         """
01441         Check if these two elements have same parent and are ordered siblings in the DOM. Two same elements will
01442         not be considered ordered.
01443         
01444         'locator1' is an element locator pointing to the first element
01445         'locator2' is an element locator pointing to the second element
01446         """
01447         return self.get_boolean("isOrdered", [locator1,locator2,])
01448 
01449 
01450     def get_element_position_left(self,locator):
01451         """
01452         Retrieves the horizontal position of an element
01453         
01454         'locator' is an element locator pointing to an element OR an element itself
01455         """
01456         return self.get_number("getElementPositionLeft", [locator,])
01457 
01458 
01459     def get_element_position_top(self,locator):
01460         """
01461         Retrieves the vertical position of an element
01462         
01463         'locator' is an element locator pointing to an element OR an element itself
01464         """
01465         return self.get_number("getElementPositionTop", [locator,])
01466 
01467 
01468     def get_element_width(self,locator):
01469         """
01470         Retrieves the width of an element
01471         
01472         'locator' is an element locator pointing to an element
01473         """
01474         return self.get_number("getElementWidth", [locator,])
01475 
01476 
01477     def get_element_height(self,locator):
01478         """
01479         Retrieves the height of an element
01480         
01481         'locator' is an element locator pointing to an element
01482         """
01483         return self.get_number("getElementHeight", [locator,])
01484 
01485 
01486     def get_cursor_position(self,locator):
01487         """
01488         Retrieves the text cursor position in the given input element or textarea; beware, this may not work perfectly on all browsers.
01489         
01490         
01491         Specifically, if the cursor/selection has been cleared by JavaScript, this command will tend to
01492         return the position of the last location of the cursor, even though the cursor is now gone from the page.  This is filed as SEL-243.
01493         
01494         This method will fail if the specified element isn't an input element or textarea, or there is no cursor in the element.
01495         
01496         'locator' is an element locator pointing to an input element or textarea
01497         """
01498         return self.get_number("getCursorPosition", [locator,])
01499 
01500 
01501     def get_expression(self,expression):
01502         """
01503         Returns the specified expression.
01504         
01505         
01506         This is useful because of JavaScript preprocessing.
01507         It is used to generate commands like assertExpression and waitForExpression.
01508         
01509         
01510         'expression' is the value to return
01511         """
01512         return self.get_string("getExpression", [expression,])
01513 
01514 
01515     def get_xpath_count(self,xpath):
01516         """
01517         Returns the number of nodes that match the specified xpath, eg. "//table" would give
01518         the number of tables.
01519         
01520         'xpath' is the xpath expression to evaluate. do NOT wrap this expression in a 'count()' function; we will do that for you.
01521         """
01522         return self.get_number("getXpathCount", [xpath,])
01523 
01524 
01525     def assign_id(self,locator,identifier):
01526         """
01527         Temporarily sets the "id" attribute of the specified element, so you can locate it in the future
01528         using its ID rather than a slow/complicated XPath.  This ID will disappear once the page is
01529         reloaded.
01530         
01531         'locator' is an element locator pointing to an element
01532         'identifier' is a string to be used as the ID of the specified element
01533         """
01534         self.do_command("assignId", [locator,identifier,])
01535 
01536 
01537     def allow_native_xpath(self,allow):
01538         """
01539         Specifies whether Selenium should use the native in-browser implementation
01540         of XPath (if any native version is available); if you pass "false" to
01541         this function, we will always use our pure-JavaScript xpath library.
01542         Using the pure-JS xpath library can improve the consistency of xpath
01543         element locators between different browser vendors, but the pure-JS
01544         version is much slower than the native implementations.
01545         
01546         'allow' is boolean, true means we'll prefer to use native XPath; false means we'll only use JS XPath
01547         """
01548         self.do_command("allowNativeXpath", [allow,])
01549 
01550 
01551     def ignore_attributes_without_value(self,ignore):
01552         """
01553         Specifies whether Selenium will ignore xpath attributes that have no
01554         value, i.e. are the empty string, when using the non-native xpath
01555         evaluation engine. You'd want to do this for performance reasons in IE.
01556         However, this could break certain xpaths, for example an xpath that looks
01557         for an attribute whose value is NOT the empty string.
01558         
01559         The hope is that such xpaths are relatively rare, but the user should
01560         have the option of using them. Note that this only influences xpath
01561         evaluation when using the ajaxslt engine (i.e. not "javascript-xpath").
01562         
01563         'ignore' is boolean, true means we'll ignore attributes without value                        at the expense of xpath "correctness"; false means                        we'll sacrifice speed for correctness.
01564         """
01565         self.do_command("ignoreAttributesWithoutValue", [ignore,])
01566 
01567 
01568     def wait_for_condition(self,script,timeout):
01569         """
01570         Runs the specified JavaScript snippet repeatedly until it evaluates to "true".
01571         The snippet may have multiple lines, but only the result of the last line
01572         will be considered.
01573         
01574         
01575         Note that, by default, the snippet will be run in the runner's test window, not in the window
01576         of your application.  To get the window of your application, you can use
01577         the JavaScript snippet ``selenium.browserbot.getCurrentWindow()``, and then
01578         run your JavaScript in there
01579         
01580         
01581         'script' is the JavaScript snippet to run
01582         'timeout' is a timeout in milliseconds, after which this command will return with an error
01583         """
01584         self.do_command("waitForCondition", [script,timeout,])
01585 
01586 
01587     def set_timeout(self,timeout):
01588         """
01589         Specifies the amount of time that Selenium will wait for actions to complete.
01590         
01591         
01592         Actions that require waiting include "open" and the "waitFor\*" actions.
01593         
01594         The default timeout is 30 seconds.
01595         
01596         'timeout' is a timeout in milliseconds, after which the action will return with an error
01597         """
01598         self.do_command("setTimeout", [timeout,])
01599 
01600 
01601     def wait_for_page_to_load(self,timeout):
01602         """
01603         Waits for a new page to load.
01604         
01605         
01606         You can use this command instead of the "AndWait" suffixes, "clickAndWait", "selectAndWait", "typeAndWait" etc.
01607         (which are only available in the JS API).
01608         
01609         Selenium constantly keeps track of new pages loading, and sets a "newPageLoaded"
01610         flag when it first notices a page load.  Running any other Selenium command after
01611         turns the flag to false.  Hence, if you want to wait for a page to load, you must
01612         wait immediately after a Selenium command that caused a page-load.
01613         
01614         
01615         'timeout' is a timeout in milliseconds, after which this command will return with an error
01616         """
01617         self.do_command("waitForPageToLoad", [timeout,])
01618 
01619 
01620     def wait_for_frame_to_load(self,frameAddress,timeout):
01621         """
01622         Waits for a new frame to load.
01623         
01624         
01625         Selenium constantly keeps track of new pages and frames loading, 
01626         and sets a "newPageLoaded" flag when it first notices a page load.
01627         
01628         
01629         See waitForPageToLoad for more information.
01630         
01631         'frameAddress' is FrameAddress from the server side
01632         'timeout' is a timeout in milliseconds, after which this command will return with an error
01633         """
01634         self.do_command("waitForFrameToLoad", [frameAddress,timeout,])
01635 
01636 
01637     def get_cookie(self):
01638         """
01639         Return all cookies of the current page under test.
01640         
01641         """
01642         return self.get_string("getCookie", [])
01643 
01644 
01645     def get_cookie_by_name(self,name):
01646         """
01647         Returns the value of the cookie with the specified name, or throws an error if the cookie is not present.
01648         
01649         'name' is the name of the cookie
01650         """
01651         return self.get_string("getCookieByName", [name,])
01652 
01653 
01654     def is_cookie_present(self,name):
01655         """
01656         Returns true if a cookie with the specified name is present, or false otherwise.
01657         
01658         'name' is the name of the cookie
01659         """
01660         return self.get_boolean("isCookiePresent", [name,])
01661 
01662 
01663     def create_cookie(self,nameValuePair,optionsString):
01664         """
01665         Create a new cookie whose path and domain are same with those of current page
01666         under test, unless you specified a path for this cookie explicitly.
01667         
01668         'nameValuePair' is name and value of the cookie in a format "name=value"
01669         'optionsString' is options for the cookie. Currently supported options include 'path', 'max_age' and 'domain'.      the optionsString's format is "path=/path/, max_age=60, domain=.foo.com". The order of options are irrelevant, the unit      of the value of 'max_age' is second.  Note that specifying a domain that isn't a subset of the current domain will      usually fail.
01670         """
01671         self.do_command("createCookie", [nameValuePair,optionsString,])
01672 
01673 
01674     def delete_cookie(self,name,optionsString):
01675         """
01676         Delete a named cookie with specified path and domain.  Be careful; to delete a cookie, you
01677         need to delete it using the exact same path and domain that were used to create the cookie.
01678         If the path is wrong, or the domain is wrong, the cookie simply won't be deleted.  Also
01679         note that specifying a domain that isn't a subset of the current domain will usually fail.
01680         
01681         Since there's no way to discover at runtime the original path and domain of a given cookie,
01682         we've added an option called 'recurse' to try all sub-domains of the current domain with
01683         all paths that are a subset of the current path.  Beware; this option can be slow.  In
01684         big-O notation, it operates in O(n\*m) time, where n is the number of dots in the domain
01685         name and m is the number of slashes in the path.
01686         
01687         'name' is the name of the cookie to be deleted
01688         'optionsString' is options for the cookie. Currently supported options include 'path', 'domain'      and 'recurse.' The optionsString's format is "path=/path/, domain=.foo.com, recurse=true".      The order of options are irrelevant. Note that specifying a domain that isn't a subset of      the current domain will usually fail.
01689         """
01690         self.do_command("deleteCookie", [name,optionsString,])
01691 
01692 
01693     def delete_all_visible_cookies(self):
01694         """
01695         Calls deleteCookie with recurse=true on all cookies visible to the current page.
01696         As noted on the documentation for deleteCookie, recurse=true can be much slower
01697         than simply deleting the cookies using a known domain/path.
01698         
01699         """
01700         self.do_command("deleteAllVisibleCookies", [])
01701 
01702 
01703     def set_browser_log_level(self,logLevel):
01704         """
01705         Sets the threshold for browser-side logging messages; log messages beneath this threshold will be discarded.
01706         Valid logLevel strings are: "debug", "info", "warn", "error" or "off".
01707         To see the browser logs, you need to
01708         either show the log window in GUI mode, or enable browser-side logging in Selenium RC.
01709         
01710         'logLevel' is one of the following: "debug", "info", "warn", "error" or "off"
01711         """
01712         self.do_command("setBrowserLogLevel", [logLevel,])
01713 
01714 
01715     def run_script(self,script):
01716         """
01717         Creates a new "script" tag in the body of the current test window, and 
01718         adds the specified text into the body of the command.  Scripts run in
01719         this way can often be debugged more easily than scripts executed using
01720         Selenium's "getEval" command.  Beware that JS exceptions thrown in these script
01721         tags aren't managed by Selenium, so you should probably wrap your script
01722         in try/catch blocks if there is any chance that the script will throw
01723         an exception.
01724         
01725         'script' is the JavaScript snippet to run
01726         """
01727         self.do_command("runScript", [script,])
01728 
01729 
01730     def add_location_strategy(self,strategyName,functionDefinition):
01731         """
01732         Defines a new function for Selenium to locate elements on the page.
01733         For example,
01734         if you define the strategy "foo", and someone runs click("foo=blah"), we'll
01735         run your function, passing you the string "blah", and click on the element 
01736         that your function
01737         returns, or throw an "Element not found" error if your function returns null.
01738         
01739         We'll pass three arguments to your function:
01740         
01741         *   locator: the string the user passed in
01742         *   inWindow: the currently selected window
01743         *   inDocument: the currently selected document
01744         
01745         
01746         The function must return null if the element can't be found.
01747         
01748         'strategyName' is the name of the strategy to define; this should use only   letters [a-zA-Z] with no spaces or other punctuation.
01749         'functionDefinition' is a string defining the body of a function in JavaScript.   For example: ``return inDocument.getElementById(locator);``
01750         """
01751         self.do_command("addLocationStrategy", [strategyName,functionDefinition,])
01752 
01753 
01754     def capture_entire_page_screenshot(self,filename):
01755         """
01756         Saves the entire contents of the current window canvas to a PNG file.
01757         Currently this only works in Mozilla and when running in chrome mode.
01758         Contrast this with the captureScreenshot command, which captures the
01759         contents of the OS viewport (i.e. whatever is currently being displayed
01760         on the monitor), and is implemented in the RC only. Implementation
01761         mostly borrowed from the Screengrab! Firefox extension. Please see
01762         http://www.screengrab.org for details.
01763         
01764         'filename' is the path to the file to persist the screenshot as. No                  filename extension will be appended by default.                  Directories will not be created if they do not exist,                    and an exception will be thrown, possibly by native                  code.
01765         """
01766         self.do_command("captureEntirePageScreenshot", [filename,])
01767 
01768 
01769     def set_context(self,context):
01770         """
01771         Writes a message to the status bar and adds a note to the browser-side
01772         log.
01773         
01774         'context' is the message to be sent to the browser
01775         """
01776         self.do_command("setContext", [context,])
01777 
01778 
01779     def attach_file(self,fieldLocator,fileLocator):
01780         """
01781         Sets a file input (upload) field to the file listed in fileLocator
01782         
01783         'fieldLocator' is an element locator
01784         'fileLocator' is a URL pointing to the specified file. Before the file  can be set in the input field (fieldLocator), Selenium RC may need to transfer the file    to the local machine before attaching the file in a web page form. This is common in selenium  grid configurations where the RC server driving the browser is not the same  machine that started the test.   Supported Browsers: Firefox ("\*chrome") only.
01785         """
01786         self.do_command("attachFile", [fieldLocator,fileLocator,])
01787 
01788 
01789     def capture_screenshot(self,filename):
01790         """
01791         Captures a PNG screenshot to the specified file.
01792         
01793         'filename' is the absolute path to the file to be written, e.g. "c:\blah\screenshot.png"
01794         """
01795         self.do_command("captureScreenshot", [filename,])
01796 
01797 
01798     def shut_down_selenium_server(self):
01799         """
01800         Kills the running Selenium Server and all browser sessions.  After you run this command, you will no longer be able to send
01801         commands to the server; you can't remotely start the server once it has been stopped.  Normally
01802         you should prefer to run the "stop" command, which terminates the current browser session, rather than 
01803         shutting down the entire server.
01804         
01805         """
01806         self.do_command("shutDownSeleniumServer", [])
01807 
01808 
01809     def key_down_native(self,keycode):
01810         """
01811         Simulates a user pressing a key (without releasing it yet) by sending a native operating system keystroke.
01812         This function uses the java.awt.Robot class to send a keystroke; this more accurately simulates typing
01813         a key on the keyboard.  It does not honor settings from the shiftKeyDown, controlKeyDown, altKeyDown and
01814         metaKeyDown commands, and does not target any particular HTML element.  To send a keystroke to a particular
01815         element, focus on the element first before running this command.
01816         
01817         'keycode' is an integer keycode number corresponding to a java.awt.event.KeyEvent; note that Java keycodes are NOT the same thing as JavaScript keycodes!
01818         """
01819         self.do_command("keyDownNative", [keycode,])
01820 
01821 
01822     def key_up_native(self,keycode):
01823         """
01824         Simulates a user releasing a key by sending a native operating system keystroke.
01825         This function uses the java.awt.Robot class to send a keystroke; this more accurately simulates typing
01826         a key on the keyboard.  It does not honor settings from the shiftKeyDown, controlKeyDown, altKeyDown and
01827         metaKeyDown commands, and does not target any particular HTML element.  To send a keystroke to a particular
01828         element, focus on the element first before running this command.
01829         
01830         'keycode' is an integer keycode number corresponding to a java.awt.event.KeyEvent; note that Java keycodes are NOT the same thing as JavaScript keycodes!
01831         """
01832         self.do_command("keyUpNative", [keycode,])
01833 
01834 
01835     def key_press_native(self,keycode):
01836         """
01837         Simulates a user pressing and releasing a key by sending a native operating system keystroke.
01838         This function uses the java.awt.Robot class to send a keystroke; this more accurately simulates typing
01839         a key on the keyboard.  It does not honor settings from the shiftKeyDown, controlKeyDown, altKeyDown and
01840         metaKeyDown commands, and does not target any particular HTML element.  To send a keystroke to a particular
01841         element, focus on the element first before running this command.
01842         
01843         'keycode' is an integer keycode number corresponding to a java.awt.event.KeyEvent; note that Java keycodes are NOT the same thing as JavaScript keycodes!
01844         """
01845         self.do_command("keyPressNative", [keycode,])
01846 


websocket_gui
Author(s): Benoit Lescot and Stéphane Magnenat
autogenerated on Sat Dec 28 2013 17:46:48