How to use Main method of Example.GetAllLinks.Program class

Best Puppeteer-sharp code snippet using Example.GetAllLinks.Program.Main

Run Puppeteer-sharp automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Program.cs

Source: Program.cs Github

copy
1using System;
2using System.Threading.Tasks;
3using PuppeteerSharp;
4
5namespace Example.GetAllLinks
6{
7    class Program
8    {
9        public static async Task Main(string[] args)
10        {
11            var options = new LaunchOptions { Headless = true };
12            Console.WriteLine("Downloading chromium");
13            await new BrowserFetcher().DownloadAsync(BrowserFetcher.DefaultRevision);
14            Console.WriteLine("Navigating to google.com");
15
16            using (var browser = await Puppeteer.LaunchAsync(options))
17            using (var page = await browser.NewPageAsync())
18            {
19                await page.GoToAsync("http://www.google.com");
20                var jsSelectAllAnchors = @"Array.from(document.querySelectorAll('a')).map(a => a.href);";
21                var urls = await page.EvaluateExpressionAsync<string[]>(jsSelectAllAnchors);
22                foreach (string url in urls)
23                {
24                    Console.WriteLine($"Url: {url}");
25                }
26                Console.WriteLine("Press any key to continue...");
27                Console.ReadLine();
28            }
29        }
30    }
31}
32
Full Screen

DefaultSelenium.cs

Source: DefaultSelenium.cs Github

copy
1/*
2 * Copyright 2006 ThoughtWorks, Inc.
3 *
4 *  Licensed under the Apache License, Version 2.0 (the "License");
5 *  you may not use this file except in compliance with the License.
6 *  You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 *  Unless required by applicable law or agreed to in writing, software
11 *  distributed under the License is distributed on an "AS IS" BASIS,
12 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 *  See the License for the specific language governing permissions and
14 *  limitations under the License.
15 *
16 */
17
18// This file has been automatically generated via XSL
19using System;
20namespace Selenium
21{
22        /// <summary>Defines an object that runs Selenium commands.
23        /// 
24        /// <h3><a name="locators"></a>Element Locators</h3><p>
25        /// Element Locators tell Selenium which HTML element a command refers to.
26        /// The format of a locator is:</p><blockquote><em>locatorType</em><strong>=</strong><em>argument</em></blockquote><p>
27        /// We support the following strategies for locating elements:
28        /// </p><ul><li><strong>identifier</strong>=<em>id</em>: 
29        /// Select the element with the specified @id attribute. If no match is
30        /// found, select the first element whose @name attribute is <em>id</em>.
31        /// (This is normally the default; see below.)</li><li><strong>id</strong>=<em>id</em>:
32        /// Select the element with the specified @id attribute.</li><li><strong>name</strong>=<em>name</em>:
33        /// Select the first element with the specified @name attribute.
34        /// <ul class="first last simple"><li>username</li><li>name=username</li></ul><p>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, <strong>value</strong> is assumed.</p><ul class="first last simple"><li>name=flavour value=chocolate</li></ul></li><li><strong>dom</strong>=<em>javascriptExpression</em>: 
35        /// 
36        /// Find an element by evaluating the specified string.  This allows you to traverse the HTML Document Object
37        /// Model using JavaScript.  Note that you must not return a value in this string; simply make it the last expression in the block.
38        /// <ul class="first last simple"><li>dom=document.forms['myForm'].myDropdown</li><li>dom=document.images[56]</li><li>dom=function foo() { return document.links[1]; }; foo();</li></ul></li><li><strong>xpath</strong>=<em>xpathExpression</em>: 
39        /// Locate an element using an XPath expression.
40        /// <ul class="first last simple"><li>xpath=//img[@alt='The image alt text']</li><li>xpath=//table[@id='table1']//tr[4]/td[2]</li><li>xpath=//a[contains(@href,'#id1')]</li><li>xpath=//a[contains(@href,'#id1')]/@class</li><li>xpath=(//table[@class='stylee'])//th[text()='theHeaderText']/../td</li><li>xpath=//input[@name='name2' and @value='yes']</li><li>xpath=//*[text()="right"]</li></ul></li><li><strong>link</strong>=<em>textPattern</em>:
41        /// Select the link (anchor) element which contains text matching the
42        /// specified <em>pattern</em>.
43        /// <ul class="first last simple"><li>link=The link text</li></ul></li><li><strong>css</strong>=<em>cssSelectorSyntax</em>:
44        /// Select the element using css selectors. Please refer to <a href="http://www.w3.org/TR/REC-CSS2/selector.html">CSS2 selectors</a>, <a href="http://www.w3.org/TR/2001/CR-css3-selectors-20011113/">CSS3 selectors</a> 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.
45        /// <ul class="first last simple"><li>css=a[href="#id3"]</li><li>css=span#firstChild + span</li></ul><p>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). </p></li><li><strong>ui</strong>=<em>uiSpecifierString</em>:
46        /// Locate an element by resolving the UI specifier string to another locator, and evaluating it. See the <a href="http://svn.openqa.org/fisheye/browse/~raw,r=trunk/selenium/trunk/src/main/resources/core/scripts/ui-doc.html">Selenium UI-Element Reference</a> for more details.
47        /// <ul class="first last simple"><li>ui=loginPages::loginButton()</li><li>ui=settingsPages::toggle(label=Hide Email)</li><li>ui=forumPages::postBody(index=2)//a[2]</li></ul></li></ul><p>
48        /// Without an explicit locator prefix, Selenium uses the following default
49        /// strategies:
50        /// </p><ul class="simple"><li><strong>dom</strong>, for locators starting with "document."</li><li><strong>xpath</strong>, for locators starting with "//"</li><li><strong>identifier</strong>, otherwise</li></ul><h3><a name="element-filters">Element Filters</a></h3><blockquote><p>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.</p><p>Filters look much like locators, ie.</p><blockquote><em>filterType</em><strong>=</strong><em>argument</em></blockquote><p>Supported element-filters are:</p><p><strong>value=</strong><em>valuePattern</em></p><blockquote>
51        /// Matches elements based on their values.  This is particularly useful for refining a list of similarly-named toggle-buttons.</blockquote><p><strong>index=</strong><em>index</em></p><blockquote>
52        /// Selects a single element based on its position in the list (offset from zero).</blockquote></blockquote><h3><a name="patterns"></a>String-match Patterns</h3><p>
53        /// Various Pattern syntaxes are available for matching string values:
54        /// </p><ul><li><strong>glob:</strong><em>pattern</em>:
55        /// Match a string against a "glob" (aka "wildmat") pattern. "Glob" is a
56        /// kind of limited regular-expression syntax typically used in command-line
57        /// shells. In a glob pattern, "*" represents any sequence of characters, and "?"
58        /// represents any single character. Glob patterns match against the entire
59        /// string.</li><li><strong>regexp:</strong><em>regexp</em>:
60        /// Match a string using a regular-expression. The full power of JavaScript
61        /// regular-expressions is available.</li><li><strong>regexpi:</strong><em>regexpi</em>:
62        /// Match a string using a case-insensitive regular-expression.</li><li><strong>exact:</strong><em>string</em>:
63        /// 
64        /// Match a string exactly, verbatim, without any of that fancy wildcard
65        /// stuff.</li></ul><p>
66        /// If no pattern prefix is specified, Selenium assumes that it's a "glob"
67        /// pattern.
68        /// </p><p>
69        /// For commands that return multiple values (such as verifySelectOptions),
70        /// the string being matched is a comma-separated list of the return values,
71        /// where both commas and backslashes in the values are backslash-escaped.
72        /// When providing a pattern, the optional matching syntax (i.e. glob,
73        /// regexp, etc.) is specified once, as usual, at the beginning of the
74        /// pattern.
75        /// </p>
76        /// </summary>
77        // This file has been automatically generated using XSL
78        // This part of the file is hard-coded in the XSL
79        public class DefaultSelenium : ISelenium
80        {
81        
82                protected ICommandProcessor commandProcessor;
83                /// <summary>
84                /// Uses a CommandBridgeClient, specifying a server host/port, a command to launch the browser, and a starting URL for the browser.
85            /// 
86            /// <p><i>browserString</i> may be any one of the following:</p>
87            /// <ul>
88            /// <li><code>*firefox [absolute path]</code> - Automatically launch a new Firefox process using a custom Firefox profile.
89            /// This profile will be automatically configured to use the Selenium Server as a proxy and to have all annoying prompts
90            /// ("save your password?" "forms are insecure" "make Firefox your default browser?" disabled.  You may optionally specify
91            /// an absolute path to your firefox executable, or just say "*firefox".  If no absolute path is specified, we'll look for
92            /// firefox.exe in a default location (normally c:\program files\mozilla firefox\firefox.exe), which you can override by
93            /// setting the Java system property <code>firefoxDefaultPath</code> to the correct path to Firefox.</li>
94            /// <li><code>*iexplore [absolute path]</code> - Automatically launch a new Internet Explorer process using custom Windows registry settings.
95            /// This process will be automatically configured to use the Selenium Server as a proxy and to have all annoying prompts
96            /// ("save your password?" "forms are insecure" "make Firefox your default browser?" disabled.  You may optionally specify
97            /// an absolute path to your iexplore executable, or just say "*iexplore".  If no absolute path is specified, we'll look for
98            /// iexplore.exe in a default location (normally c:\program files\internet explorer\iexplore.exe), which you can override by
99            /// setting the Java system property <code>iexploreDefaultPath</code> to the correct path to Internet Explorer.</li>
100            /// <li><code>/path/to/my/browser [other arguments]</code> - You may also simply specify the absolute path to your browser
101            /// executable, or use a relative path to your executable (which we'll try to find on your path).  <b>Warning:</b> If you
102            /// specify your own custom browser, it's up to you to configure it correctly.  At a minimum, you'll need to configure your
103            /// browser to use the Selenium Server as a proxy, and disable all browser-specific prompting.</li>
104            /// </ul>
105            /// </summary>
106            /// 
107            /// <param name="serverHost">the host name on which the Selenium Server resides</param>
108            /// <param name="serverPort">the port on which the Selenium Server is listening</param>
109            /// <param name="browserString">the command string used to launch the browser, e.g. "*firefox", "*iexplore" or "c:\\program files\\internet explorer\\iexplore.exe"</param>
110            /// <param name="browserURL">the starting URL including just a domain name.  We'll start the browser pointing at the Selenium resources on this URL,
111            /// e.g. "http://www.google.com" would send the browser to "http://www.google.com/selenium-server/RemoteRunner.html"</param>
112            public DefaultSelenium(String serverHost, int serverPort, String browserString, String browserURL)
113            {
114                this.commandProcessor = new HttpCommandProcessor(serverHost, serverPort, browserString, browserURL);
115            }
116            
117            /// <summary>
118            /// Uses an arbitrary CommandProcessor
119            /// </summary>
120            public DefaultSelenium(ICommandProcessor processor)
121            {
122                this.commandProcessor = processor;
123            }
124            
125            /// <summary>
126            /// The command processor that handles all of our Selenium commands
127            /// </summary>
128            public ICommandProcessor Processor
129                {
130                get { return this.commandProcessor; }
131                }
132                
133                /// <summary>
134                /// Sets the extension Javascript for the session
135                /// </summary>
136                public void SetExtensionJs(string extensionJs)
137                {
138                        commandProcessor.SetExtensionJs(extensionJs);
139                }
140                
141                /// <summary>
142                /// Starts a new Selenium testing session
143                /// </summary>
144                public void Start()
145                {
146                        commandProcessor.Start();
147                }
148                
149        /// <summary>
150        /// 
151        /// </summary>
152        /// <param name="optionsString"></param>
153        public void Start(string optionsString)
154        {
155            commandProcessor.Start(optionsString);
156        }
157
158                /// <summary>
159                /// Ends the current Selenium testing session (normally killing the browser)
160                /// </summary>
161                public void Stop()
162                {
163                        commandProcessor.Stop();
164                }
165            
166            // From here on, everything in this file has been auto-generated
167            
168                /// <summary>Clicks on a link, button, checkbox or radio button. If the click action
169                /// causes a new page to load (like a link usually does), call
170                /// waitForPageToLoad.
171                /// </summary>
172                /// <param name="locator">an element locator</param>
173                public void Click(String locator)
174                {
175                        commandProcessor.DoCommand("click", new String[] {locator,});
176                }
177
178
179                /// <summary>Double clicks on a link, button, checkbox or radio button. If the double click action
180                /// causes a new page to load (like a link usually does), call
181                /// waitForPageToLoad.
182                /// </summary>
183                /// <param name="locator">an element locator</param>
184                public void DoubleClick(String locator)
185                {
186                        commandProcessor.DoCommand("doubleClick", new String[] {locator,});
187                }
188
189
190                /// <summary>Simulates opening the context menu for the specified element (as might happen if the user "right-clicked" on the element).
191                /// </summary>
192                /// <param name="locator">an element locator</param>
193                public void ContextMenu(String locator)
194                {
195                        commandProcessor.DoCommand("contextMenu", new String[] {locator,});
196                }
197
198
199                /// <summary>Clicks on a link, button, checkbox or radio button. If the click action
200                /// causes a new page to load (like a link usually does), call
201                /// waitForPageToLoad.
202                /// </summary>
203                /// <param name="locator">an element locator</param>
204                /// <param name="coordString">specifies the x,y position (i.e. - 10,20) of the mouse      event relative to the element returned by the locator.</param>
205                public void ClickAt(String locator,String coordString)
206                {
207                        commandProcessor.DoCommand("clickAt", new String[] {locator,coordString,});
208                }
209
210
211                /// <summary>Doubleclicks on a link, button, checkbox or radio button. If the action
212                /// causes a new page to load (like a link usually does), call
213                /// waitForPageToLoad.
214                /// </summary>
215                /// <param name="locator">an element locator</param>
216                /// <param name="coordString">specifies the x,y position (i.e. - 10,20) of the mouse      event relative to the element returned by the locator.</param>
217                public void DoubleClickAt(String locator,String coordString)
218                {
219                        commandProcessor.DoCommand("doubleClickAt", new String[] {locator,coordString,});
220                }
221
222
223                /// <summary>Simulates opening the context menu for the specified element (as might happen if the user "right-clicked" on the element).
224                /// </summary>
225                /// <param name="locator">an element locator</param>
226                /// <param name="coordString">specifies the x,y position (i.e. - 10,20) of the mouse      event relative to the element returned by the locator.</param>
227                public void ContextMenuAt(String locator,String coordString)
228                {
229                        commandProcessor.DoCommand("contextMenuAt", new String[] {locator,coordString,});
230                }
231
232
233                /// <summary>Explicitly simulate an event, to trigger the corresponding "on<em>event</em>"
234                /// handler.
235                /// </summary>
236                /// <param name="locator">an <a href="#locators">element locator</a></param>
237                /// <param name="eventName">the event name, e.g. "focus" or "blur"</param>
238                public void FireEvent(String locator,String eventName)
239                {
240                        commandProcessor.DoCommand("fireEvent", new String[] {locator,eventName,});
241                }
242
243
244                /// <summary>Move the focus to the specified element; for example, if the element is an input field, move the cursor to that field.
245                /// </summary>
246                /// <param name="locator">an <a href="#locators">element locator</a></param>
247                public void Focus(String locator)
248                {
249                        commandProcessor.DoCommand("focus", new String[] {locator,});
250                }
251
252
253                /// <summary>Simulates a user pressing and releasing a key.
254                /// </summary>
255                /// <param name="locator">an <a href="#locators">element locator</a></param>
256                /// <param name="keySequence">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".</param>
257                public void KeyPress(String locator,String keySequence)
258                {
259                        commandProcessor.DoCommand("keyPress", new String[] {locator,keySequence,});
260                }
261
262
263                /// <summary>Press the shift key and hold it down until doShiftUp() is called or a new page is loaded.
264                /// </summary>
265                public void ShiftKeyDown()
266                {
267                        commandProcessor.DoCommand("shiftKeyDown", new String[] {});
268                }
269
270
271                /// <summary>Release the shift key.
272                /// </summary>
273                public void ShiftKeyUp()
274                {
275                        commandProcessor.DoCommand("shiftKeyUp", new String[] {});
276                }
277
278
279                /// <summary>Press the meta key and hold it down until doMetaUp() is called or a new page is loaded.
280                /// </summary>
281                public void MetaKeyDown()
282                {
283                        commandProcessor.DoCommand("metaKeyDown", new String[] {});
284                }
285
286
287                /// <summary>Release the meta key.
288                /// </summary>
289                public void MetaKeyUp()
290                {
291                        commandProcessor.DoCommand("metaKeyUp", new String[] {});
292                }
293
294
295                /// <summary>Press the alt key and hold it down until doAltUp() is called or a new page is loaded.
296                /// </summary>
297                public void AltKeyDown()
298                {
299                        commandProcessor.DoCommand("altKeyDown", new String[] {});
300                }
301
302
303                /// <summary>Release the alt key.
304                /// </summary>
305                public void AltKeyUp()
306                {
307                        commandProcessor.DoCommand("altKeyUp", new String[] {});
308                }
309
310
311                /// <summary>Press the control key and hold it down until doControlUp() is called or a new page is loaded.
312                /// </summary>
313                public void ControlKeyDown()
314                {
315                        commandProcessor.DoCommand("controlKeyDown", new String[] {});
316                }
317
318
319                /// <summary>Release the control key.
320                /// </summary>
321                public void ControlKeyUp()
322                {
323                        commandProcessor.DoCommand("controlKeyUp", new String[] {});
324                }
325
326
327                /// <summary>Simulates a user pressing a key (without releasing it yet).
328                /// </summary>
329                /// <param name="locator">an <a href="#locators">element locator</a></param>
330                /// <param name="keySequence">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".</param>
331                public void KeyDown(String locator,String keySequence)
332                {
333                        commandProcessor.DoCommand("keyDown", new String[] {locator,keySequence,});
334                }
335
336
337                /// <summary>Simulates a user releasing a key.
338                /// </summary>
339                /// <param name="locator">an <a href="#locators">element locator</a></param>
340                /// <param name="keySequence">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".</param>
341                public void KeyUp(String locator,String keySequence)
342                {
343                        commandProcessor.DoCommand("keyUp", new String[] {locator,keySequence,});
344                }
345
346
347                /// <summary>Simulates a user hovering a mouse over the specified element.
348                /// </summary>
349                /// <param name="locator">an <a href="#locators">element locator</a></param>
350                public void MouseOver(String locator)
351                {
352                        commandProcessor.DoCommand("mouseOver", new String[] {locator,});
353                }
354
355
356                /// <summary>Simulates a user moving the mouse pointer away from the specified element.
357                /// </summary>
358                /// <param name="locator">an <a href="#locators">element locator</a></param>
359                public void MouseOut(String locator)
360                {
361                        commandProcessor.DoCommand("mouseOut", new String[] {locator,});
362                }
363
364
365                /// <summary>Simulates a user pressing the left mouse button (without releasing it yet) on
366                /// the specified element.
367                /// </summary>
368                /// <param name="locator">an <a href="#locators">element locator</a></param>
369                public void MouseDown(String locator)
370                {
371                        commandProcessor.DoCommand("mouseDown", new String[] {locator,});
372                }
373
374
375                /// <summary>Simulates a user pressing the right mouse button (without releasing it yet) on
376                /// the specified element.
377                /// </summary>
378                /// <param name="locator">an <a href="#locators">element locator</a></param>
379                public void MouseDownRight(String locator)
380                {
381                        commandProcessor.DoCommand("mouseDownRight", new String[] {locator,});
382                }
383
384
385                /// <summary>Simulates a user pressing the left mouse button (without releasing it yet) at
386                /// the specified location.
387                /// </summary>
388                /// <param name="locator">an <a href="#locators">element locator</a></param>
389                /// <param name="coordString">specifies the x,y position (i.e. - 10,20) of the mouse      event relative to the element returned by the locator.</param>
390                public void MouseDownAt(String locator,String coordString)
391                {
392                        commandProcessor.DoCommand("mouseDownAt", new String[] {locator,coordString,});
393                }
394
395
396                /// <summary>Simulates a user pressing the right mouse button (without releasing it yet) at
397                /// the specified location.
398                /// </summary>
399                /// <param name="locator">an <a href="#locators">element locator</a></param>
400                /// <param name="coordString">specifies the x,y position (i.e. - 10,20) of the mouse      event relative to the element returned by the locator.</param>
401                public void MouseDownRightAt(String locator,String coordString)
402                {
403                        commandProcessor.DoCommand("mouseDownRightAt", new String[] {locator,coordString,});
404                }
405
406
407                /// <summary>Simulates the event that occurs when the user releases the mouse button (i.e., stops
408                /// holding the button down) on the specified element.
409                /// </summary>
410                /// <param name="locator">an <a href="#locators">element locator</a></param>
411                public void MouseUp(String locator)
412                {
413                        commandProcessor.DoCommand("mouseUp", new String[] {locator,});
414                }
415
416
417                /// <summary>Simulates the event that occurs when the user releases the right mouse button (i.e., stops
418                /// holding the button down) on the specified element.
419                /// </summary>
420                /// <param name="locator">an <a href="#locators">element locator</a></param>
421                public void MouseUpRight(String locator)
422                {
423                        commandProcessor.DoCommand("mouseUpRight", new String[] {locator,});
424                }
425
426
427                /// <summary>Simulates the event that occurs when the user releases the mouse button (i.e., stops
428                /// holding the button down) at the specified location.
429                /// </summary>
430                /// <param name="locator">an <a href="#locators">element locator</a></param>
431                /// <param name="coordString">specifies the x,y position (i.e. - 10,20) of the mouse      event relative to the element returned by the locator.</param>
432                public void MouseUpAt(String locator,String coordString)
433                {
434                        commandProcessor.DoCommand("mouseUpAt", new String[] {locator,coordString,});
435                }
436
437
438                /// <summary>Simulates the event that occurs when the user releases the right mouse button (i.e., stops
439                /// holding the button down) at the specified location.
440                /// </summary>
441                /// <param name="locator">an <a href="#locators">element locator</a></param>
442                /// <param name="coordString">specifies the x,y position (i.e. - 10,20) of the mouse      event relative to the element returned by the locator.</param>
443                public void MouseUpRightAt(String locator,String coordString)
444                {
445                        commandProcessor.DoCommand("mouseUpRightAt", new String[] {locator,coordString,});
446                }
447
448
449                /// <summary>Simulates a user pressing the mouse button (without releasing it yet) on
450                /// the specified element.
451                /// </summary>
452                /// <param name="locator">an <a href="#locators">element locator</a></param>
453                public void MouseMove(String locator)
454                {
455                        commandProcessor.DoCommand("mouseMove", new String[] {locator,});
456                }
457
458
459                /// <summary>Simulates a user pressing the mouse button (without releasing it yet) on
460                /// the specified element.
461                /// </summary>
462                /// <param name="locator">an <a href="#locators">element locator</a></param>
463                /// <param name="coordString">specifies the x,y position (i.e. - 10,20) of the mouse      event relative to the element returned by the locator.</param>
464                public void MouseMoveAt(String locator,String coordString)
465                {
466                        commandProcessor.DoCommand("mouseMoveAt", new String[] {locator,coordString,});
467                }
468
469
470                /// <summary>Sets the value of an input field, as though you typed it in.
471                /// 
472                /// <p>Can also be used to set the value of combo boxes, check boxes, etc. In these cases,
473                /// value should be the value of the option selected, not the visible text.</p>
474                /// </summary>
475                /// <param name="locator">an <a href="#locators">element locator</a></param>
476                /// <param name="value">the value to type</param>
477                public void Type(String locator,String value)
478                {
479                        commandProcessor.DoCommand("type", new String[] {locator,value,});
480                }
481
482
483                /// <summary>Simulates keystroke events on the specified element, as though you typed the value key-by-key.
484                /// 
485                /// <p>This is a convenience method for calling keyDown, keyUp, keyPress for every character in the specified string;
486                /// this is useful for dynamic UI widgets (like auto-completing combo boxes) that require explicit key events.</p><p>Unlike the simple "type" command, which forces the specified value into the page directly, this command
487                /// may or may not have any visible effect, even in cases where typing keys would normally have a visible effect.
488                /// For example, if you use "typeKeys" on a form element, you may or may not see the results of what you typed in
489                /// the field.</p><p>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
490                /// send the keystroke events corresponding to what you just typed.</p>
491                /// </summary>
492                /// <param name="locator">an <a href="#locators">element locator</a></param>
493                /// <param name="value">the value to type</param>
494                public void TypeKeys(String locator,String value)
495                {
496                        commandProcessor.DoCommand("typeKeys", new String[] {locator,value,});
497                }
498
499
500                /// <summary>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.,
501                /// the delay is 0 milliseconds.
502                /// </summary>
503                /// <param name="value">the number of milliseconds to pause after operation</param>
504                public void SetSpeed(String value)
505                {
506                        commandProcessor.DoCommand("setSpeed", new String[] {value,});
507                }
508
509
510                /// <summary>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.,
511                /// the delay is 0 milliseconds.
512                /// 
513                /// See also setSpeed.
514                /// </summary>
515                /// <returns>the execution speed in milliseconds.</returns>
516                public String GetSpeed()
517                {
518                        return commandProcessor.GetString("getSpeed", new String[] {});
519                }
520
521
522                /// <summary>Check a toggle-button (checkbox/radio)
523                /// </summary>
524                /// <param name="locator">an <a href="#locators">element locator</a></param>
525                public void Check(String locator)
526                {
527                        commandProcessor.DoCommand("check", new String[] {locator,});
528                }
529
530
531                /// <summary>Uncheck a toggle-button (checkbox/radio)
532                /// </summary>
533                /// <param name="locator">an <a href="#locators">element locator</a></param>
534                public void Uncheck(String locator)
535                {
536                        commandProcessor.DoCommand("uncheck", new String[] {locator,});
537                }
538
539
540                /// <summary>Select an option from a drop-down using an option locator.
541                /// 
542                /// <p>
543                /// Option locators provide different ways of specifying options of an HTML
544                /// Select element (e.g. for selecting a specific option, or for asserting
545                /// that the selected option satisfies a specification). There are several
546                /// forms of Select Option Locator.
547                /// </p><ul><li><strong>label</strong>=<em>labelPattern</em>:
548                /// matches options based on their labels, i.e. the visible text. (This
549                /// is the default.)
550                /// <ul class="first last simple"><li>label=regexp:^[Oo]ther</li></ul></li><li><strong>value</strong>=<em>valuePattern</em>:
551                /// matches options based on their values.
552                /// <ul class="first last simple"><li>value=other</li></ul></li><li><strong>id</strong>=<em>id</em>:
553                /// 
554                /// matches options based on their ids.
555                /// <ul class="first last simple"><li>id=option1</li></ul></li><li><strong>index</strong>=<em>index</em>:
556                /// matches an option based on its index (offset from zero).
557                /// <ul class="first last simple"><li>index=2</li></ul></li></ul><p>
558                /// If no option locator prefix is provided, the default behaviour is to match on <strong>label</strong>.
559                /// </p>
560                /// </summary>
561                /// <param name="selectLocator">an <a href="#locators">element locator</a> identifying a drop-down menu</param>
562                /// <param name="optionLocator">an option locator (a label by default)</param>
563                public void Select(String selectLocator,String optionLocator)
564                {
565                        commandProcessor.DoCommand("select", new String[] {selectLocator,optionLocator,});
566                }
567
568
569                /// <summary>Add a selection to the set of selected options in a multi-select element using an option locator.
570                /// 
571                /// @see #doSelect for details of option locators
572                /// </summary>
573                /// <param name="locator">an <a href="#locators">element locator</a> identifying a multi-select box</param>
574                /// <param name="optionLocator">an option locator (a label by default)</param>
575                public void AddSelection(String locator,String optionLocator)
576                {
577                        commandProcessor.DoCommand("addSelection", new String[] {locator,optionLocator,});
578                }
579
580
581                /// <summary>Remove a selection from the set of selected options in a multi-select element using an option locator.
582                /// 
583                /// @see #doSelect for details of option locators
584                /// </summary>
585                /// <param name="locator">an <a href="#locators">element locator</a> identifying a multi-select box</param>
586                /// <param name="optionLocator">an option locator (a label by default)</param>
587                public void RemoveSelection(String locator,String optionLocator)
588                {
589                        commandProcessor.DoCommand("removeSelection", new String[] {locator,optionLocator,});
590                }
591
592
593                /// <summary>Unselects all of the selected options in a multi-select element.
594                /// </summary>
595                /// <param name="locator">an <a href="#locators">element locator</a> identifying a multi-select box</param>
596                public void RemoveAllSelections(String locator)
597                {
598                        commandProcessor.DoCommand("removeAllSelections", new String[] {locator,});
599                }
600
601
602                /// <summary>Submit the specified form. This is particularly useful for forms without
603                /// submit buttons, e.g. single-input "Search" forms.
604                /// </summary>
605                /// <param name="formLocator">an <a href="#locators">element locator</a> for the form you want to submit</param>
606                public void Submit(String formLocator)
607                {
608                        commandProcessor.DoCommand("submit", new String[] {formLocator,});
609                }
610
611
612                /// <summary>Opens an URL in the test frame. This accepts both relative and absolute
613                /// URLs.
614                /// 
615                /// The "open" command waits for the page to load before proceeding,
616                /// ie. the "AndWait" suffix is implicit.
617                /// 
618                /// <em>Note</em>: The URL must be on the same domain as the runner HTML
619                /// due to security restrictions in the browser (Same Origin Policy). If you
620                /// need to open an URL on another domain, use the Selenium Server to start a
621                /// new browser session on that domain.
622                /// </summary>
623                /// <param name="url">the URL to open; may be relative or absolute</param>
624                public void Open(String url)
625                {
626                        commandProcessor.DoCommand("open", new String[] {url,});
627                }
628
629
630                /// <summary>Opens a popup window (if a window with that ID isn't already open).
631                /// After opening the window, you'll need to select it using the selectWindow
632                /// command.
633                /// 
634                /// <p>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).
635                /// In those cases, you can force Selenium to notice the open window's name by using the Selenium openWindow command, using
636                /// an empty (blank) url, like this: openWindow("", "myFunnyWindow").</p>
637                /// </summary>
638                /// <param name="url">the URL to open, which can be blank</param>
639                /// <param name="windowID">the JavaScript window ID of the window to select</param>
640                public void OpenWindow(String url,String windowID)
641                {
642                        commandProcessor.DoCommand("openWindow", new String[] {url,windowID,});
643                }
644
645
646                /// <summary>Selects a popup window using a window locator; once a popup window has been selected, all
647                /// commands go to that window. To select the main window again, use null
648                /// as the target.
649                /// 
650                /// <p>
651                /// 
652                /// Window locators provide different ways of specifying the window object:
653                /// by title, by internal JavaScript "name," or by JavaScript variable.
654                /// </p><ul><li><strong>title</strong>=<em>My Special Window</em>:
655                /// Finds the window using the text that appears in the title bar.  Be careful;
656                /// two windows can share the same title.  If that happens, this locator will
657                /// just pick one.
658                /// </li><li><strong>name</strong>=<em>myWindow</em>:
659                /// Finds the window using its internal JavaScript "name" property.  This is the second 
660                /// parameter "windowName" passed to the JavaScript method window.open(url, windowName, windowFeatures, replaceFlag)
661                /// (which Selenium intercepts).
662                /// </li><li><strong>var</strong>=<em>variableName</em>:
663                /// Some pop-up windows are unnamed (anonymous), but are associated with a JavaScript variable name in the current
664                /// application window, e.g. "window.foo = window.open(url);".  In those cases, you can open the window using
665                /// "var=foo".
666                /// </li></ul><p>
667                /// If no window locator prefix is provided, we'll try to guess what you mean like this:</p><p>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).</p><p>2.) if the value of the "windowID" parameter is a JavaScript variable name in the current application window, then it is assumed
668                /// that this variable contains the return value from a call to the JavaScript window.open() method.</p><p>3.) Otherwise, selenium looks in a hash it maintains that maps string names to window "names".</p><p>4.) If <em>that</em> fails, we'll try looping over all of the known windows to try to find the appropriate "title".
669                /// Since "title" is not necessarily unique, this may have unexpected behavior.</p><p>If you're having trouble figuring out the name of a window that you want to manipulate, look at the Selenium log messages
670                /// which identify the names of windows created via window.open (and therefore intercepted by Selenium).  You will see messages
671                /// like the following for each window as it is opened:</p><p><code>debug: window.open call intercepted; window ID (which you can use with selectWindow()) is "myNewWindow"</code></p><p>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).
672                /// (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
673                /// an empty (blank) url, like this: openWindow("", "myFunnyWindow").</p>
674                /// </summary>
675                /// <param name="windowID">the JavaScript window ID of the window to select</param>
676                public void SelectWindow(String windowID)
677                {
678                        commandProcessor.DoCommand("selectWindow", new String[] {windowID,});
679                }
680
681
682                /// <summary>Simplifies the process of selecting a popup window (and does not offer
683                /// functionality beyond what <code>selectWindow()</code> already provides).
684                /// <ul><li>If <code>windowID</code> is either not specified, or specified as
685                /// "null", the first non-top window is selected. The top window is the one
686                /// that would be selected by <code>selectWindow()</code> without providing a
687                /// <code>windowID</code> . This should not be used when more than one popup
688                /// window is in play.</li><li>Otherwise, the window will be looked up considering
689                /// <code>windowID</code> as the following in order: 1) the "name" of the
690                /// window, as specified to <code>window.open()</code>; 2) a javascript
691                /// variable which is a reference to a window; and 3) the title of the
692                /// window. This is the same ordered lookup performed by
693                /// <code>selectWindow</code> .</li></ul>
694                /// </summary>
695                /// <param name="windowID">an identifier for the popup window, which can take on a                  number of different meanings</param>
696                public void SelectPopUp(String windowID)
697                {
698                        commandProcessor.DoCommand("selectPopUp", new String[] {windowID,});
699                }
700
701
702                /// <summary>Selects the main window. Functionally equivalent to using
703                /// <code>selectWindow()</code> and specifying no value for
704                /// <code>windowID</code>.
705                /// </summary>
706                public void DeselectPopUp()
707                {
708                        commandProcessor.DoCommand("deselectPopUp", new String[] {});
709                }
710
711
712                /// <summary>Selects a frame within the current window.  (You may invoke this command
713                /// multiple times to select nested frames.)  To select the parent frame, use
714                /// "relative=parent" as a locator; to select the top frame, use "relative=top".
715                /// You can also select a frame by its 0-based index number; select the first frame with
716                /// "index=0", or the third frame with "index=2".
717                /// 
718                /// <p>You may also use a DOM expression to identify the frame you want directly,
719                /// like this: <code>dom=frames["main"].frames["subframe"]</code></p>
720                /// </summary>
721                /// <param name="locator">an <a href="#locators">element locator</a> identifying a frame or iframe</param>
722                public void SelectFrame(String locator)
723                {
724                        commandProcessor.DoCommand("selectFrame", new String[] {locator,});
725                }
726
727
728                /// <summary>Determine whether current/locator identify the frame containing this running code.
729                /// 
730                /// <p>This is useful in proxy injection mode, where this code runs in every
731                /// browser frame and window, and sometimes the selenium server needs to identify
732                /// the "current" frame.  In this case, when the test calls selectFrame, this
733                /// routine is called for each frame to figure out which one has been selected.
734                /// The selected frame will return true, while all others will return false.</p>
735                /// </summary>
736                /// <param name="currentFrameString">starting frame</param>
737                /// <param name="target">new frame (which might be relative to the current one)</param>
738                /// <returns>true if the new frame is this code's window</returns>
739                public bool GetWhetherThisFrameMatchFrameExpression(String currentFrameString,String target)
740                {
741                        return commandProcessor.GetBoolean("getWhetherThisFrameMatchFrameExpression", new String[] {currentFrameString,target,});
742                }
743
744
745                /// <summary>Determine whether currentWindowString plus target identify the window containing this running code.
746                /// 
747                /// <p>This is useful in proxy injection mode, where this code runs in every
748                /// browser frame and window, and sometimes the selenium server needs to identify
749                /// the "current" window.  In this case, when the test calls selectWindow, this
750                /// routine is called for each window to figure out which one has been selected.
751                /// The selected window will return true, while all others will return false.</p>
752                /// </summary>
753                /// <param name="currentWindowString">starting window</param>
754                /// <param name="target">new window (which might be relative to the current one, e.g., "_parent")</param>
755                /// <returns>true if the new window is this code's window</returns>
756                public bool GetWhetherThisWindowMatchWindowExpression(String currentWindowString,String target)
757                {
758                        return commandProcessor.GetBoolean("getWhetherThisWindowMatchWindowExpression", new String[] {currentWindowString,target,});
759                }
760
761
762                /// <summary>Waits for a popup window to appear and load up.
763                /// </summary>
764                /// <param name="windowID">the JavaScript window "name" of the window that will appear (not the text of the title bar)                 If unspecified, or specified as "null", this command will                 wait for the first non-top window to appear (don't rely                 on this if you are working with multiple popups                 simultaneously).</param>
765                /// <param name="timeout">a timeout in milliseconds, after which the action will return with an error.                If this value is not specified, the default Selenium                timeout will be used. See the setTimeout() command.</param>
766                public void WaitForPopUp(String windowID,String timeout)
767                {
768                        commandProcessor.DoCommand("waitForPopUp", new String[] {windowID,timeout,});
769                }
770
771
772                /// <summary><p>
773                /// By default, Selenium's overridden window.confirm() function will
774                /// return true, as if the user had manually clicked OK; after running
775                /// this command, the next call to confirm() will return false, as if
776                /// the user had clicked Cancel.  Selenium will then resume using the
777                /// default behavior for future confirmations, automatically returning 
778                /// true (OK) unless/until you explicitly call this command for each
779                /// confirmation.
780                /// </p><p>
781                /// Take note - every time a confirmation comes up, you must
782                /// consume it with a corresponding getConfirmation, or else
783                /// the next selenium operation will fail.
784                /// </p>
785                /// </summary>
786                public void ChooseCancelOnNextConfirmation()
787                {
788                        commandProcessor.DoCommand("chooseCancelOnNextConfirmation", new String[] {});
789                }
790
791
792                /// <summary><p>
793                /// Undo the effect of calling chooseCancelOnNextConfirmation.  Note
794                /// that Selenium's overridden window.confirm() function will normally automatically
795                /// return true, as if the user had manually clicked OK, so you shouldn't
796                /// need to use this command unless for some reason you need to change
797                /// your mind prior to the next confirmation.  After any confirmation, Selenium will resume using the
798                /// default behavior for future confirmations, automatically returning 
799                /// true (OK) unless/until you explicitly call chooseCancelOnNextConfirmation for each
800                /// confirmation.
801                /// </p><p>
802                /// Take note - every time a confirmation comes up, you must
803                /// consume it with a corresponding getConfirmation, or else
804                /// the next selenium operation will fail.
805                /// </p>
806                /// </summary>
807                public void ChooseOkOnNextConfirmation()
808                {
809                        commandProcessor.DoCommand("chooseOkOnNextConfirmation", new String[] {});
810                }
811
812
813                /// <summary>Instructs Selenium to return the specified answer string in response to
814                /// the next JavaScript prompt [window.prompt()].
815                /// </summary>
816                /// <param name="answer">the answer to give in response to the prompt pop-up</param>
817                public void AnswerOnNextPrompt(String answer)
818                {
819                        commandProcessor.DoCommand("answerOnNextPrompt", new String[] {answer,});
820                }
821
822
823                /// <summary>Simulates the user clicking the "back" button on their browser.
824                /// </summary>
825                public void GoBack()
826                {
827                        commandProcessor.DoCommand("goBack", new String[] {});
828                }
829
830
831                /// <summary>Simulates the user clicking the "Refresh" button on their browser.
832                /// </summary>
833                public void Refresh()
834                {
835                        commandProcessor.DoCommand("refresh", new String[] {});
836                }
837
838
839                /// <summary>Simulates the user clicking the "close" button in the titlebar of a popup
840                /// window or tab.
841                /// </summary>
842                public void Close()
843                {
844                        commandProcessor.DoCommand("close", new String[] {});
845                }
846
847
848                /// <summary>Has an alert occurred?
849                /// 
850                /// <p>
851                /// This function never throws an exception
852                /// </p>
853                /// </summary>
854                /// <returns>true if there is an alert</returns>
855                public bool IsAlertPresent()
856                {
857                        return commandProcessor.GetBoolean("isAlertPresent", new String[] {});
858                }
859
860
861                /// <summary>Has a prompt occurred?
862                /// 
863                /// <p>
864                /// This function never throws an exception
865                /// </p>
866                /// </summary>
867                /// <returns>true if there is a pending prompt</returns>
868                public bool IsPromptPresent()
869                {
870                        return commandProcessor.GetBoolean("isPromptPresent", new String[] {});
871                }
872
873
874                /// <summary>Has confirm() been called?
875                /// 
876                /// <p>
877                /// This function never throws an exception
878                /// </p>
879                /// </summary>
880                /// <returns>true if there is a pending confirmation</returns>
881                public bool IsConfirmationPresent()
882                {
883                        return commandProcessor.GetBoolean("isConfirmationPresent", new String[] {});
884                }
885
886
887                /// <summary>Retrieves the message of a JavaScript alert generated during the previous action, or fail if there were no alerts.
888                /// 
889                /// <p>Getting an alert has the same effect as manually clicking OK. If an
890                /// alert is generated but you do not consume it with getAlert, the next Selenium action
891                /// will fail.</p><p>Under Selenium, JavaScript alerts will NOT pop up a visible alert
892                /// dialog.</p><p>Selenium does NOT support JavaScript alerts that are generated in a
893                /// page's onload() event handler. In this case a visible dialog WILL be
894                /// generated and Selenium will hang until someone manually clicks OK.</p>
895                /// </summary>
896                /// <returns>The message of the most recent JavaScript alert</returns>
897                public String GetAlert()
898                {
899                        return commandProcessor.GetString("getAlert", new String[] {});
900                }
901
902
903                /// <summary>Retrieves the message of a JavaScript confirmation dialog generated during
904                /// the previous action.
905                /// 
906                /// <p>
907                /// By default, the confirm function will return true, having the same effect
908                /// as manually clicking OK. This can be changed by prior execution of the
909                /// chooseCancelOnNextConfirmation command. 
910                /// </p><p>
911                /// If an confirmation is generated but you do not consume it with getConfirmation,
912                /// the next Selenium action will fail.
913                /// </p><p>
914                /// NOTE: under Selenium, JavaScript confirmations will NOT pop up a visible
915                /// dialog.
916                /// </p><p>
917                /// NOTE: Selenium does NOT support JavaScript confirmations that are
918                /// generated in a page's onload() event handler. In this case a visible
919                /// dialog WILL be generated and Selenium will hang until you manually click
920                /// OK.
921                /// </p>
922                /// </summary>
923                /// <returns>the message of the most recent JavaScript confirmation dialog</returns>
924                public String GetConfirmation()
925                {
926                        return commandProcessor.GetString("getConfirmation", new String[] {});
927                }
928
929
930                /// <summary>Retrieves the message of a JavaScript question prompt dialog generated during
931                /// the previous action.
932                /// 
933                /// <p>Successful handling of the prompt requires prior execution of the
934                /// answerOnNextPrompt command. If a prompt is generated but you
935                /// do not get/verify it, the next Selenium action will fail.</p><p>NOTE: under Selenium, JavaScript prompts will NOT pop up a visible
936                /// dialog.</p><p>NOTE: Selenium does NOT support JavaScript prompts that are generated in a
937                /// page's onload() event handler. In this case a visible dialog WILL be
938                /// generated and Selenium will hang until someone manually clicks OK.</p>
939                /// </summary>
940                /// <returns>the message of the most recent JavaScript question prompt</returns>
941                public String GetPrompt()
942                {
943                        return commandProcessor.GetString("getPrompt", new String[] {});
944                }
945
946
947                /// <summary>Gets the absolute URL of the current page.
948                /// </summary>
949                /// <returns>the absolute URL of the current page</returns>
950                public String GetLocation()
951                {
952                        return commandProcessor.GetString("getLocation", new String[] {});
953                }
954
955
956                /// <summary>Gets the title of the current page.
957                /// </summary>
958                /// <returns>the title of the current page</returns>
959                public String GetTitle()
960                {
961                        return commandProcessor.GetString("getTitle", new String[] {});
962                }
963
964
965                /// <summary>Gets the entire text of the page.
966                /// </summary>
967                /// <returns>the entire text of the page</returns>
968                public String GetBodyText()
969                {
970                        return commandProcessor.GetString("getBodyText", new String[] {});
971                }
972
973
974                /// <summary>Gets the (whitespace-trimmed) value of an input field (or anything else with a value parameter).
975                /// For checkbox/radio elements, the value will be "on" or "off" depending on
976                /// whether the element is checked or not.
977                /// </summary>
978                /// <param name="locator">an <a href="#locators">element locator</a></param>
979                /// <returns>the element value, or "on/off" for checkbox/radio elements</returns>
980                public String GetValue(String locator)
981                {
982                        return commandProcessor.GetString("getValue", new String[] {locator,});
983                }
984
985
986                /// <summary>Gets the text of an element. This works for any element that contains
987                /// text. This command uses either the textContent (Mozilla-like browsers) or
988                /// the innerText (IE-like browsers) of the element, which is the rendered
989                /// text shown to the user.
990                /// </summary>
991                /// <param name="locator">an <a href="#locators">element locator</a></param>
992                /// <returns>the text of the element</returns>
993                public String GetText(String locator)
994                {
995                        return commandProcessor.GetString("getText", new String[] {locator,});
996                }
997
998
999                /// <summary>Briefly changes the backgroundColor of the specified element yellow.  Useful for debugging.
1000                /// </summary>
1001                /// <param name="locator">an <a href="#locators">element locator</a></param>
1002                public void Highlight(String locator)
1003                {
1004                        commandProcessor.DoCommand("highlight", new String[] {locator,});
1005                }
1006
1007
1008                /// <summary>Gets the result of evaluating the specified JavaScript snippet.  The snippet may
1009                /// have multiple lines, but only the result of the last line will be returned.
1010                /// 
1011                /// <p>Note that, by default, the snippet will run in the context of the "selenium"
1012                /// object itself, so <code>this</code> will refer to the Selenium object.  Use <code>window</code> to
1013                /// refer to the window of your application, e.g. <code>window.document.getElementById('foo')</code></p><p>If you need to use
1014                /// a locator to refer to a single element in your application page, you can
1015                /// use <code>this.browserbot.findElement("id=foo")</code> where "id=foo" is your locator.</p>
1016                /// </summary>
1017                /// <param name="script">the JavaScript snippet to run</param>
1018                /// <returns>the results of evaluating the snippet</returns>
1019                public String GetEval(String script)
1020                {
1021                        return commandProcessor.GetString("getEval", new String[] {script,});
1022                }
1023
1024
1025                /// <summary>Gets whether a toggle-button (checkbox/radio) is checked.  Fails if the specified element doesn't exist or isn't a toggle-button.
1026                /// </summary>
1027                /// <param name="locator">an <a href="#locators">element locator</a> pointing to a checkbox or radio button</param>
1028                /// <returns>true if the checkbox is checked, false otherwise</returns>
1029                public bool IsChecked(String locator)
1030                {
1031                        return commandProcessor.GetBoolean("isChecked", new String[] {locator,});
1032                }
1033
1034
1035                /// <summary>Gets the text from a cell of a table. The cellAddress syntax
1036                /// tableLocator.row.column, where row and column start at 0.
1037                /// </summary>
1038                /// <param name="tableCellAddress">a cell address, e.g. "foo.1.4"</param>
1039                /// <returns>the text from the specified cell</returns>
1040                public String GetTable(String tableCellAddress)
1041                {
1042                        return commandProcessor.GetString("getTable", new String[] {tableCellAddress,});
1043                }
1044
1045
1046                /// <summary>Gets all option labels (visible text) for selected options in the specified select or multi-select element.
1047                /// </summary>
1048                /// <param name="selectLocator">an <a href="#locators">element locator</a> identifying a drop-down menu</param>
1049                /// <returns>an array of all selected option labels in the specified select drop-down</returns>
1050                public String[] GetSelectedLabels(String selectLocator)
1051                {
1052                        return commandProcessor.GetStringArray("getSelectedLabels", new String[] {selectLocator,});
1053                }
1054
1055
1056                /// <summary>Gets option label (visible text) for selected option in the specified select element.
1057                /// </summary>
1058                /// <param name="selectLocator">an <a href="#locators">element locator</a> identifying a drop-down menu</param>
1059                /// <returns>the selected option label in the specified select drop-down</returns>
1060                public String GetSelectedLabel(String selectLocator)
1061                {
1062                        return commandProcessor.GetString("getSelectedLabel", new String[] {selectLocator,});
1063                }
1064
1065
1066                /// <summary>Gets all option values (value attributes) for selected options in the specified select or multi-select element.
1067                /// </summary>
1068                /// <param name="selectLocator">an <a href="#locators">element locator</a> identifying a drop-down menu</param>
1069                /// <returns>an array of all selected option values in the specified select drop-down</returns>
1070                public String[] GetSelectedValues(String selectLocator)
1071                {
1072                        return commandProcessor.GetStringArray("getSelectedValues", new String[] {selectLocator,});
1073                }
1074
1075
1076                /// <summary>Gets option value (value attribute) for selected option in the specified select element.
1077                /// </summary>
1078                /// <param name="selectLocator">an <a href="#locators">element locator</a> identifying a drop-down menu</param>
1079                /// <returns>the selected option value in the specified select drop-down</returns>
1080                public String GetSelectedValue(String selectLocator)
1081                {
1082                        return commandProcessor.GetString("getSelectedValue", new String[] {selectLocator,});
1083                }
1084
1085
1086                /// <summary>Gets all option indexes (option number, starting at 0) for selected options in the specified select or multi-select element.
1087                /// </summary>
1088                /// <param name="selectLocator">an <a href="#locators">element locator</a> identifying a drop-down menu</param>
1089                /// <returns>an array of all selected option indexes in the specified select drop-down</returns>
1090                public String[] GetSelectedIndexes(String selectLocator)
1091                {
1092                        return commandProcessor.GetStringArray("getSelectedIndexes", new String[] {selectLocator,});
1093                }
1094
1095
1096                /// <summary>Gets option index (option number, starting at 0) for selected option in the specified select element.
1097                /// </summary>
1098                /// <param name="selectLocator">an <a href="#locators">element locator</a> identifying a drop-down menu</param>
1099                /// <returns>the selected option index in the specified select drop-down</returns>
1100                public String GetSelectedIndex(String selectLocator)
1101                {
1102                        return commandProcessor.GetString("getSelectedIndex", new String[] {selectLocator,});
1103                }
1104
1105
1106                /// <summary>Gets all option element IDs for selected options in the specified select or multi-select element.
1107                /// </summary>
1108                /// <param name="selectLocator">an <a href="#locators">element locator</a> identifying a drop-down menu</param>
1109                /// <returns>an array of all selected option IDs in the specified select drop-down</returns>
1110                public String[] GetSelectedIds(String selectLocator)
1111                {
1112                        return commandProcessor.GetStringArray("getSelectedIds", new String[] {selectLocator,});
1113                }
1114
1115
1116                /// <summary>Gets option element ID for selected option in the specified select element.
1117                /// </summary>
1118                /// <param name="selectLocator">an <a href="#locators">element locator</a> identifying a drop-down menu</param>
1119                /// <returns>the selected option ID in the specified select drop-down</returns>
1120                public String GetSelectedId(String selectLocator)
1121                {
1122                        return commandProcessor.GetString("getSelectedId", new String[] {selectLocator,});
1123                }
1124
1125
1126                /// <summary>Determines whether some option in a drop-down menu is selected.
1127                /// </summary>
1128                /// <param name="selectLocator">an <a href="#locators">element locator</a> identifying a drop-down menu</param>
1129                /// <returns>true if some option has been selected, false otherwise</returns>
1130                public bool IsSomethingSelected(String selectLocator)
1131                {
1132                        return commandProcessor.GetBoolean("isSomethingSelected", new String[] {selectLocator,});
1133                }
1134
1135
1136                /// <summary>Gets all option labels in the specified select drop-down.
1137                /// </summary>
1138                /// <param name="selectLocator">an <a href="#locators">element locator</a> identifying a drop-down menu</param>
1139                /// <returns>an array of all option labels in the specified select drop-down</returns>
1140                public String[] GetSelectOptions(String selectLocator)
1141                {
1142                        return commandProcessor.GetStringArray("getSelectOptions", new String[] {selectLocator,});
1143                }
1144
1145
1146                /// <summary>Gets the value of an element attribute. The value of the attribute may
1147                /// differ across browsers (this is the case for the "style" attribute, for
1148                /// example).
1149                /// </summary>
1150                /// <param name="attributeLocator">an element locator followed by an @ sign and then the name of the attribute, e.g. "[email protected]"</param>
1151                /// <returns>the value of the specified attribute</returns>
1152                public String GetAttribute(String attributeLocator)
1153                {
1154                        return commandProcessor.GetString("getAttribute", new String[] {attributeLocator,});
1155                }
1156
1157
1158                /// <summary>Verifies that the specified text pattern appears somewhere on the rendered page shown to the user.
1159                /// </summary>
1160                /// <param name="pattern">a <a href="#patterns">pattern</a> to match with the text of the page</param>
1161                /// <returns>true if the pattern matches the text, false otherwise</returns>
1162                public bool IsTextPresent(String pattern)
1163                {
1164                        return commandProcessor.GetBoolean("isTextPresent", new String[] {pattern,});
1165                }
1166
1167
1168                /// <summary>Verifies that the specified element is somewhere on the page.
1169                /// </summary>
1170                /// <param name="locator">an <a href="#locators">element locator</a></param>
1171                /// <returns>true if the element is present, false otherwise</returns>
1172                public bool IsElementPresent(String locator)
1173                {
1174                        return commandProcessor.GetBoolean("isElementPresent", new String[] {locator,});
1175                }
1176
1177
1178                /// <summary>Determines if the specified element is visible. An
1179                /// element can be rendered invisible by setting the CSS "visibility"
1180                /// property to "hidden", or the "display" property to "none", either for the
1181                /// element itself or one if its ancestors.  This method will fail if
1182                /// the element is not present.
1183                /// </summary>
1184                /// <param name="locator">an <a href="#locators">element locator</a></param>
1185                /// <returns>true if the specified element is visible, false otherwise</returns>
1186                public bool IsVisible(String locator)
1187                {
1188                        return commandProcessor.GetBoolean("isVisible", new String[] {locator,});
1189                }
1190
1191
1192                /// <summary>Determines whether the specified input element is editable, ie hasn't been disabled.
1193                /// This method will fail if the specified element isn't an input element.
1194                /// </summary>
1195                /// <param name="locator">an <a href="#locators">element locator</a></param>
1196                /// <returns>true if the input element is editable, false otherwise</returns>
1197                public bool IsEditable(String locator)
1198                {
1199                        return commandProcessor.GetBoolean("isEditable", new String[] {locator,});
1200                }
1201
1202
1203                /// <summary>Returns the IDs of all buttons on the page.
1204                /// 
1205                /// <p>If a given button has no ID, it will appear as "" in this array.</p>
1206                /// </summary>
1207                /// <returns>the IDs of all buttons on the page</returns>
1208                public String[] GetAllButtons()
1209                {
1210                        return commandProcessor.GetStringArray("getAllButtons", new String[] {});
1211                }
1212
1213
1214                /// <summary>Returns the IDs of all links on the page.
1215                /// 
1216                /// <p>If a given link has no ID, it will appear as "" in this array.</p>
1217                /// </summary>
1218                /// <returns>the IDs of all links on the page</returns>
1219                public String[] GetAllLinks()
1220                {
1221                        return commandProcessor.GetStringArray("getAllLinks", new String[] {});
1222                }
1223
1224
1225                /// <summary>Returns the IDs of all input fields on the page.
1226                /// 
1227                /// <p>If a given field has no ID, it will appear as "" in this array.</p>
1228                /// </summary>
1229                /// <returns>the IDs of all field on the page</returns>
1230                public String[] GetAllFields()
1231                {
1232                        return commandProcessor.GetStringArray("getAllFields", new String[] {});
1233                }
1234
1235
1236                /// <summary>Returns an array of JavaScript property values from all known windows having one.
1237                /// </summary>
1238                /// <param name="attributeName">name of an attribute on the windows</param>
1239                /// <returns>the set of values of this attribute from all known windows.</returns>
1240                public String[] GetAttributeFromAllWindows(String attributeName)
1241                {
1242                        return commandProcessor.GetStringArray("getAttributeFromAllWindows", new String[] {attributeName,});
1243                }
1244
1245
1246                /// <summary>deprecated - use dragAndDrop instead
1247                /// </summary>
1248                /// <param name="locator">an element locator</param>
1249                /// <param name="movementsString">offset in pixels from the current location to which the element should be moved, e.g., "+70,-300"</param>
1250                public void Dragdrop(String locator,String movementsString)
1251                {
1252                        commandProcessor.DoCommand("dragdrop", new String[] {locator,movementsString,});
1253                }
1254
1255
1256                /// <summary>Configure the number of pixels between "mousemove" events during dragAndDrop commands (default=10).
1257                /// <p>Setting this value to 0 means that we'll send a "mousemove" event to every single pixel
1258                /// in between the start location and the end location; that can be very slow, and may
1259                /// cause some browsers to force the JavaScript to timeout.</p><p>If the mouse speed is greater than the distance between the two dragged objects, we'll
1260                /// just send one "mousemove" at the start location and then one final one at the end location.</p>
1261                /// </summary>
1262                /// <param name="pixels">the number of pixels between "mousemove" events</param>
1263                public void SetMouseSpeed(String pixels)
1264                {
1265                        commandProcessor.DoCommand("setMouseSpeed", new String[] {pixels,});
1266                }
1267
1268
1269                /// <summary>Returns the number of pixels between "mousemove" events during dragAndDrop commands (default=10).
1270                /// </summary>
1271                /// <returns>the number of pixels between "mousemove" events during dragAndDrop commands (default=10)</returns>
1272                public Decimal GetMouseSpeed()
1273                {
1274                        return commandProcessor.GetNumber("getMouseSpeed", new String[] {});
1275                }
1276
1277
1278                /// <summary>Drags an element a certain distance and then drops it
1279                /// </summary>
1280                /// <param name="locator">an element locator</param>
1281                /// <param name="movementsString">offset in pixels from the current location to which the element should be moved, e.g., "+70,-300"</param>
1282                public void DragAndDrop(String locator,String movementsString)
1283                {
1284                        commandProcessor.DoCommand("dragAndDrop", new String[] {locator,movementsString,});
1285                }
1286
1287
1288                /// <summary>Drags an element and drops it on another element
1289                /// </summary>
1290                /// <param name="locatorOfObjectToBeDragged">an element to be dragged</param>
1291                /// <param name="locatorOfDragDestinationObject">an element whose location (i.e., whose center-most pixel) will be the point where locatorOfObjectToBeDragged  is dropped</param>
1292                public void DragAndDropToObject(String locatorOfObjectToBeDragged,String locatorOfDragDestinationObject)
1293                {
1294                        commandProcessor.DoCommand("dragAndDropToObject", new String[] {locatorOfObjectToBeDragged,locatorOfDragDestinationObject,});
1295                }
1296
1297
1298                /// <summary>Gives focus to the currently selected window
1299                /// </summary>
1300                public void WindowFocus()
1301                {
1302                        commandProcessor.DoCommand("windowFocus", new String[] {});
1303                }
1304
1305
1306                /// <summary>Resize currently selected window to take up the entire screen
1307                /// </summary>
1308                public void WindowMaximize()
1309                {
1310                        commandProcessor.DoCommand("windowMaximize", new String[] {});
1311                }
1312
1313
1314                /// <summary>Returns the IDs of all windows that the browser knows about in an array.
1315                /// </summary>
1316                /// <returns>Array of identifiers of all windows that the browser knows about.</returns>
1317                public String[] GetAllWindowIds()
1318                {
1319                        return commandProcessor.GetStringArray("getAllWindowIds", new String[] {});
1320                }
1321
1322
1323                /// <summary>Returns the names of all windows that the browser knows about in an array.
1324                /// </summary>
1325                /// <returns>Array of names of all windows that the browser knows about.</returns>
1326                public String[] GetAllWindowNames()
1327                {
1328                        return commandProcessor.GetStringArray("getAllWindowNames", new String[] {});
1329                }
1330
1331
1332                /// <summary>Returns the titles of all windows that the browser knows about in an array.
1333                /// </summary>
1334                /// <returns>Array of titles of all windows that the browser knows about.</returns>
1335                public String[] GetAllWindowTitles()
1336                {
1337                        return commandProcessor.GetStringArray("getAllWindowTitles", new String[] {});
1338                }
1339
1340
1341                /// <summary>Returns the entire HTML source between the opening and
1342                /// closing "html" tags.
1343                /// </summary>
1344                /// <returns>the entire HTML source</returns>
1345                public String GetHtmlSource()
1346                {
1347                        return commandProcessor.GetString("getHtmlSource", new String[] {});
1348                }
1349
1350
1351                /// <summary>Moves the text cursor to the specified position in the given input element or textarea.
1352                /// This method will fail if the specified element isn't an input element or textarea.
1353                /// </summary>
1354                /// <param name="locator">an <a href="#locators">element locator</a> pointing to an input element or textarea</param>
1355                /// <param name="position">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.</param>
1356                public void SetCursorPosition(String locator,String position)
1357                {
1358                        commandProcessor.DoCommand("setCursorPosition", new String[] {locator,position,});
1359                }
1360
1361
1362                /// <summary>Get the relative index of an element to its parent (starting from 0). The comment node and empty text node
1363                /// will be ignored.
1364                /// </summary>
1365                /// <param name="locator">an <a href="#locators">element locator</a> pointing to an element</param>
1366                /// <returns>of relative index of the element to its parent (starting from 0)</returns>
1367                public Decimal GetElementIndex(String locator)
1368                {
1369                        return commandProcessor.GetNumber("getElementIndex", new String[] {locator,});
1370                }
1371
1372
1373                /// <summary>Check if these two elements have same parent and are ordered siblings in the DOM. Two same elements will
1374                /// not be considered ordered.
1375                /// </summary>
1376                /// <param name="locator1">an <a href="#locators">element locator</a> pointing to the first element</param>
1377                /// <param name="locator2">an <a href="#locators">element locator</a> pointing to the second element</param>
1378                /// <returns>true if element1 is the previous sibling of element2, false otherwise</returns>
1379                public bool IsOrdered(String locator1,String locator2)
1380                {
1381                        return commandProcessor.GetBoolean("isOrdered", new String[] {locator1,locator2,});
1382                }
1383
1384
1385                /// <summary>Retrieves the horizontal position of an element
1386                /// </summary>
1387                /// <param name="locator">an <a href="#locators">element locator</a> pointing to an element OR an element itself</param>
1388                /// <returns>of pixels from the edge of the frame.</returns>
1389                public Decimal GetElementPositionLeft(String locator)
1390                {
1391                        return commandProcessor.GetNumber("getElementPositionLeft", new String[] {locator,});
1392                }
1393
1394
1395                /// <summary>Retrieves the vertical position of an element
1396                /// </summary>
1397                /// <param name="locator">an <a href="#locators">element locator</a> pointing to an element OR an element itself</param>
1398                /// <returns>of pixels from the edge of the frame.</returns>
1399                public Decimal GetElementPositionTop(String locator)
1400                {
1401                        return commandProcessor.GetNumber("getElementPositionTop", new String[] {locator,});
1402                }
1403
1404
1405                /// <summary>Retrieves the width of an element
1406                /// </summary>
1407                /// <param name="locator">an <a href="#locators">element locator</a> pointing to an element</param>
1408                /// <returns>width of an element in pixels</returns>
1409                public Decimal GetElementWidth(String locator)
1410                {
1411                        return commandProcessor.GetNumber("getElementWidth", new String[] {locator,});
1412                }
1413
1414
1415                /// <summary>Retrieves the height of an element
1416                /// </summary>
1417                /// <param name="locator">an <a href="#locators">element locator</a> pointing to an element</param>
1418                /// <returns>height of an element in pixels</returns>
1419                public Decimal GetElementHeight(String locator)
1420                {
1421                        return commandProcessor.GetNumber("getElementHeight", new String[] {locator,});
1422                }
1423
1424
1425                /// <summary>Retrieves the text cursor position in the given input element or textarea; beware, this may not work perfectly on all browsers.
1426                /// 
1427                /// <p>Specifically, if the cursor/selection has been cleared by JavaScript, this command will tend to
1428                /// return the position of the last location of the cursor, even though the cursor is now gone from the page.  This is filed as <a href="http://jira.openqa.org/browse/SEL-243">SEL-243</a>.</p>
1429                /// This method will fail if the specified element isn't an input element or textarea, or there is no cursor in the element.
1430                /// </summary>
1431                /// <param name="locator">an <a href="#locators">element locator</a> pointing to an input element or textarea</param>
1432                /// <returns>the numerical position of the cursor in the field</returns>
1433                public Decimal GetCursorPosition(String locator)
1434                {
1435                        return commandProcessor.GetNumber("getCursorPosition", new String[] {locator,});
1436                }
1437
1438
1439                /// <summary>Returns the specified expression.
1440                /// 
1441                /// <p>This is useful because of JavaScript preprocessing.
1442                /// It is used to generate commands like assertExpression and waitForExpression.</p>
1443                /// </summary>
1444                /// <param name="expression">the value to return</param>
1445                /// <returns>the value passed in</returns>
1446                public String GetExpression(String expression)
1447                {
1448                        return commandProcessor.GetString("getExpression", new String[] {expression,});
1449                }
1450
1451
1452                /// <summary>Returns the number of nodes that match the specified xpath, eg. "//table" would give
1453                /// the number of tables.
1454                /// </summary>
1455                /// <param name="xpath">the xpath expression to evaluate. do NOT wrap this expression in a 'count()' function; we will do that for you.</param>
1456                /// <returns>the number of nodes that match the specified xpath</returns>
1457                public Decimal GetXpathCount(String xpath)
1458                {
1459                        return commandProcessor.GetNumber("getXpathCount", new String[] {xpath,});
1460                }
1461
1462
1463                /// <summary>Temporarily sets the "id" attribute of the specified element, so you can locate it in the future
1464                /// using its ID rather than a slow/complicated XPath.  This ID will disappear once the page is
1465                /// reloaded.
1466                /// </summary>
1467                /// <param name="locator">an <a href="#locators">element locator</a> pointing to an element</param>
1468                /// <param name="identifier">a string to be used as the ID of the specified element</param>
1469                public void AssignId(String locator,String identifier)
1470                {
1471                        commandProcessor.DoCommand("assignId", new String[] {locator,identifier,});
1472                }
1473
1474
1475                /// <summary>Specifies whether Selenium should use the native in-browser implementation
1476                /// of XPath (if any native version is available); if you pass "false" to
1477                /// this function, we will always use our pure-JavaScript xpath library.
1478                /// Using the pure-JS xpath library can improve the consistency of xpath
1479                /// element locators between different browser vendors, but the pure-JS
1480                /// version is much slower than the native implementations.
1481                /// </summary>
1482                /// <param name="allow">boolean, true means we'll prefer to use native XPath; false means we'll only use JS XPath</param>
1483                public void AllowNativeXpath(String allow)
1484                {
1485                        commandProcessor.DoCommand("allowNativeXpath", new String[] {allow,});
1486                }
1487
1488
1489                /// <summary>Specifies whether Selenium will ignore xpath attributes that have no
1490                /// value, i.e. are the empty string, when using the non-native xpath
1491                /// evaluation engine. You'd want to do this for performance reasons in IE.
1492                /// However, this could break certain xpaths, for example an xpath that looks
1493                /// for an attribute whose value is NOT the empty string.
1494                /// 
1495                /// The hope is that such xpaths are relatively rare, but the user should
1496                /// have the option of using them. Note that this only influences xpath
1497                /// evaluation when using the ajaxslt engine (i.e. not "javascript-xpath").
1498                /// </summary>
1499                /// <param name="ignore">boolean, true means we'll ignore attributes without value                        at the expense of xpath "correctness"; false means                        we'll sacrifice speed for correctness.</param>
1500                public void IgnoreAttributesWithoutValue(String ignore)
1501                {
1502                        commandProcessor.DoCommand("ignoreAttributesWithoutValue", new String[] {ignore,});
1503                }
1504
1505
1506                /// <summary>Runs the specified JavaScript snippet repeatedly until it evaluates to "true".
1507                /// The snippet may have multiple lines, but only the result of the last line
1508                /// will be considered.
1509                /// 
1510                /// <p>Note that, by default, the snippet will be run in the runner's test window, not in the window
1511                /// of your application.  To get the window of your application, you can use
1512                /// the JavaScript snippet <code>selenium.browserbot.getCurrentWindow()</code>, and then
1513                /// run your JavaScript in there</p>
1514                /// </summary>
1515                /// <param name="script">the JavaScript snippet to run</param>
1516                /// <param name="timeout">a timeout in milliseconds, after which this command will return with an error</param>
1517                public void WaitForCondition(String script,String timeout)
1518                {
1519                        commandProcessor.DoCommand("waitForCondition", new String[] {script,timeout,});
1520                }
1521
1522
1523                /// <summary>Specifies the amount of time that Selenium will wait for actions to complete.
1524                /// 
1525                /// <p>Actions that require waiting include "open" and the "waitFor*" actions.</p>
1526                /// The default timeout is 30 seconds.
1527                /// </summary>
1528                /// <param name="timeout">a timeout in milliseconds, after which the action will return with an error</param>
1529                public void SetTimeout(String timeout)
1530                {
1531                        commandProcessor.DoCommand("setTimeout", new String[] {timeout,});
1532                }
1533
1534
1535                /// <summary>Waits for a new page to load.
1536                /// 
1537                /// <p>You can use this command instead of the "AndWait" suffixes, "clickAndWait", "selectAndWait", "typeAndWait" etc.
1538                /// (which are only available in the JS API).</p><p>Selenium constantly keeps track of new pages loading, and sets a "newPageLoaded"
1539                /// flag when it first notices a page load.  Running any other Selenium command after
1540                /// turns the flag to false.  Hence, if you want to wait for a page to load, you must
1541                /// wait immediately after a Selenium command that caused a page-load.</p>
1542                /// </summary>
1543                /// <param name="timeout">a timeout in milliseconds, after which this command will return with an error</param>
1544                public void WaitForPageToLoad(String timeout)
1545                {
1546                        commandProcessor.DoCommand("waitForPageToLoad", new String[] {timeout,});
1547                }
1548
1549
1550                /// <summary>Waits for a new frame to load.
1551                /// 
1552                /// <p>Selenium constantly keeps track of new pages and frames loading, 
1553                /// and sets a "newPageLoaded" flag when it first notices a page load.</p>
1554                /// 
1555                /// See waitForPageToLoad for more information.
1556                /// </summary>
1557                /// <param name="frameAddress">FrameAddress from the server side</param>
1558                /// <param name="timeout">a timeout in milliseconds, after which this command will return with an error</param>
1559                public void WaitForFrameToLoad(String frameAddress,String timeout)
1560                {
1561                        commandProcessor.DoCommand("waitForFrameToLoad", new String[] {frameAddress,timeout,});
1562                }
1563
1564
1565                /// <summary>Return all cookies of the current page under test.
1566                /// </summary>
1567                /// <returns>all cookies of the current page under test</returns>
1568                public String GetCookie()
1569                {
1570                        return commandProcessor.GetString("getCookie", new String[] {});
1571                }
1572
1573
1574                /// <summary>Returns the value of the cookie with the specified name, or throws an error if the cookie is not present.
1575                /// </summary>
1576                /// <param name="name">the name of the cookie</param>
1577                /// <returns>the value of the cookie</returns>
1578                public String GetCookieByName(String name)
1579                {
1580                        return commandProcessor.GetString("getCookieByName", new String[] {name,});
1581                }
1582
1583
1584                /// <summary>Returns true if a cookie with the specified name is present, or false otherwise.
1585                /// </summary>
1586                /// <param name="name">the name of the cookie</param>
1587                /// <returns>true if a cookie with the specified name is present, or false otherwise.</returns>
1588                public bool IsCookiePresent(String name)
1589                {
1590                        return commandProcessor.GetBoolean("isCookiePresent", new String[] {name,});
1591                }
1592
1593
1594                /// <summary>Create a new cookie whose path and domain are same with those of current page
1595                /// under test, unless you specified a path for this cookie explicitly.
1596                /// </summary>
1597                /// <param name="nameValuePair">name and value of the cookie in a format "name=value"</param>
1598                /// <param name="optionsString">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.</param>
1599                public void CreateCookie(String nameValuePair,String optionsString)
1600                {
1601                        commandProcessor.DoCommand("createCookie", new String[] {nameValuePair,optionsString,});
1602                }
1603
1604
1605                /// <summary>Delete a named cookie with specified path and domain.  Be careful; to delete a cookie, you
1606                /// need to delete it using the exact same path and domain that were used to create the cookie.
1607                /// If the path is wrong, or the domain is wrong, the cookie simply won't be deleted.  Also
1608                /// note that specifying a domain that isn't a subset of the current domain will usually fail.
1609                /// 
1610                /// Since there's no way to discover at runtime the original path and domain of a given cookie,
1611                /// we've added an option called 'recurse' to try all sub-domains of the current domain with
1612                /// all paths that are a subset of the current path.  Beware; this option can be slow.  In
1613                /// big-O notation, it operates in O(n*m) time, where n is the number of dots in the domain
1614                /// name and m is the number of slashes in the path.
1615                /// </summary>
1616                /// <param name="name">the name of the cookie to be deleted</param>
1617                /// <param name="optionsString">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.</param>
1618                public void DeleteCookie(String name,String optionsString)
1619                {
1620                        commandProcessor.DoCommand("deleteCookie", new String[] {name,optionsString,});
1621                }
1622
1623
1624                /// <summary>Calls deleteCookie with recurse=true on all cookies visible to the current page.
1625                /// As noted on the documentation for deleteCookie, recurse=true can be much slower
1626                /// than simply deleting the cookies using a known domain/path.
1627                /// </summary>
1628                public void DeleteAllVisibleCookies()
1629                {
1630                        commandProcessor.DoCommand("deleteAllVisibleCookies", new String[] {});
1631                }
1632
1633
1634                /// <summary>Sets the threshold for browser-side logging messages; log messages beneath this threshold will be discarded.
1635                /// Valid logLevel strings are: "debug", "info", "warn", "error" or "off".
1636                /// To see the browser logs, you need to
1637                /// either show the log window in GUI mode, or enable browser-side logging in Selenium RC.
1638                /// </summary>
1639                /// <param name="logLevel">one of the following: "debug", "info", "warn", "error" or "off"</param>
1640                public void SetBrowserLogLevel(String logLevel)
1641                {
1642                        commandProcessor.DoCommand("setBrowserLogLevel", new String[] {logLevel,});
1643                }
1644
1645
1646                /// <summary>Creates a new "script" tag in the body of the current test window, and 
1647                /// adds the specified text into the body of the command.  Scripts run in
1648                /// this way can often be debugged more easily than scripts executed using
1649                /// Selenium's "getEval" command.  Beware that JS exceptions thrown in these script
1650                /// tags aren't managed by Selenium, so you should probably wrap your script
1651                /// in try/catch blocks if there is any chance that the script will throw
1652                /// an exception.
1653                /// </summary>
1654                /// <param name="script">the JavaScript snippet to run</param>
1655                public void RunScript(String script)
1656                {
1657                        commandProcessor.DoCommand("runScript", new String[] {script,});
1658                }
1659
1660
1661                /// <summary>Defines a new function for Selenium to locate elements on the page.
1662                /// For example,
1663                /// if you define the strategy "foo", and someone runs click("foo=blah"), we'll
1664                /// run your function, passing you the string "blah", and click on the element 
1665                /// that your function
1666                /// returns, or throw an "Element not found" error if your function returns null.
1667                /// 
1668                /// We'll pass three arguments to your function:
1669                /// <ul><li>locator: the string the user passed in</li><li>inWindow: the currently selected window</li><li>inDocument: the currently selected document</li></ul>
1670                /// The function must return null if the element can't be found.
1671                /// </summary>
1672                /// <param name="strategyName">the name of the strategy to define; this should use only   letters [a-zA-Z] with no spaces or other punctuation.</param>
1673                /// <param name="functionDefinition">a string defining the body of a function in JavaScript.   For example: <code>return inDocument.getElementById(locator);</code></param>
1674                public void AddLocationStrategy(String strategyName,String functionDefinition)
1675                {
1676                        commandProcessor.DoCommand("addLocationStrategy", new String[] {strategyName,functionDefinition,});
1677                }
1678
1679
1680                /// <summary>Saves the entire contents of the current window canvas to a PNG file.
1681                /// Contrast this with the captureScreenshot command, which captures the
1682                /// contents of the OS viewport (i.e. whatever is currently being displayed
1683                /// on the monitor), and is implemented in the RC only. Currently this only
1684                /// works in Firefox when running in chrome mode, and in IE non-HTA using
1685                /// the EXPERIMENTAL "Snapsie" utility. The Firefox implementation is mostly
1686                /// borrowed from the Screengrab! Firefox extension. Please see
1687                /// http://www.screengrab.org and http://snapsie.sourceforge.net/ for
1688                /// details.
1689                /// </summary>
1690                /// <param name="filename">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.</param>
1691                /// <param name="kwargs">a kwargs string that modifies the way the screenshot                  is captured. Example: "background=#CCFFDD" .                  Currently valid options:                  <dl><dt>background</dt><dd>the background CSS for the HTML document. This                     may be useful to set for capturing screenshots of                     less-than-ideal layouts, for example where absolute                     positioning causes the calculation of the canvas                     dimension to fail and a black background is exposed                     (possibly obscuring black text).</dd></dl></param>
1692                public void CaptureEntirePageScreenshot(String filename,String kwargs)
1693                {
1694                        commandProcessor.DoCommand("captureEntirePageScreenshot", new String[] {filename,kwargs,});
1695                }
1696
1697
1698                /// <summary>Executes a command rollup, which is a series of commands with a unique
1699                /// name, and optionally arguments that control the generation of the set of
1700                /// commands. If any one of the rolled-up commands fails, the rollup is
1701                /// considered to have failed. Rollups may also contain nested rollups.
1702                /// </summary>
1703                /// <param name="rollupName">the name of the rollup command</param>
1704                /// <param name="kwargs">keyword arguments string that influences how the                    rollup expands into commands</param>
1705                public void Rollup(String rollupName,String kwargs)
1706                {
1707                        commandProcessor.DoCommand("rollup", new String[] {rollupName,kwargs,});
1708                }
1709
1710
1711                /// <summary>Loads script content into a new script tag in the Selenium document. This
1712                /// differs from the runScript command in that runScript adds the script tag
1713                /// to the document of the AUT, not the Selenium document. The following
1714                /// entities in the script content are replaced by the characters they
1715                /// represent:
1716                /// 
1717                ///     &lt;
1718                ///     &gt;
1719                ///     &amp;
1720                /// 
1721                /// The corresponding remove command is removeScript.
1722                /// </summary>
1723                /// <param name="scriptContent">the Javascript content of the script to add</param>
1724                /// <param name="scriptTagId">(optional) the id of the new script tag. If                       specified, and an element with this id already                       exists, this operation will fail.</param>
1725                public void AddScript(String scriptContent,String scriptTagId)
1726                {
1727                        commandProcessor.DoCommand("addScript", new String[] {scriptContent,scriptTagId,});
1728                }
1729
1730
1731                /// <summary>Removes a script tag from the Selenium document identified by the given
1732                /// id. Does nothing if the referenced tag doesn't exist.
1733                /// </summary>
1734                /// <param name="scriptTagId">the id of the script element to remove.</param>
1735                public void RemoveScript(String scriptTagId)
1736                {
1737                        commandProcessor.DoCommand("removeScript", new String[] {scriptTagId,});
1738                }
1739
1740
1741                /// <summary>Allows choice of one of the available libraries.
1742                /// </summary>
1743                /// <param name="libraryName">name of the desired library Only the following three can be chosen: <ul><li>"ajaxslt" - Google's library</li><li>"javascript-xpath" - Cybozu Labs' faster library</li><li>"default" - The default library.  Currently the default library is "ajaxslt" .</li></ul> If libraryName isn't one of these three, then  no change will be made.</param>
1744                public void UseXpathLibrary(String libraryName)
1745                {
1746                        commandProcessor.DoCommand("useXpathLibrary", new String[] {libraryName,});
1747                }
1748
1749
1750                /// <summary>Writes a message to the status bar and adds a note to the browser-side
1751                /// log.
1752                /// </summary>
1753                /// <param name="context">the message to be sent to the browser</param>
1754                public void SetContext(String context)
1755                {
1756                        commandProcessor.DoCommand("setContext", new String[] {context,});
1757                }
1758
1759
1760                /// <summary>Sets a file input (upload) field to the file listed in fileLocator
1761                /// </summary>
1762                /// <param name="fieldLocator">an <a href="#locators">element locator</a></param>
1763                /// <param name="fileLocator">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.</param>
1764                public void AttachFile(String fieldLocator,String fileLocator)
1765                {
1766                        commandProcessor.DoCommand("attachFile", new String[] {fieldLocator,fileLocator,});
1767                }
1768
1769
1770                /// <summary>Captures a PNG screenshot to the specified file.
1771                /// </summary>
1772                /// <param name="filename">the absolute path to the file to be written, e.g. "c:\blah\screenshot.png"</param>
1773                public void CaptureScreenshot(String filename)
1774                {
1775                        commandProcessor.DoCommand("captureScreenshot", new String[] {filename,});
1776                }
1777
1778
1779                /// <summary>Capture a PNG screenshot.  It then returns the file as a base 64 encoded string.
1780                /// </summary>
1781                /// <returns>The base 64 encoded string of the screen shot (PNG file)</returns>
1782                public String CaptureScreenshotToString()
1783                {
1784                        return commandProcessor.GetString("captureScreenshotToString", new String[] {});
1785                }
1786        
1787        /// <summary>
1788        /// Captures the Network Traffic that is passing through Selenium Server
1789        /// </summary>
1790        /// <param name="type"></param>
1791        /// <returns></returns>
1792        public string CaptureNetworkTraffic(string type)
1793        {
1794            return commandProcessor.GetString("captureNetworkTraffic", new string[] {type});
1795        }
1796
1797                /// <summary>Downloads a screenshot of the browser current window canvas to a 
1798                /// based 64 encoded PNG file. The <em>entire</em> windows canvas is captured,
1799                /// including parts rendered outside of the current view port.
1800                /// 
1801                /// Currently this only works in Mozilla and when running in chrome mode.
1802                /// </summary>
1803                /// <param name="kwargs">A kwargs string that modifies the way the screenshot is captured. Example: "background=#CCFFDD". This may be useful to set for capturing screenshots of less-than-ideal layouts, for example where absolute positioning causes the calculation of the canvas dimension to fail and a black background is exposed  (possibly obscuring black text).</param>
1804                /// <returns>The base 64 encoded string of the page screenshot (PNG file)</returns>
1805                public String CaptureEntirePageScreenshotToString(String kwargs)
1806                {
1807                        return commandProcessor.GetString("captureEntirePageScreenshotToString", new String[] {kwargs,});
1808                }
1809
1810
1811                /// <summary>Kills the running Selenium Server and all browser sessions.  After you run this command, you will no longer be able to send
1812                /// commands to the server; you can't remotely start the server once it has been stopped.  Normally
1813                /// you should prefer to run the "stop" command, which terminates the current browser session, rather than 
1814                /// shutting down the entire server.
1815                /// </summary>
1816                public void ShutDownSeleniumServer()
1817                {
1818                        commandProcessor.DoCommand("shutDownSeleniumServer", new String[] {});
1819                }
1820
1821
1822                /// <summary>Retrieve the last messages logged on a specific remote control. Useful for error reports, especially
1823                /// when running multiple remote controls in a distributed environment. The maximum number of log messages
1824                /// that can be retrieve is configured on remote control startup.
1825                /// </summary>
1826                /// <returns>The last N log messages as a multi-line string.</returns>
1827                public String RetrieveLastRemoteControlLogs()
1828                {
1829                        return commandProcessor.GetString("retrieveLastRemoteControlLogs", new String[] {});
1830                }
1831
1832
1833                /// <summary>Simulates a user pressing a key (without releasing it yet) by sending a native operating system keystroke.
1834                /// This function uses the java.awt.Robot class to send a keystroke; this more accurately simulates typing
1835                /// a key on the keyboard.  It does not honor settings from the shiftKeyDown, controlKeyDown, altKeyDown and
1836                /// metaKeyDown commands, and does not target any particular HTML element.  To send a keystroke to a particular
1837                /// element, focus on the element first before running this command.
1838                /// </summary>
1839                /// <param name="keycode">an integer keycode number corresponding to a java.awt.event.KeyEvent; note that Java keycodes are NOT the same thing as JavaScript keycodes!</param>
1840                public void KeyDownNative(String keycode)
1841                {
1842                        commandProcessor.DoCommand("keyDownNative", new String[] {keycode,});
1843                }
1844
1845
1846                /// <summary>Simulates a user releasing a key by sending a native operating system keystroke.
1847                /// This function uses the java.awt.Robot class to send a keystroke; this more accurately simulates typing
1848                /// a key on the keyboard.  It does not honor settings from the shiftKeyDown, controlKeyDown, altKeyDown and
1849                /// metaKeyDown commands, and does not target any particular HTML element.  To send a keystroke to a particular
1850                /// element, focus on the element first before running this command.
1851                /// </summary>
1852                /// <param name="keycode">an integer keycode number corresponding to a java.awt.event.KeyEvent; note that Java keycodes are NOT the same thing as JavaScript keycodes!</param>
1853                public void KeyUpNative(String keycode)
1854                {
1855                        commandProcessor.DoCommand("keyUpNative", new String[] {keycode,});
1856                }
1857
1858
1859                /// <summary>Simulates a user pressing and releasing a key by sending a native operating system keystroke.
1860                /// This function uses the java.awt.Robot class to send a keystroke; this more accurately simulates typing
1861                /// a key on the keyboard.  It does not honor settings from the shiftKeyDown, controlKeyDown, altKeyDown and
1862                /// metaKeyDown commands, and does not target any particular HTML element.  To send a keystroke to a particular
1863                /// element, focus on the element first before running this command.
1864                /// </summary>
1865                /// <param name="keycode">an integer keycode number corresponding to a java.awt.event.KeyEvent; note that Java keycodes are NOT the same thing as JavaScript keycodes!</param>
1866                public void KeyPressNative(String keycode)
1867                {
1868                        commandProcessor.DoCommand("keyPressNative", new String[] {keycode,});
1869                }
1870
1871        }
1872}
1873    
1874
1875
Full Screen

Accelerate Your Automation Test Cycles With LambdaTest

Leverage LambdaTest’s cloud-based platform to execute your automation tests in parallel and trim down your test execution time significantly. Your first 100 automation testing minutes are on us.

Try LambdaTest

Most used method in Program

Trigger Main code on LambdaTest Cloud Grid

Execute automation tests with Main on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free
LambdaTestX

We use cookies to give you the best experience. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. Learn More in our Cookies policy, Privacy & Terms of service

Allow Cookie
Sarah

I hope you find the best code examples for your project.

If you want to accelerate automated browser testing, try LambdaTest. Your first 100 automation testing minutes are FREE.

Sarah Elson (Product & Growth Lead)