source: project/release/3/selenium/trunk/selenium.scm @ 9597

Last change on this file since 9597 was 9597, checked in by rlpowell, 12 years ago

Now with:

  1. Less debugging statements.
  1. More working with unpatched http egg.
  • Property svn:keywords set to Id
File size: 54.6 KB
Line 
1
2(define-extension "selenium")
3
4(use http-client)
5(use uri)
6(use srfi-1)
7(use srfi-18)
8(use extras)
9
10;=====
11; Introduction And Copyright
12;
13; This file is autogenerated by the iedoc2scm.xml XSLT stylesheet,
14; using iedoc.xml as the source.  See
15; http://wiki.openqa.org/display/SRC/Developer%27s+Guide#Developer%27sGuide-IEDoc.js%2CIEDoc.xmlandXSLT
16; for how to get iedoc.xml
17;
18; The specification this works from is at
19; http://wiki.openqa.org/display/SRC/Specifications+for+Selenium+Remote+Control+Client+Driver+Protocol
20;
21; Copyright 2008 Robin Lee Powell, sort of.
22;
23; The XSLT is almost entirely copied from the Ruby Selenium RC
24; XSLT, which was created by ThoughtWorks, Inc., and licensed
25; under the Apache License, Version 2.0 (the "License").  All the
26; Scheme and all my modifications are placed into the public domain
27; as much as that license allows.
28;
29;      http://www.apache.org/licenses/LICENSE-2.0
30;
31; -----------------
32; Original code by Aslak Hellesoy and Darren Hobbs
33; This file has been automatically generated via XSL
34; -----------------
35
36;-----
37; Explanation And Examples
38;
39; Defines an object that runs Selenium commands.
40;
41; Element Locators
42; Element Locators tell Selenium which HTML element a command refers to.
43; The format of a locator is:
44; <em>locatorType</em><b>=</b><em>argument</em>
45; We support the following strategies for locating elements:
46;
47; <b>identifier</b>=<em>id</em>:
48; Select the element with the specified @id attribute. If no match is
49; found, select the first element whose @name attribute is <em>id</em>.
50; (This is normally the default; see below.)<b>id</b>=<em>id</em>:
51; Select the element with the specified @id attribute.<b>name</b>=<em>name</em>:
52; Select the first element with the specified @name attribute.
53; usernamename=username
54; The name may optionally be followed by one or more <em>element-filters</em>, separated from the name by whitespace.  If the <em>filterType</em> is not specified, <b>value</b> is assumed.
55; name=flavour value=chocolate
56; <b>dom</b>=<em>javascriptExpression</em>:
57;
58; Find an element by evaluating the specified string.  This allows you to traverse the HTML Document Object
59; Model using JavaScript.  Note that you must not return a value in this string; simply make it the last expression in the block.
60; dom=document.forms['myForm'].myDropdowndom=document.images[56]dom=function foo() { return document.links[1]; }; foo();
61; <b>xpath</b>=<em>xpathExpression</em>:
62; Locate an element using an XPath expression.
63; xpath=//img[@alt='The image alt text']xpath=//table[@id='table1']//tr[4]/td[2]xpath=//a[contains(@href,'#id1')]xpath=//a[contains(@href,'#id1')]/@classxpath=(//table[@class='stylee'])//th[text()='theHeaderText']/../tdxpath=//input[@name='name2' and @value='yes']xpath=//*[text()="right"]
64; <b>link</b>=<em>textPattern</em>:
65; Select the link (anchor) element which contains text matching the
66; specified <em>pattern</em>.
67; link=The link text
68; <b>css</b>=<em>cssSelectorSyntax</em>:
69; 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.
70; css=a[href="#id3"]css=span#firstChild + span
71; 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).
72;
73;
74; Without an explicit locator prefix, Selenium uses the following default
75; strategies:
76;
77; <b>dom</b>, for locators starting with "document."<b>xpath</b>, for locators starting with "//"<b>identifier</b>, otherwise
78; Element FiltersElement filters can be used with a locator to refine a list of candidate elements.  They are currently used only in the 'name' element-locator.
79; Filters look much like locators, ie.
80; <em>filterType</em><b>=</b><em>argument</em>Supported element-filters are:
81; <b>value=</b><em>valuePattern</em>
82;
83; Matches elements based on their values.  This is particularly useful for refining a list of similarly-named toggle-buttons.<b>index=</b><em>index</em>
84;
85; Selects a single element based on its position in the list (offset from zero).String-match Patterns
86; Various Pattern syntaxes are available for matching string values:
87;
88; <b>glob:</b><em>pattern</em>:
89; Match a string against a "glob" (aka "wildmat") pattern. "Glob" is a
90; kind of limited regular-expression syntax typically used in command-line
91; shells. In a glob pattern, "*" represents any sequence of characters, and "?"
92; represents any single character. Glob patterns match against the entire
93; string.<b>regexp:</b><em>regexp</em>:
94; Match a string using a regular-expression. The full power of JavaScript
95; regular-expressions is available.<b>exact:</b><em>string</em>:
96;
97; Match a string exactly, verbatim, without any of that fancy wildcard
98; stuff.
99;
100; If no pattern prefix is specified, Selenium assumes that it's a "glob"
101; pattern.
102;
103;
104
105;-----
106; Selenium Session
107;
108; The selenium-session record.  Nothing fancy.  All of the values
109; are start-time options except session-id, which is gotten from the
110; server at start time.
111;
112(define-record
113    selenium-session
114    server-host
115    server-port
116    browser-start-command
117    browser-url
118    timeout
119    session-id)
120
121; This is so we can allow defaults and not force the session id to
122; be defined.  Timeout is in seconds, and defaults to 30.
123(define (new-selenium-session
124          server-host
125          server-port
126          browser-start-command
127          browser-url
128          #!optional timeout)
129  (make-selenium-session
130    server-host
131    server-port
132    browser-start-command
133    browser-url
134    (or timeout 30)
135    #f))
136
137;-----
138; Internal commands
139;
140(define (selenium::do-command sel-sess verb . args)
141  ;(format #t "d-c args: ~A\n" args)
142  (let*
143    (
144     [url
145       (uri->string
146         (make-uri
147           scheme: 'http
148           ; List of authority, path, query.  Authority is in turn
149           ; userinfo, host, port.
150           specific: (list
151                       (list
152                         #f
153                         (selenium-session-server-host sel-sess)
154                         (selenium-session-server-port sel-sess))
155                       "/selenium-server/driver/"
156                       ; Create an alist of the arguments.  The
157                       ; session-id we may or may not want to
158                       ; populate, depending on whether we have one
159                       ; yet.
160                       (let
161                         ([main-list
162                            (cons
163                              (cons "cmd" verb)
164                              (cond
165                                [(null? args) '()]
166                                [(and (null? (car args)) (null? (cdr args))) '()]
167                                [else (map
168                                        (lambda (a b) (cons a b))
169                                        (iota (length args) 1)
170                                        args)]))])
171                         ; Add the session ID, or not.
172                         (cond
173                           [(selenium-session-session-id sel-sess)
174                            (append
175                              main-list
176                              (list (cons "sessionId" (selenium-session-session-id sel-sess))))]
177                           [else main-list])))))]
178     [http-thread (make-thread (lambda ()
179                                 (http:GET (http:make-request
180                                             'GET url
181                                             '(("Connection" . "close"))
182                                             '() "" 'HTTP/1.1))))]
183     [result (begin
184               (thread-start! http-thread)
185               ;(format #t "start done.\n")
186               (thread-join! http-thread (selenium-session-timeout sel-sess) #f))])
187    ;(format #t "do-command verb: ~A.\n" verb)
188    ;(format #t "do-command args: ~A.\n" args)
189    ;(format #t "do-command url: ~A.\n" url)
190    ;(format #t "do-command output: ~A.\n" result)
191    result))
192
193; Selenium strings start with "OK,".  The rest is the string.
194(define (selenium::get-string sel-sess verb . args)
195  (string-drop (apply selenium::do-command (cons* sel-sess verb args)) 3))
196
197; Just turn the Selenium string into a number
198(define (selenium::get-number sel-sess verb . args)
199  (string->number (selenium::get-string sel-sess verb args)))
200
201; Selenium booleans are one of the literal strings "true" and
202; "false"
203(define (selenium::get-boolean sel-sess verb . args)
204  (let
205    ([str (selenium::get-string sel-sess verb args)])
206    ; We let cond throw an exception if neither string matches
207    (cond
208      [(string=? "true" str) #t]
209      [(string=? "false" str) #f])))
210
211; Selenium arrays are comma-seperated strings, with \ escapes
212(define (selenium::get-string-array sel-sess verb . args)
213  (map
214    (lambda (str)
215      (string-substitute "(?<!\\\\)\\\\" "" str #t))
216    (string-split-fields
217      "(?<!\\\\),"
218      (selenium::get-string sel-sess verb args)
219      #:infix)))
220
221; Just turn the array bits into numbers
222(define (selenium::get-number-array sel-sess verb . args)
223  (map
224    string->number
225    (selenium::get-string-array sel-sess verb args)))
226
227; Selenium booleans are one of the literal strings "true" and
228; "false"; convert all the bits
229(define (selenium::get-number-array sel-sess verb . args)
230  (map
231    (lambda (str)
232      (cond
233        [(string=? "true" str) #t]
234        [(string=? "false" str) #f]))
235    (selenium::get-string-array sel-sess verb args)))
236
237;-----
238; Starting and Stopping
239
240; Start a Selenium session (that is, launch the browser)
241(define (selenium::start sel-sess)
242  (selenium-session-session-id-set!
243    sel-sess
244    (selenium::get-string
245      sel-sess
246      "getNewBrowserSession"
247      (selenium-session-browser-start-command sel-sess)
248      (selenium-session-browser-url sel-sess))))
249
250; Stop a Selenium session (that is, close the browser)
251(define (selenium::stop sel-sess)
252  (selenium::do-command sel-sess "testComplete" '())
253  (selenium-session-session-id-set! sel-sess #f))
254
255;-----
256; Generated Commands
257
258
259; Clicks on a link, button, checkbox or radio button. If the click action
260; causes a new page to load (like a link usually does), call
261; waitForPageToLoad.
262;
263; 'locator' is an element locator
264(define (selenium::click sel-sess locator)
265            (selenium::do-command sel-sess "click" locator ))
266
267
268; Double clicks on a link, button, checkbox or radio button. If the double click action
269; causes a new page to load (like a link usually does), call
270; waitForPageToLoad.
271;
272; 'locator' is an element locator
273(define (selenium::double_click sel-sess locator)
274            (selenium::do-command sel-sess "doubleClick" locator ))
275
276
277; Clicks on a link, button, checkbox or radio button. If the click action
278; causes a new page to load (like a link usually does), call
279; waitForPageToLoad.
280;
281; 'locator' is an element locator
282; 'coordString' is specifies the x,y position (i.e. - 10,20) of the mouse      event relative to the element returned by the locator.
283(define (selenium::click_at sel-sess locator coordString)
284            (selenium::do-command sel-sess "clickAt" locator coordString ))
285
286
287; Doubleclicks on a link, button, checkbox or radio button. If the action
288; causes a new page to load (like a link usually does), call
289; waitForPageToLoad.
290;
291; 'locator' is an element locator
292; 'coordString' is specifies the x,y position (i.e. - 10,20) of the mouse      event relative to the element returned by the locator.
293(define (selenium::double_click_at sel-sess locator coordString)
294            (selenium::do-command sel-sess "doubleClickAt" locator coordString ))
295
296
297; Explicitly simulate an event, to trigger the corresponding "on<em>event</em>"
298; handler.
299;
300; 'locator' is an element locator
301; 'eventName' is the event name, e.g. "focus" or "blur"
302(define (selenium::fire_event sel-sess locator eventName)
303            (selenium::do-command sel-sess "fireEvent" locator eventName ))
304
305
306; Simulates a user pressing and releasing a key.
307;
308; 'locator' is an element locator
309; '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".
310(define (selenium::key_press sel-sess locator keySequence)
311            (selenium::do-command sel-sess "keyPress" locator keySequence ))
312
313
314; Press the shift key and hold it down until doShiftUp() is called or a new page is loaded.
315;
316(define (selenium::shift_key_down sel-sess )
317            (selenium::do-command sel-sess "shiftKeyDown" ))
318
319
320; Release the shift key.
321;
322(define (selenium::shift_key_up sel-sess )
323            (selenium::do-command sel-sess "shiftKeyUp" ))
324
325
326; Press the meta key and hold it down until doMetaUp() is called or a new page is loaded.
327;
328(define (selenium::meta_key_down sel-sess )
329            (selenium::do-command sel-sess "metaKeyDown" ))
330
331
332; Release the meta key.
333;
334(define (selenium::meta_key_up sel-sess )
335            (selenium::do-command sel-sess "metaKeyUp" ))
336
337
338; Press the alt key and hold it down until doAltUp() is called or a new page is loaded.
339;
340(define (selenium::alt_key_down sel-sess )
341            (selenium::do-command sel-sess "altKeyDown" ))
342
343
344; Release the alt key.
345;
346(define (selenium::alt_key_up sel-sess )
347            (selenium::do-command sel-sess "altKeyUp" ))
348
349
350; Press the control key and hold it down until doControlUp() is called or a new page is loaded.
351;
352(define (selenium::control_key_down sel-sess )
353            (selenium::do-command sel-sess "controlKeyDown" ))
354
355
356; Release the control key.
357;
358(define (selenium::control_key_up sel-sess )
359            (selenium::do-command sel-sess "controlKeyUp" ))
360
361
362; Simulates a user pressing a key (without releasing it yet).
363;
364; 'locator' is an element locator
365; '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".
366(define (selenium::key_down sel-sess locator keySequence)
367            (selenium::do-command sel-sess "keyDown" locator keySequence ))
368
369
370; Simulates a user releasing a key.
371;
372; 'locator' is an element locator
373; '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".
374(define (selenium::key_up sel-sess locator keySequence)
375            (selenium::do-command sel-sess "keyUp" locator keySequence ))
376
377
378; Simulates a user hovering a mouse over the specified element.
379;
380; 'locator' is an element locator
381(define (selenium::mouse_over sel-sess locator)
382            (selenium::do-command sel-sess "mouseOver" locator ))
383
384
385; Simulates a user moving the mouse pointer away from the specified element.
386;
387; 'locator' is an element locator
388(define (selenium::mouse_out sel-sess locator)
389            (selenium::do-command sel-sess "mouseOut" locator ))
390
391
392; Simulates a user pressing the mouse button (without releasing it yet) on
393; the specified element.
394;
395; 'locator' is an element locator
396(define (selenium::mouse_down sel-sess locator)
397            (selenium::do-command sel-sess "mouseDown" locator ))
398
399
400; Simulates a user pressing the mouse button (without releasing it yet) at
401; the specified location.
402;
403; 'locator' is an element locator
404; 'coordString' is specifies the x,y position (i.e. - 10,20) of the mouse      event relative to the element returned by the locator.
405(define (selenium::mouse_down_at sel-sess locator coordString)
406            (selenium::do-command sel-sess "mouseDownAt" locator coordString ))
407
408
409; Simulates the event that occurs when the user releases the mouse button (i.e., stops
410; holding the button down) on the specified element.
411;
412; 'locator' is an element locator
413(define (selenium::mouse_up sel-sess locator)
414            (selenium::do-command sel-sess "mouseUp" locator ))
415
416
417; Simulates the event that occurs when the user releases the mouse button (i.e., stops
418; holding the button down) at the specified location.
419;
420; 'locator' is an element locator
421; 'coordString' is specifies the x,y position (i.e. - 10,20) of the mouse      event relative to the element returned by the locator.
422(define (selenium::mouse_up_at sel-sess locator coordString)
423            (selenium::do-command sel-sess "mouseUpAt" locator coordString ))
424
425
426; Simulates a user pressing the mouse button (without releasing it yet) on
427; the specified element.
428;
429; 'locator' is an element locator
430(define (selenium::mouse_move sel-sess locator)
431            (selenium::do-command sel-sess "mouseMove" locator ))
432
433
434; Simulates a user pressing the mouse button (without releasing it yet) on
435; the specified element.
436;
437; 'locator' is an element locator
438; 'coordString' is specifies the x,y position (i.e. - 10,20) of the mouse      event relative to the element returned by the locator.
439(define (selenium::mouse_move_at sel-sess locator coordString)
440            (selenium::do-command sel-sess "mouseMoveAt" locator coordString ))
441
442
443; Sets the value of an input field, as though you typed it in.
444;
445; Can also be used to set the value of combo boxes, check boxes, etc. In these cases,
446; value should be the value of the option selected, not the visible text.
447;
448;
449; 'locator' is an element locator
450; 'value' is the value to type
451(define (selenium::type sel-sess locator value)
452            (selenium::do-command sel-sess "type" locator value ))
453
454
455; Simulates keystroke events on the specified element, as though you typed the value key-by-key.
456;
457; This is a convenience method for calling keyDown, keyUp, keyPress for every character in the specified string;
458; this is useful for dynamic UI widgets (like auto-completing combo boxes) that require explicit key events.
459; Unlike the simple "type" command, which forces the specified value into the page directly, this command
460; may or may not have any visible effect, even in cases where typing keys would normally have a visible effect.
461; For example, if you use "typeKeys" on a form element, you may or may not see the results of what you typed in
462; the field.
463; 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
464; send the keystroke events corresponding to what you just typed.
465;
466;
467; 'locator' is an element locator
468; 'value' is the value to type
469(define (selenium::type_keys sel-sess locator value)
470            (selenium::do-command sel-sess "typeKeys" locator value ))
471
472
473; 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.,
474; the delay is 0 milliseconds.
475;
476; 'value' is the number of milliseconds to pause after operation
477(define (selenium::set_speed sel-sess value)
478            (selenium::do-command sel-sess "setSpeed" value ))
479
480
481; 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.,
482; the delay is 0 milliseconds.
483;
484; See also setSpeed.
485;
486(define (selenium::get_speed sel-sess )
487            (selenium::do-command sel-sess "getSpeed" ))
488
489
490; Check a toggle-button (checkbox/radio)
491;
492; 'locator' is an element locator
493(define (selenium::check sel-sess locator)
494            (selenium::do-command sel-sess "check" locator ))
495
496
497; Uncheck a toggle-button (checkbox/radio)
498;
499; 'locator' is an element locator
500(define (selenium::uncheck sel-sess locator)
501            (selenium::do-command sel-sess "uncheck" locator ))
502
503
504; Select an option from a drop-down using an option locator.
505;
506;
507; Option locators provide different ways of specifying options of an HTML
508; Select element (e.g. for selecting a specific option, or for asserting
509; that the selected option satisfies a specification). There are several
510; forms of Select Option Locator.
511;
512; <b>label</b>=<em>labelPattern</em>:
513; matches options based on their labels, i.e. the visible text. (This
514; is the default.)
515; label=regexp:^[Oo]ther
516; <b>value</b>=<em>valuePattern</em>:
517; matches options based on their values.
518; value=other
519; <b>id</b>=<em>id</em>:
520;
521; matches options based on their ids.
522; id=option1
523; <b>index</b>=<em>index</em>:
524; matches an option based on its index (offset from zero).
525; index=2
526;
527;
528; If no option locator prefix is provided, the default behaviour is to match on <b>label</b>.
529;
530;
531;
532; 'selectLocator' is an element locator identifying a drop-down menu
533; 'optionLocator' is an option locator (a label by default)
534(define (selenium::select sel-sess selectLocator optionLocator)
535            (selenium::do-command sel-sess "select" selectLocator optionLocator ))
536
537
538; Add a selection to the set of selected options in a multi-select element using an option locator.
539;
540; @see #doSelect for details of option locators
541;
542; 'locator' is an element locator identifying a multi-select box
543; 'optionLocator' is an option locator (a label by default)
544(define (selenium::add_selection sel-sess locator optionLocator)
545            (selenium::do-command sel-sess "addSelection" locator optionLocator ))
546
547
548; Remove a selection from the set of selected options in a multi-select element using an option locator.
549;
550; @see #doSelect for details of option locators
551;
552; 'locator' is an element locator identifying a multi-select box
553; 'optionLocator' is an option locator (a label by default)
554(define (selenium::remove_selection sel-sess locator optionLocator)
555            (selenium::do-command sel-sess "removeSelection" locator optionLocator ))
556
557
558; Unselects all of the selected options in a multi-select element.
559;
560; 'locator' is an element locator identifying a multi-select box
561(define (selenium::remove_all_selections sel-sess locator)
562            (selenium::do-command sel-sess "removeAllSelections" locator ))
563
564
565; Submit the specified form. This is particularly useful for forms without
566; submit buttons, e.g. single-input "Search" forms.
567;
568; 'formLocator' is an element locator for the form you want to submit
569(define (selenium::submit sel-sess formLocator)
570            (selenium::do-command sel-sess "submit" formLocator ))
571
572
573; Opens an URL in the test frame. This accepts both relative and absolute
574; URLs.
575;
576; The "open" command waits for the page to load before proceeding,
577; ie. the "AndWait" suffix is implicit.
578;
579; <em>Note</em>: The URL must be on the same domain as the runner HTML
580; due to security restrictions in the browser (Same Origin Policy). If you
581; need to open an URL on another domain, use the Selenium Server to start a
582; new browser session on that domain.
583;
584; 'url' is the URL to open; may be relative or absolute
585(define (selenium::open sel-sess url)
586            (selenium::do-command sel-sess "open" url ))
587
588
589; Opens a popup window (if a window with that ID isn't already open).
590; After opening the window, you'll need to select it using the selectWindow
591; command.
592;
593; 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).
594; In those cases, you can force Selenium to notice the open window's name by using the Selenium openWindow command, using
595; an empty (blank) url, like this: openWindow("", "myFunnyWindow").
596;
597;
598; 'url' is the URL to open, which can be blank
599; 'windowID' is the JavaScript window ID of the window to select
600(define (selenium::open_window sel-sess url windowID)
601            (selenium::do-command sel-sess "openWindow" url windowID ))
602
603
604; Selects a popup window; once a popup window has been selected, all
605; commands go to that window. To select the main window again, use null
606; as the target.
607;
608; Note that there is a big difference between a window's internal JavaScript "name" property
609; and the "title" of a given window's document (which is normally what you actually see, as an end user,
610; in the title bar of the window).  The "name" is normally invisible to the end-user; it's the second
611; parameter "windowName" passed to the JavaScript method window.open(url, windowName, windowFeatures, replaceFlag)
612; (which selenium intercepts).
613; Selenium has several strategies for finding the window object referred to by the "windowID" parameter.
614; 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).
615; 2.) if the value of the "windowID" parameter is a JavaScript variable name in the current application window, then it is assumed
616; that this variable contains the return value from a call to the JavaScript window.open() method.
617; 3.) Otherwise, selenium looks in a hash it maintains that maps string names to window "names".
618; 4.) If <em>that</em> fails, we'll try looping over all of the known windows to try to find the appropriate "title".
619; Since "title" is not necessarily unique, this may have unexpected behavior.
620; If you're having trouble figuring out what is the name of a window that you want to manipulate, look at the selenium log messages
621; which identify the names of windows created via window.open (and therefore intercepted by selenium).  You will see messages
622; like the following for each window as it is opened:
623; <tt>debug: window.open call intercepted; window ID (which you can use with selectWindow()) is "myNewWindow"</tt>
624; 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).
625; (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
626; an empty (blank) url, like this: openWindow("", "myFunnyWindow").
627;
628;
629; 'windowID' is the JavaScript window ID of the window to select
630(define (selenium::select_window sel-sess windowID)
631            (selenium::do-command sel-sess "selectWindow" windowID ))
632
633
634; Selects a frame within the current window.  (You may invoke this command
635; multiple times to select nested frames.)  To select the parent frame, use
636; "relative=parent" as a locator; to select the top frame, use "relative=top".
637; You can also select a frame by its 0-based index number; select the first frame with
638; "index=0", or the third frame with "index=2".
639;
640; You may also use a DOM expression to identify the frame you want directly,
641; like this: <tt>dom=frames["main"].frames["subframe"]</tt>
642;
643;
644; 'locator' is an element locator identifying a frame or iframe
645(define (selenium::select_frame sel-sess locator)
646            (selenium::do-command sel-sess "selectFrame" locator ))
647
648
649; Determine whether current/locator identify the frame containing this running code.
650;
651; This is useful in proxy injection mode, where this code runs in every
652; browser frame and window, and sometimes the selenium server needs to identify
653; the "current" frame.  In this case, when the test calls selectFrame, this
654; routine is called for each frame to figure out which one has been selected.
655; The selected frame will return true, while all others will return false.
656;
657;
658; 'currentFrameString' is starting frame
659; 'target' is new frame (which might be relative to the current one)
660(define (selenium::get_whether_this_frame_match_frame_expression sel-sess currentFrameString target)
661            (selenium::get-boolean sel-sess "getWhetherThisFrameMatchFrameExpression" currentFrameString target ))
662
663
664; Determine whether currentWindowString plus target identify the window containing this running code.
665;
666; This is useful in proxy injection mode, where this code runs in every
667; browser frame and window, and sometimes the selenium server needs to identify
668; the "current" window.  In this case, when the test calls selectWindow, this
669; routine is called for each window to figure out which one has been selected.
670; The selected window will return true, while all others will return false.
671;
672;
673; 'currentWindowString' is starting window
674; 'target' is new window (which might be relative to the current one, e.g., "_parent")
675(define (selenium::get_whether_this_window_match_window_expression sel-sess currentWindowString target)
676            (selenium::get-boolean sel-sess "getWhetherThisWindowMatchWindowExpression" currentWindowString target ))
677
678
679; Waits for a popup window to appear and load up.
680;
681; 'windowID' is the JavaScript window ID of the window that will appear
682; 'timeout' is a timeout in milliseconds, after which the action will return with an error
683(define (selenium::wait_for_pop_up sel-sess windowID timeout)
684            (selenium::do-command sel-sess "waitForPopUp" windowID timeout ))
685
686
687; By default, Selenium's overridden window.confirm() function will
688; return true, as if the user had manually clicked OK; after running
689; this command, the next call to confirm() will return false, as if
690; the user had clicked Cancel.  Selenium will then resume using the
691; default behavior for future confirmations, automatically returning
692; true (OK) unless/until you explicitly call this command for each
693; confirmation.
694;
695(define (selenium::choose_cancel_on_next_confirmation sel-sess )
696            (selenium::do-command sel-sess "chooseCancelOnNextConfirmation" ))
697
698
699; Undo the effect of calling chooseCancelOnNextConfirmation.  Note
700; that Selenium's overridden window.confirm() function will normally automatically
701; return true, as if the user had manually clicked OK, so you shouldn't
702; need to use this command unless for some reason you need to change
703; your mind prior to the next confirmation.  After any confirmation, Selenium will resume using the
704; default behavior for future confirmations, automatically returning
705; true (OK) unless/until you explicitly call chooseCancelOnNextConfirmation for each
706; confirmation.
707;
708(define (selenium::choose_ok_on_next_confirmation sel-sess )
709            (selenium::do-command sel-sess "chooseOkOnNextConfirmation" ))
710
711
712; Instructs Selenium to return the specified answer string in response to
713; the next JavaScript prompt [window.prompt()].
714;
715; 'answer' is the answer to give in response to the prompt pop-up
716(define (selenium::answer_on_next_prompt sel-sess answer)
717            (selenium::do-command sel-sess "answerOnNextPrompt" answer ))
718
719
720; Simulates the user clicking the "back" button on their browser.
721;
722(define (selenium::go_back sel-sess )
723            (selenium::do-command sel-sess "goBack" ))
724
725
726; Simulates the user clicking the "Refresh" button on their browser.
727;
728(define (selenium::refresh sel-sess )
729            (selenium::do-command sel-sess "refresh" ))
730
731
732; Simulates the user clicking the "close" button in the titlebar of a popup
733; window or tab.
734;
735(define (selenium::close sel-sess )
736            (selenium::do-command sel-sess "close" ))
737
738
739; Has an alert occurred?
740;
741;
742; This function never throws an exception
743;
744;
745;
746(define (selenium::is_alert_present sel-sess )
747            (selenium::get-boolean sel-sess "isAlertPresent" ))
748
749
750; Has a prompt occurred?
751;
752;
753; This function never throws an exception
754;
755;
756;
757(define (selenium::is_prompt_present sel-sess )
758            (selenium::get-boolean sel-sess "isPromptPresent" ))
759
760
761; Has confirm() been called?
762;
763;
764; This function never throws an exception
765;
766;
767;
768(define (selenium::is_confirmation_present sel-sess )
769            (selenium::get-boolean sel-sess "isConfirmationPresent" ))
770
771
772; Retrieves the message of a JavaScript alert generated during the previous action, or fail if there were no alerts.
773;
774; Getting an alert has the same effect as manually clicking OK. If an
775; alert is generated but you do not get/verify it, the next Selenium action
776; will fail.
777; NOTE: under Selenium, JavaScript alerts will NOT pop up a visible alert
778; dialog.
779; NOTE: Selenium does NOT support JavaScript alerts that are generated in a
780; page's onload() event handler. In this case a visible dialog WILL be
781; generated and Selenium will hang until someone manually clicks OK.
782;
783;
784(define (selenium::get_alert sel-sess )
785            (selenium::get-string sel-sess "getAlert" ))
786
787
788; Retrieves the message of a JavaScript confirmation dialog generated during
789; the previous action.
790;
791;
792; By default, the confirm function will return true, having the same effect
793; as manually clicking OK. This can be changed by prior execution of the
794; chooseCancelOnNextConfirmation command. If an confirmation is generated
795; but you do not get/verify it, the next Selenium action will fail.
796;
797;
798; NOTE: under Selenium, JavaScript confirmations will NOT pop up a visible
799; dialog.
800;
801;
802; NOTE: Selenium does NOT support JavaScript confirmations that are
803; generated in a page's onload() event handler. In this case a visible
804; dialog WILL be generated and Selenium will hang until you manually click
805; OK.
806;
807;
808;
809(define (selenium::get_confirmation sel-sess )
810            (selenium::get-string sel-sess "getConfirmation" ))
811
812
813; Retrieves the message of a JavaScript question prompt dialog generated during
814; the previous action.
815;
816; Successful handling of the prompt requires prior execution of the
817; answerOnNextPrompt command. If a prompt is generated but you
818; do not get/verify it, the next Selenium action will fail.
819; NOTE: under Selenium, JavaScript prompts will NOT pop up a visible
820; dialog.
821; NOTE: Selenium does NOT support JavaScript prompts that are generated in a
822; page's onload() event handler. In this case a visible dialog WILL be
823; generated and Selenium will hang until someone manually clicks OK.
824;
825;
826(define (selenium::get_prompt sel-sess )
827            (selenium::get-string sel-sess "getPrompt" ))
828
829
830; Gets the absolute URL of the current page.
831;
832(define (selenium::get_location sel-sess )
833            (selenium::get-string sel-sess "getLocation" ))
834
835
836; Gets the title of the current page.
837;
838(define (selenium::get_title sel-sess )
839            (selenium::get-string sel-sess "getTitle" ))
840
841
842; Gets the entire text of the page.
843;
844(define (selenium::get_body_text sel-sess )
845            (selenium::get-string sel-sess "getBodyText" ))
846
847
848; Gets the (whitespace-trimmed) value of an input field (or anything else with a value parameter).
849; For checkbox/radio elements, the value will be "on" or "off" depending on
850; whether the element is checked or not.
851;
852; 'locator' is an element locator
853(define (selenium::get_value sel-sess locator)
854            (selenium::get-string sel-sess "getValue" locator ))
855
856
857; Gets the text of an element. This works for any element that contains
858; text. This command uses either the textContent (Mozilla-like browsers) or
859; the innerText (IE-like browsers) of the element, which is the rendered
860; text shown to the user.
861;
862; 'locator' is an element locator
863(define (selenium::get_text sel-sess locator)
864            (selenium::get-string sel-sess "getText" locator ))
865
866
867; Briefly changes the backgroundColor of the specified element yellow.  Useful for debugging.
868;
869; 'locator' is an element locator
870(define (selenium::highlight sel-sess locator)
871            (selenium::do-command sel-sess "highlight" locator ))
872
873
874; Gets the result of evaluating the specified JavaScript snippet.  The snippet may
875; have multiple lines, but only the result of the last line will be returned.
876;
877; Note that, by default, the snippet will run in the context of the "selenium"
878; object itself, so <tt>this</tt> will refer to the Selenium object.  Use <tt>window</tt> to
879; refer to the window of your application, e.g. <tt>window.document.getElementById('foo')</tt>
880; If you need to use
881; a locator to refer to a single element in your application page, you can
882; use <tt>this.browserbot.findElement("id=foo")</tt> where "id=foo" is your locator.
883;
884;
885; 'script' is the JavaScript snippet to run
886(define (selenium::get_eval sel-sess script)
887            (selenium::get-string sel-sess "getEval" script ))
888
889
890; Gets whether a toggle-button (checkbox/radio) is checked.  Fails if the specified element doesn't exist or isn't a toggle-button.
891;
892; 'locator' is an element locator pointing to a checkbox or radio button
893(define (selenium::is_checked sel-sess locator)
894            (selenium::get-boolean sel-sess "isChecked" locator ))
895
896
897; Gets the text from a cell of a table. The cellAddress syntax
898; tableLocator.row.column, where row and column start at 0.
899;
900; 'tableCellAddress' is a cell address, e.g. "foo.1.4"
901(define (selenium::get_table sel-sess tableCellAddress)
902            (selenium::get-string sel-sess "getTable" tableCellAddress ))
903
904
905; Gets all option labels (visible text) for selected options in the specified select or multi-select element.
906;
907; 'selectLocator' is an element locator identifying a drop-down menu
908(define (selenium::get_selected_labels sel-sess selectLocator)
909            (selenium::get-string-array sel-sess "getSelectedLabels" selectLocator ))
910
911
912; Gets option label (visible text) for selected option in the specified select element.
913;
914; 'selectLocator' is an element locator identifying a drop-down menu
915(define (selenium::get_selected_label sel-sess selectLocator)
916            (selenium::get-string sel-sess "getSelectedLabel" selectLocator ))
917
918
919; Gets all option values (value attributes) for selected options in the specified select or multi-select element.
920;
921; 'selectLocator' is an element locator identifying a drop-down menu
922(define (selenium::get_selected_values sel-sess selectLocator)
923            (selenium::get-string-array sel-sess "getSelectedValues" selectLocator ))
924
925
926; Gets option value (value attribute) for selected option in the specified select element.
927;
928; 'selectLocator' is an element locator identifying a drop-down menu
929(define (selenium::get_selected_value sel-sess selectLocator)
930            (selenium::get-string sel-sess "getSelectedValue" selectLocator ))
931
932
933; Gets all option indexes (option number, starting at 0) for selected options in the specified select or multi-select element.
934;
935; 'selectLocator' is an element locator identifying a drop-down menu
936(define (selenium::get_selected_indexes sel-sess selectLocator)
937            (selenium::get-string-array sel-sess "getSelectedIndexes" selectLocator ))
938
939
940; Gets option index (option number, starting at 0) for selected option in the specified select element.
941;
942; 'selectLocator' is an element locator identifying a drop-down menu
943(define (selenium::get_selected_index sel-sess selectLocator)
944            (selenium::get-string sel-sess "getSelectedIndex" selectLocator ))
945
946
947; Gets all option element IDs for selected options in the specified select or multi-select element.
948;
949; 'selectLocator' is an element locator identifying a drop-down menu
950(define (selenium::get_selected_ids sel-sess selectLocator)
951            (selenium::get-string-array sel-sess "getSelectedIds" selectLocator ))
952
953
954; Gets option element ID for selected option in the specified select element.
955;
956; 'selectLocator' is an element locator identifying a drop-down menu
957(define (selenium::get_selected_id sel-sess selectLocator)
958            (selenium::get-string sel-sess "getSelectedId" selectLocator ))
959
960
961; Determines whether some option in a drop-down menu is selected.
962;
963; 'selectLocator' is an element locator identifying a drop-down menu
964(define (selenium::is_something_selected sel-sess selectLocator)
965            (selenium::get-boolean sel-sess "isSomethingSelected" selectLocator ))
966
967
968; Gets all option labels in the specified select drop-down.
969;
970; 'selectLocator' is an element locator identifying a drop-down menu
971(define (selenium::get_select_options sel-sess selectLocator)
972            (selenium::get-string-array sel-sess "getSelectOptions" selectLocator ))
973
974
975; Gets the value of an element attribute.
976;
977; 'attributeLocator' is an element locator followed by an @ sign and then the name of the attribute, e.g. "foo@bar"
978(define (selenium::get_attribute sel-sess attributeLocator)
979            (selenium::get-string sel-sess "getAttribute" attributeLocator ))
980
981
982; Verifies that the specified text pattern appears somewhere on the rendered page shown to the user.
983;
984; 'pattern' is a pattern to match with the text of the page
985(define (selenium::is_text_present sel-sess pattern)
986            (selenium::get-boolean sel-sess "isTextPresent" pattern ))
987
988
989; Verifies that the specified element is somewhere on the page.
990;
991; 'locator' is an element locator
992(define (selenium::is_element_present sel-sess locator)
993            (selenium::get-boolean sel-sess "isElementPresent" locator ))
994
995
996; Determines if the specified element is visible. An
997; element can be rendered invisible by setting the CSS "visibility"
998; property to "hidden", or the "display" property to "none", either for the
999; element itself or one if its ancestors.  This method will fail if
1000; the element is not present.
1001;
1002; 'locator' is an element locator
1003(define (selenium::is_visible sel-sess locator)
1004            (selenium::get-boolean sel-sess "isVisible" locator ))
1005
1006
1007; Determines whether the specified input element is editable, ie hasn't been disabled.
1008; This method will fail if the specified element isn't an input element.
1009;
1010; 'locator' is an element locator
1011(define (selenium::is_editable sel-sess locator)
1012            (selenium::get-boolean sel-sess "isEditable" locator ))
1013
1014
1015; Returns the IDs of all buttons on the page.
1016;
1017; If a given button has no ID, it will appear as "" in this array.
1018;
1019;
1020(define (selenium::get_all_buttons sel-sess )
1021            (selenium::get-string-array sel-sess "getAllButtons" ))
1022
1023
1024; Returns the IDs of all links on the page.
1025;
1026; If a given link has no ID, it will appear as "" in this array.
1027;
1028;
1029(define (selenium::get_all_links sel-sess )
1030            (selenium::get-string-array sel-sess "getAllLinks" ))
1031
1032
1033; Returns the IDs of all input fields on the page.
1034;
1035; If a given field has no ID, it will appear as "" in this array.
1036;
1037;
1038(define (selenium::get_all_fields sel-sess )
1039            (selenium::get-string-array sel-sess "getAllFields" ))
1040
1041
1042; Returns every instance of some attribute from all known windows.
1043;
1044; 'attributeName' is name of an attribute on the windows
1045(define (selenium::get_attribute_from_all_windows sel-sess attributeName)
1046            (selenium::get-string-array sel-sess "getAttributeFromAllWindows" attributeName ))
1047
1048
1049; deprecated - use dragAndDrop instead
1050;
1051; 'locator' is an element locator
1052; 'movementsString' is offset in pixels from the current location to which the element should be moved, e.g., "+70,-300"
1053(define (selenium::dragdrop sel-sess locator movementsString)
1054            (selenium::do-command sel-sess "dragdrop" locator movementsString ))
1055
1056
1057; Configure the number of pixels between "mousemove" events during dragAndDrop commands (default=10).
1058; Setting this value to 0 means that we'll send a "mousemove" event to every single pixel
1059; in between the start location and the end location; that can be very slow, and may
1060; cause some browsers to force the JavaScript to timeout.
1061; If the mouse speed is greater than the distance between the two dragged objects, we'll
1062; just send one "mousemove" at the start location and then one final one at the end location.
1063;
1064;
1065; 'pixels' is the number of pixels between "mousemove" events
1066(define (selenium::set_mouse_speed sel-sess pixels)
1067            (selenium::do-command sel-sess "setMouseSpeed" pixels ))
1068
1069
1070; Returns the number of pixels between "mousemove" events during dragAndDrop commands (default=10).
1071;
1072(define (selenium::get_mouse_speed sel-sess )
1073            (selenium::get-number sel-sess "getMouseSpeed" ))
1074
1075
1076; Drags an element a certain distance and then drops it
1077;
1078; 'locator' is an element locator
1079; 'movementsString' is offset in pixels from the current location to which the element should be moved, e.g., "+70,-300"
1080(define (selenium::drag_and_drop sel-sess locator movementsString)
1081            (selenium::do-command sel-sess "dragAndDrop" locator movementsString ))
1082
1083
1084; Drags an element and drops it on another element
1085;
1086; 'locatorOfObjectToBeDragged' is an element to be dragged
1087; 'locatorOfDragDestinationObject' is an element whose location (i.e., whose center-most pixel) will be the point where locatorOfObjectToBeDragged  is dropped
1088(define (selenium::drag_and_drop_to_object sel-sess locatorOfObjectToBeDragged locatorOfDragDestinationObject)
1089            (selenium::do-command sel-sess "dragAndDropToObject" locatorOfObjectToBeDragged locatorOfDragDestinationObject ))
1090
1091
1092; Gives focus to the currently selected window
1093;
1094(define (selenium::window_focus sel-sess )
1095            (selenium::do-command sel-sess "windowFocus" ))
1096
1097
1098; Resize currently selected window to take up the entire screen
1099;
1100(define (selenium::window_maximize sel-sess )
1101            (selenium::do-command sel-sess "windowMaximize" ))
1102
1103
1104; Returns the IDs of all windows that the browser knows about.
1105;
1106(define (selenium::get_all_window_ids sel-sess )
1107            (selenium::get-string-array sel-sess "getAllWindowIds" ))
1108
1109
1110; Returns the names of all windows that the browser knows about.
1111;
1112(define (selenium::get_all_window_names sel-sess )
1113            (selenium::get-string-array sel-sess "getAllWindowNames" ))
1114
1115
1116; Returns the titles of all windows that the browser knows about.
1117;
1118(define (selenium::get_all_window_titles sel-sess )
1119            (selenium::get-string-array sel-sess "getAllWindowTitles" ))
1120
1121
1122; Returns the entire HTML source between the opening and
1123; closing "html" tags.
1124;
1125(define (selenium::get_html_source sel-sess )
1126            (selenium::get-string sel-sess "getHtmlSource" ))
1127
1128
1129; Moves the text cursor to the specified position in the given input element or textarea.
1130; This method will fail if the specified element isn't an input element or textarea.
1131;
1132; 'locator' is an element locator pointing to an input element or textarea
1133; '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.
1134(define (selenium::set_cursor_position sel-sess locator position)
1135            (selenium::do-command sel-sess "setCursorPosition" locator position ))
1136
1137
1138; Get the relative index of an element to its parent (starting from 0). The comment node and empty text node
1139; will be ignored.
1140;
1141; 'locator' is an element locator pointing to an element
1142(define (selenium::get_element_index sel-sess locator)
1143            (selenium::get-number sel-sess "getElementIndex" locator ))
1144
1145
1146; Check if these two elements have same parent and are ordered siblings in the DOM. Two same elements will
1147; not be considered ordered.
1148;
1149; 'locator1' is an element locator pointing to the first element
1150; 'locator2' is an element locator pointing to the second element
1151(define (selenium::is_ordered sel-sess locator1 locator2)
1152            (selenium::get-boolean sel-sess "isOrdered" locator1 locator2 ))
1153
1154
1155; Retrieves the horizontal position of an element
1156;
1157; 'locator' is an element locator pointing to an element OR an element itself
1158(define (selenium::get_element_position_left sel-sess locator)
1159            (selenium::get-number sel-sess "getElementPositionLeft" locator ))
1160
1161
1162; Retrieves the vertical position of an element
1163;
1164; 'locator' is an element locator pointing to an element OR an element itself
1165(define (selenium::get_element_position_top sel-sess locator)
1166            (selenium::get-number sel-sess "getElementPositionTop" locator ))
1167
1168
1169; Retrieves the width of an element
1170;
1171; 'locator' is an element locator pointing to an element
1172(define (selenium::get_element_width sel-sess locator)
1173            (selenium::get-number sel-sess "getElementWidth" locator ))
1174
1175
1176; Retrieves the height of an element
1177;
1178; 'locator' is an element locator pointing to an element
1179(define (selenium::get_element_height sel-sess locator)
1180            (selenium::get-number sel-sess "getElementHeight" locator ))
1181
1182
1183; Retrieves the text cursor position in the given input element or textarea; beware, this may not work perfectly on all browsers.
1184;
1185; Specifically, if the cursor/selection has been cleared by JavaScript, this command will tend to
1186; 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.
1187;
1188; This method will fail if the specified element isn't an input element or textarea, or there is no cursor in the element.
1189;
1190; 'locator' is an element locator pointing to an input element or textarea
1191(define (selenium::get_cursor_position sel-sess locator)
1192            (selenium::get-number sel-sess "getCursorPosition" locator ))
1193
1194
1195; Returns the specified expression.
1196;
1197; This is useful because of JavaScript preprocessing.
1198; It is used to generate commands like assertExpression and waitForExpression.
1199;
1200;
1201; 'expression' is the value to return
1202(define (selenium::get_expression sel-sess expression)
1203            (selenium::get-string sel-sess "getExpression" expression ))
1204
1205
1206; Returns the number of nodes that match the specified xpath, eg. "//table" would give
1207; the number of tables.
1208;
1209; 'xpath' is the xpath expression to evaluate. do NOT wrap this expression in a 'count()' function; we will do that for you.
1210(define (selenium::get_xpath_count sel-sess xpath)
1211            (selenium::get-number sel-sess "getXpathCount" xpath ))
1212
1213
1214; Temporarily sets the "id" attribute of the specified element, so you can locate it in the future
1215; using its ID rather than a slow/complicated XPath.  This ID will disappear once the page is
1216; reloaded.
1217;
1218; 'locator' is an element locator pointing to an element
1219; 'identifier' is a string to be used as the ID of the specified element
1220(define (selenium::assign_id sel-sess locator identifier)
1221            (selenium::do-command sel-sess "assignId" locator identifier ))
1222
1223
1224; Specifies whether Selenium should use the native in-browser implementation
1225; of XPath (if any native version is available); if you pass "false" to
1226; this function, we will always use our pure-JavaScript xpath library.
1227; Using the pure-JS xpath library can improve the consistency of xpath
1228; element locators between different browser vendors, but the pure-JS
1229; version is much slower than the native implementations.
1230;
1231; 'allow' is boolean, true means we'll prefer to use native XPath; false means we'll only use JS XPath
1232(define (selenium::allow_native_xpath sel-sess allow)
1233            (selenium::do-command sel-sess "allowNativeXpath" allow ))
1234
1235
1236; Runs the specified JavaScript snippet repeatedly until it evaluates to "true".
1237; The snippet may have multiple lines, but only the result of the last line
1238; will be considered.
1239;
1240; Note that, by default, the snippet will be run in the runner's test window, not in the window
1241; of your application.  To get the window of your application, you can use
1242; the JavaScript snippet <tt>selenium.browserbot.getCurrentWindow()</tt>, and then
1243; run your JavaScript in there
1244;
1245;
1246; 'script' is the JavaScript snippet to run
1247; 'timeout' is a timeout in milliseconds, after which this command will return with an error
1248(define (selenium::wait_for_condition sel-sess script timeout)
1249            (selenium::do-command sel-sess "waitForCondition" script timeout ))
1250
1251
1252; Specifies the amount of time that Selenium will wait for actions to complete.
1253;
1254; Actions that require waiting include "open" and the "waitFor*" actions.
1255;
1256; The default timeout is 30 seconds.
1257;
1258; 'timeout' is a timeout in milliseconds, after which the action will return with an error
1259(define (selenium::set_timeout sel-sess timeout)
1260            (selenium::do-command sel-sess "setTimeout" timeout ))
1261
1262
1263; Waits for a new page to load.
1264;
1265; You can use this command instead of the "AndWait" suffixes, "clickAndWait", "selectAndWait", "typeAndWait" etc.
1266; (which are only available in the JS API).
1267; Selenium constantly keeps track of new pages loading, and sets a "newPageLoaded"
1268; flag when it first notices a page load.  Running any other Selenium command after
1269; turns the flag to false.  Hence, if you want to wait for a page to load, you must
1270; wait immediately after a Selenium command that caused a page-load.
1271;
1272;
1273; 'timeout' is a timeout in milliseconds, after which this command will return with an error
1274(define (selenium::wait_for_page_to_load sel-sess timeout)
1275            (selenium::do-command sel-sess "waitForPageToLoad" timeout ))
1276
1277
1278; Waits for a new frame to load.
1279;
1280; Selenium constantly keeps track of new pages and frames loading,
1281; and sets a "newPageLoaded" flag when it first notices a page load.
1282;
1283;
1284; See waitForPageToLoad for more information.
1285;
1286; 'frameAddress' is FrameAddress from the server side
1287; 'timeout' is a timeout in milliseconds, after which this command will return with an error
1288(define (selenium::wait_for_frame_to_load sel-sess frameAddress timeout)
1289            (selenium::do-command sel-sess "waitForFrameToLoad" frameAddress timeout ))
1290
1291
1292; Return all cookies of the current page under test.
1293;
1294(define (selenium::get_cookie sel-sess )
1295            (selenium::get-string sel-sess "getCookie" ))
1296
1297
1298; Create a new cookie whose path and domain are same with those of current page
1299; under test, unless you specified a path for this cookie explicitly.
1300;
1301; 'nameValuePair' is name and value of the cookie in a format "name=value"
1302; 'optionsString' is options for the cookie. Currently supported options include 'path' and 'max_age'.      the optionsString's format is "path=/path/, max_age=60". The order of options are irrelevant, the unit      of the value of 'max_age' is second.
1303(define (selenium::create_cookie sel-sess nameValuePair optionsString)
1304            (selenium::do-command sel-sess "createCookie" nameValuePair optionsString ))
1305
1306
1307; Delete a named cookie with specified path.
1308;
1309; 'name' is the name of the cookie to be deleted
1310; 'path' is the path property of the cookie to be deleted
1311(define (selenium::delete_cookie sel-sess name path)
1312            (selenium::do-command sel-sess "deleteCookie" name path ))
1313
1314
1315; Sets the threshold for browser-side logging messages; log messages beneath this threshold will be discarded.
1316; Valid logLevel strings are: "debug", "info", "warn", "error" or "off".
1317; To see the browser logs, you need to
1318; either show the log window in GUI mode, or enable browser-side logging in Selenium RC.
1319;
1320; 'logLevel' is one of the following: "debug", "info", "warn", "error" or "off"
1321(define (selenium::set_browser_log_level sel-sess logLevel)
1322            (selenium::do-command sel-sess "setBrowserLogLevel" logLevel ))
1323
1324
1325; Creates a new "script" tag in the body of the current test window, and
1326; adds the specified text into the body of the command.  Scripts run in
1327; this way can often be debugged more easily than scripts executed using
1328; Selenium's "getEval" command.  Beware that JS exceptions thrown in these script
1329; tags aren't managed by Selenium, so you should probably wrap your script
1330; in try/catch blocks if there is any chance that the script will throw
1331; an exception.
1332;
1333; 'script' is the JavaScript snippet to run
1334(define (selenium::run_script sel-sess script)
1335            (selenium::do-command sel-sess "runScript" script ))
1336
1337
1338; Defines a new function for Selenium to locate elements on the page.
1339; For example,
1340; if you define the strategy "foo", and someone runs click("foo=blah"), we'll
1341; run your function, passing you the string "blah", and click on the element
1342; that your function
1343; returns, or throw an "Element not found" error if your function returns null.
1344;
1345; We'll pass three arguments to your function:
1346; locator: the string the user passed ininWindow: the currently selected windowinDocument: the currently selected document
1347;
1348; The function must return null if the element can't be found.
1349;
1350; 'strategyName' is the name of the strategy to define; this should use only   letters [a-zA-Z] with no spaces or other punctuation.
1351; 'functionDefinition' is a string defining the body of a function in JavaScript.   For example: <tt>return inDocument.getElementById(locator);</tt>
1352(define (selenium::add_location_strategy sel-sess strategyName functionDefinition)
1353            (selenium::do-command sel-sess "addLocationStrategy" strategyName functionDefinition ))
1354
1355
1356; Writes a message to the status bar and adds a note to the browser-side
1357; log.
1358;
1359; 'context' is the message to be sent to the browser
1360(define (selenium::set_context sel-sess context)
1361            (selenium::do-command sel-sess "setContext" context ))
1362
1363
1364; Captures a PNG screenshot to the specified file.
1365;
1366; 'filename' is the absolute path to the file to be written, e.g. "c:\blah\screenshot.png"
1367(define (selenium::capture_screenshot sel-sess filename)
1368            (selenium::do-command sel-sess "captureScreenshot" filename ))
1369
1370
1371
1372
1373
Note: See TracBrowser for help on using the repository browser.