How to use Program class of Example.GetAllLinks package

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

DefaultSelenium.cs

Source:DefaultSelenium.cs Github

copy

Full Screen

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 at7 *8 * http://www.apache.org/licenses/LICENSE-2.09 *10 * Unless required by applicable law or agreed to in writing, software11 * 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 and14 * limitations under the License.15 *16 */17// This file has been automatically generated via XSL18using System;19namespace Selenium20{21 /// <summary>Defines an object that runs Selenium commands.22 /// 23 /// <h3><a name="locators"></a>Element Locators</h3><p>24 /// Element Locators tell Selenium which HTML element a command refers to.25 /// The format of a locator is:</p><blockquote><em>locatorType</em><strong>=</strong><em>argument</em></blockquote><p>26 /// We support the following strategies for locating elements:27 /// </p><ul><li><strong>identifier</strong>=<em>id</em>: 28 /// Select the element with the specified @id attribute. If no match is29 /// found, select the first element whose @name attribute is <em>id</em>.30 /// (This is normally the default; see below.)</li><li><strong>id</strong>=<em>id</em>:31 /// Select the element with the specified @id attribute.</li><li><strong>name</strong>=<em>name</em>:32 /// Select the first element with the specified @name attribute.33 /// <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>: 34 /// 35 /// Find an element by evaluating the specified string. This allows you to traverse the HTML Document Object36 /// Model using JavaScript. Note that you must not return a value in this string; simply make it the last expression in the block.37 /// <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>: 38 /// Locate an element using an XPath expression.39 /// <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>:40 /// Select the link (anchor) element which contains text matching the41 /// specified <em>pattern</em>.42 /// <ul class="first last simple"><li>link=The link text</li></ul></li><li><strong>css</strong>=<em>cssSelectorSyntax</em>:43 /// 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.44 /// <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>:45 /// 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.46 /// <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>47 /// Without an explicit locator prefix, Selenium uses the following default48 /// strategies:49 /// </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>50 /// 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>51 /// 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>52 /// Various Pattern syntaxes are available for matching string values:53 /// </p><ul><li><strong>glob:</strong><em>pattern</em>:54 /// Match a string against a "glob" (aka "wildmat") pattern. "Glob" is a55 /// kind of limited regular-expression syntax typically used in command-line56 /// shells. In a glob pattern, "*" represents any sequence of characters, and "?"57 /// represents any single character. Glob patterns match against the entire58 /// string.</li><li><strong>regexp:</strong><em>regexp</em>:59 /// Match a string using a regular-expression. The full power of JavaScript60 /// regular-expressions is available.</li><li><strong>regexpi:</strong><em>regexpi</em>:61 /// Match a string using a case-insensitive regular-expression.</li><li><strong>exact:</strong><em>string</em>:62 /// 63 /// Match a string exactly, verbatim, without any of that fancy wildcard64 /// stuff.</li></ul><p>65 /// If no pattern prefix is specified, Selenium assumes that it's a "glob"66 /// pattern.67 /// </p><p>68 /// For commands that return multiple values (such as verifySelectOptions),69 /// the string being matched is a comma-separated list of the return values,70 /// where both commas and backslashes in the values are backslash-escaped.71 /// When providing a pattern, the optional matching syntax (i.e. glob,72 /// regexp, etc.) is specified once, as usual, at the beginning of the73 /// pattern.74 /// </p>75 /// </summary>76 // This file has been automatically generated using XSL77 // This part of the file is hard-coded in the XSL78 public class DefaultSelenium : ISelenium79 {80 81 protected ICommandProcessor commandProcessor;82 /// <summary>83 /// Uses a CommandBridgeClient, specifying a server host/port, a command to launch the browser, and a starting URL for the browser.84 /// 85 /// <p><i>browserString</i> may be any one of the following:</p>86 /// <ul>87 /// <li><code>*firefox [absolute path]</code> - Automatically launch a new Firefox process using a custom Firefox profile.88 /// This profile will be automatically configured to use the Selenium Server as a proxy and to have all annoying prompts89 /// ("save your password?" "forms are insecure" "make Firefox your default browser?" disabled. You may optionally specify90 /// an absolute path to your firefox executable, or just say "*firefox". If no absolute path is specified, we'll look for91 /// firefox.exe in a default location (normally c:\program files\mozilla firefox\firefox.exe), which you can override by92 /// setting the Java system property <code>firefoxDefaultPath</code> to the correct path to Firefox.</li>93 /// <li><code>*iexplore [absolute path]</code> - Automatically launch a new Internet Explorer process using custom Windows registry settings.94 /// This process will be automatically configured to use the Selenium Server as a proxy and to have all annoying prompts95 /// ("save your password?" "forms are insecure" "make Firefox your default browser?" disabled. You may optionally specify96 /// an absolute path to your iexplore executable, or just say "*iexplore". If no absolute path is specified, we'll look for97 /// iexplore.exe in a default location (normally c:\program files\internet explorer\iexplore.exe), which you can override by98 /// setting the Java system property <code>iexploreDefaultPath</code> to the correct path to Internet Explorer.</li>99 /// <li><code>/path/to/my/browser [other arguments]</code> - You may also simply specify the absolute path to your browser100 /// executable, or use a relative path to your executable (which we'll try to find on your path). <b>Warning:</b> If you101 /// specify your own custom browser, it's up to you to configure it correctly. At a minimum, you'll need to configure your102 /// browser to use the Selenium Server as a proxy, and disable all browser-specific prompting.</li>103 /// </ul>104 /// </summary>105 /// 106 /// <param name="serverHost">the host name on which the Selenium Server resides</param>107 /// <param name="serverPort">the port on which the Selenium Server is listening</param>108 /// <param name="browserString">the command string used to launch the browser, e.g. "*firefox", "*iexplore" or "c:\\program files\\internet explorer\\iexplore.exe"</param>109 /// <param name="browserURL">the starting URL including just a domain name. We'll start the browser pointing at the Selenium resources on this URL,110 /// e.g. "http://www.google.com" would send the browser to "http://www.google.com/selenium-server/RemoteRunner.html"</param>111 public DefaultSelenium(String serverHost, int serverPort, String browserString, String browserURL)112 {113 this.commandProcessor = new HttpCommandProcessor(serverHost, serverPort, browserString, browserURL);114 }115 116 /// <summary>117 /// Uses an arbitrary CommandProcessor118 /// </summary>119 public DefaultSelenium(ICommandProcessor processor)120 {121 this.commandProcessor = processor;122 }123 124 /// <summary>125 /// The command processor that handles all of our Selenium commands126 /// </summary>127 public ICommandProcessor Processor128 {129 get { return this.commandProcessor; }130 }131 132 /// <summary>133 /// Sets the extension Javascript for the session134 /// </summary>135 public void SetExtensionJs(string extensionJs)136 {137 commandProcessor.SetExtensionJs(extensionJs);138 }139 140 /// <summary>141 /// Starts a new Selenium testing session142 /// </summary>143 public void Start()144 {145 commandProcessor.Start();146 }147 148 /// <summary>149 /// 150 /// </summary>151 /// <param name="optionsString"></param>152 public void Start(string optionsString)153 {154 commandProcessor.Start(optionsString);155 }156 /// <summary>157 /// Ends the current Selenium testing session (normally killing the browser)158 /// </summary>159 public void Stop()160 {161 commandProcessor.Stop();162 }163 164 // From here on, everything in this file has been auto-generated165 166 /// <summary>Clicks on a link, button, checkbox or radio button. If the click action167 /// causes a new page to load (like a link usually does), call168 /// waitForPageToLoad.169 /// </summary>170 /// <param name="locator">an element locator</param>171 public void Click(String locator)172 {173 commandProcessor.DoCommand("click", new String[] {locator,});174 }175 /// <summary>Double clicks on a link, button, checkbox or radio button. If the double click action176 /// causes a new page to load (like a link usually does), call177 /// waitForPageToLoad.178 /// </summary>179 /// <param name="locator">an element locator</param>180 public void DoubleClick(String locator)181 {182 commandProcessor.DoCommand("doubleClick", new String[] {locator,});183 }184 /// <summary>Simulates opening the context menu for the specified element (as might happen if the user "right-clicked" on the element).185 /// </summary>186 /// <param name="locator">an element locator</param>187 public void ContextMenu(String locator)188 {189 commandProcessor.DoCommand("contextMenu", new String[] {locator,});190 }191 /// <summary>Clicks on a link, button, checkbox or radio button. If the click action192 /// causes a new page to load (like a link usually does), call193 /// waitForPageToLoad.194 /// </summary>195 /// <param name="locator">an element locator</param>196 /// <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>197 public void ClickAt(String locator,String coordString)198 {199 commandProcessor.DoCommand("clickAt", new String[] {locator,coordString,});200 }201 /// <summary>Doubleclicks on a link, button, checkbox or radio button. If the action202 /// causes a new page to load (like a link usually does), call203 /// waitForPageToLoad.204 /// </summary>205 /// <param name="locator">an element locator</param>206 /// <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>207 public void DoubleClickAt(String locator,String coordString)208 {209 commandProcessor.DoCommand("doubleClickAt", new String[] {locator,coordString,});210 }211 /// <summary>Simulates opening the context menu for the specified element (as might happen if the user "right-clicked" on the element).212 /// </summary>213 /// <param name="locator">an element locator</param>214 /// <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>215 public void ContextMenuAt(String locator,String coordString)216 {217 commandProcessor.DoCommand("contextMenuAt", new String[] {locator,coordString,});218 }219 /// <summary>Explicitly simulate an event, to trigger the corresponding "on<em>event</em>"220 /// handler.221 /// </summary>222 /// <param name="locator">an <a href="#locators">element locator</a></param>223 /// <param name="eventName">the event name, e.g. "focus" or "blur"</param>224 public void FireEvent(String locator,String eventName)225 {226 commandProcessor.DoCommand("fireEvent", new String[] {locator,eventName,});227 }228 /// <summary>Move the focus to the specified element; for example, if the element is an input field, move the cursor to that field.229 /// </summary>230 /// <param name="locator">an <a href="#locators">element locator</a></param>231 public void Focus(String locator)232 {233 commandProcessor.DoCommand("focus", new String[] {locator,});234 }235 /// <summary>Simulates a user pressing and releasing a key.236 /// </summary>237 /// <param name="locator">an <a href="#locators">element locator</a></param>238 /// <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>239 public void KeyPress(String locator,String keySequence)240 {241 commandProcessor.DoCommand("keyPress", new String[] {locator,keySequence,});242 }243 /// <summary>Press the shift key and hold it down until doShiftUp() is called or a new page is loaded.244 /// </summary>245 public void ShiftKeyDown()246 {247 commandProcessor.DoCommand("shiftKeyDown", new String[] {});248 }249 /// <summary>Release the shift key.250 /// </summary>251 public void ShiftKeyUp()252 {253 commandProcessor.DoCommand("shiftKeyUp", new String[] {});254 }255 /// <summary>Press the meta key and hold it down until doMetaUp() is called or a new page is loaded.256 /// </summary>257 public void MetaKeyDown()258 {259 commandProcessor.DoCommand("metaKeyDown", new String[] {});260 }261 /// <summary>Release the meta key.262 /// </summary>263 public void MetaKeyUp()264 {265 commandProcessor.DoCommand("metaKeyUp", new String[] {});266 }267 /// <summary>Press the alt key and hold it down until doAltUp() is called or a new page is loaded.268 /// </summary>269 public void AltKeyDown()270 {271 commandProcessor.DoCommand("altKeyDown", new String[] {});272 }273 /// <summary>Release the alt key.274 /// </summary>275 public void AltKeyUp()276 {277 commandProcessor.DoCommand("altKeyUp", new String[] {});278 }279 /// <summary>Press the control key and hold it down until doControlUp() is called or a new page is loaded.280 /// </summary>281 public void ControlKeyDown()282 {283 commandProcessor.DoCommand("controlKeyDown", new String[] {});284 }285 /// <summary>Release the control key.286 /// </summary>287 public void ControlKeyUp()288 {289 commandProcessor.DoCommand("controlKeyUp", new String[] {});290 }291 /// <summary>Simulates a user pressing a key (without releasing it yet).292 /// </summary>293 /// <param name="locator">an <a href="#locators">element locator</a></param>294 /// <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>295 public void KeyDown(String locator,String keySequence)296 {297 commandProcessor.DoCommand("keyDown", new String[] {locator,keySequence,});298 }299 /// <summary>Simulates a user releasing a key.300 /// </summary>301 /// <param name="locator">an <a href="#locators">element locator</a></param>302 /// <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>303 public void KeyUp(String locator,String keySequence)304 {305 commandProcessor.DoCommand("keyUp", new String[] {locator,keySequence,});306 }307 /// <summary>Simulates a user hovering a mouse over the specified element.308 /// </summary>309 /// <param name="locator">an <a href="#locators">element locator</a></param>310 public void MouseOver(String locator)311 {312 commandProcessor.DoCommand("mouseOver", new String[] {locator,});313 }314 /// <summary>Simulates a user moving the mouse pointer away from the specified element.315 /// </summary>316 /// <param name="locator">an <a href="#locators">element locator</a></param>317 public void MouseOut(String locator)318 {319 commandProcessor.DoCommand("mouseOut", new String[] {locator,});320 }321 /// <summary>Simulates a user pressing the left mouse button (without releasing it yet) on322 /// the specified element.323 /// </summary>324 /// <param name="locator">an <a href="#locators">element locator</a></param>325 public void MouseDown(String locator)326 {327 commandProcessor.DoCommand("mouseDown", new String[] {locator,});328 }329 /// <summary>Simulates a user pressing the right mouse button (without releasing it yet) on330 /// the specified element.331 /// </summary>332 /// <param name="locator">an <a href="#locators">element locator</a></param>333 public void MouseDownRight(String locator)334 {335 commandProcessor.DoCommand("mouseDownRight", new String[] {locator,});336 }337 /// <summary>Simulates a user pressing the left mouse button (without releasing it yet) at338 /// the specified location.339 /// </summary>340 /// <param name="locator">an <a href="#locators">element locator</a></param>341 /// <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>342 public void MouseDownAt(String locator,String coordString)343 {344 commandProcessor.DoCommand("mouseDownAt", new String[] {locator,coordString,});345 }346 /// <summary>Simulates a user pressing the right mouse button (without releasing it yet) at347 /// the specified location.348 /// </summary>349 /// <param name="locator">an <a href="#locators">element locator</a></param>350 /// <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>351 public void MouseDownRightAt(String locator,String coordString)352 {353 commandProcessor.DoCommand("mouseDownRightAt", new String[] {locator,coordString,});354 }355 /// <summary>Simulates the event that occurs when the user releases the mouse button (i.e., stops356 /// holding the button down) on the specified element.357 /// </summary>358 /// <param name="locator">an <a href="#locators">element locator</a></param>359 public void MouseUp(String locator)360 {361 commandProcessor.DoCommand("mouseUp", new String[] {locator,});362 }363 /// <summary>Simulates the event that occurs when the user releases the right mouse button (i.e., stops364 /// holding the button down) on the specified element.365 /// </summary>366 /// <param name="locator">an <a href="#locators">element locator</a></param>367 public void MouseUpRight(String locator)368 {369 commandProcessor.DoCommand("mouseUpRight", new String[] {locator,});370 }371 /// <summary>Simulates the event that occurs when the user releases the mouse button (i.e., stops372 /// holding the button down) at the specified location.373 /// </summary>374 /// <param name="locator">an <a href="#locators">element locator</a></param>375 /// <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>376 public void MouseUpAt(String locator,String coordString)377 {378 commandProcessor.DoCommand("mouseUpAt", new String[] {locator,coordString,});379 }380 /// <summary>Simulates the event that occurs when the user releases the right mouse button (i.e., stops381 /// holding the button down) at the specified location.382 /// </summary>383 /// <param name="locator">an <a href="#locators">element locator</a></param>384 /// <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>385 public void MouseUpRightAt(String locator,String coordString)386 {387 commandProcessor.DoCommand("mouseUpRightAt", new String[] {locator,coordString,});388 }389 /// <summary>Simulates a user pressing the mouse button (without releasing it yet) on390 /// the specified element.391 /// </summary>392 /// <param name="locator">an <a href="#locators">element locator</a></param>393 public void MouseMove(String locator)394 {395 commandProcessor.DoCommand("mouseMove", new String[] {locator,});396 }397 /// <summary>Simulates a user pressing the mouse button (without releasing it yet) on398 /// the specified element.399 /// </summary>400 /// <param name="locator">an <a href="#locators">element locator</a></param>401 /// <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>402 public void MouseMoveAt(String locator,String coordString)403 {404 commandProcessor.DoCommand("mouseMoveAt", new String[] {locator,coordString,});405 }406 /// <summary>Sets the value of an input field, as though you typed it in.407 /// 408 /// <p>Can also be used to set the value of combo boxes, check boxes, etc. In these cases,409 /// value should be the value of the option selected, not the visible text.</p>410 /// </summary>411 /// <param name="locator">an <a href="#locators">element locator</a></param>412 /// <param name="value">the value to type</param>413 public void Type(String locator,String value)414 {415 commandProcessor.DoCommand("type", new String[] {locator,value,});416 }417 /// <summary>Simulates keystroke events on the specified element, as though you typed the value key-by-key.418 /// 419 /// <p>This is a convenience method for calling keyDown, keyUp, keyPress for every character in the specified string;420 /// 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 command421 /// may or may not have any visible effect, even in cases where typing keys would normally have a visible effect.422 /// For example, if you use "typeKeys" on a form element, you may or may not see the results of what you typed in423 /// 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 to424 /// send the keystroke events corresponding to what you just typed.</p>425 /// </summary>426 /// <param name="locator">an <a href="#locators">element locator</a></param>427 /// <param name="value">the value to type</param>428 public void TypeKeys(String locator,String value)429 {430 commandProcessor.DoCommand("typeKeys", new String[] {locator,value,});431 }432 /// <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.,433 /// the delay is 0 milliseconds.434 /// </summary>435 /// <param name="value">the number of milliseconds to pause after operation</param>436 public void SetSpeed(String value)437 {438 commandProcessor.DoCommand("setSpeed", new String[] {value,});439 }440 /// <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.,441 /// the delay is 0 milliseconds.442 /// 443 /// See also setSpeed.444 /// </summary>445 /// <returns>the execution speed in milliseconds.</returns>446 public String GetSpeed()447 {448 return commandProcessor.GetString("getSpeed", new String[] {});449 }450 /// <summary>Check a toggle-button (checkbox/radio)451 /// </summary>452 /// <param name="locator">an <a href="#locators">element locator</a></param>453 public void Check(String locator)454 {455 commandProcessor.DoCommand("check", new String[] {locator,});456 }457 /// <summary>Uncheck a toggle-button (checkbox/radio)458 /// </summary>459 /// <param name="locator">an <a href="#locators">element locator</a></param>460 public void Uncheck(String locator)461 {462 commandProcessor.DoCommand("uncheck", new String[] {locator,});463 }464 /// <summary>Select an option from a drop-down using an option locator.465 /// 466 /// <p>467 /// Option locators provide different ways of specifying options of an HTML468 /// Select element (e.g. for selecting a specific option, or for asserting469 /// that the selected option satisfies a specification). There are several470 /// forms of Select Option Locator.471 /// </p><ul><li><strong>label</strong>=<em>labelPattern</em>:472 /// matches options based on their labels, i.e. the visible text. (This473 /// is the default.)474 /// <ul class="first last simple"><li>label=regexp:^[Oo]ther</li></ul></li><li><strong>value</strong>=<em>valuePattern</em>:475 /// matches options based on their values.476 /// <ul class="first last simple"><li>value=other</li></ul></li><li><strong>id</strong>=<em>id</em>:477 /// 478 /// matches options based on their ids.479 /// <ul class="first last simple"><li>id=option1</li></ul></li><li><strong>index</strong>=<em>index</em>:480 /// matches an option based on its index (offset from zero).481 /// <ul class="first last simple"><li>index=2</li></ul></li></ul><p>482 /// If no option locator prefix is provided, the default behaviour is to match on <strong>label</strong>.483 /// </p>484 /// </summary>485 /// <param name="selectLocator">an <a href="#locators">element locator</a> identifying a drop-down menu</param>486 /// <param name="optionLocator">an option locator (a label by default)</param>487 public void Select(String selectLocator,String optionLocator)488 {489 commandProcessor.DoCommand("select", new String[] {selectLocator,optionLocator,});490 }491 /// <summary>Add a selection to the set of selected options in a multi-select element using an option locator.492 /// 493 /// @see #doSelect for details of option locators494 /// </summary>495 /// <param name="locator">an <a href="#locators">element locator</a> identifying a multi-select box</param>496 /// <param name="optionLocator">an option locator (a label by default)</param>497 public void AddSelection(String locator,String optionLocator)498 {499 commandProcessor.DoCommand("addSelection", new String[] {locator,optionLocator,});500 }501 /// <summary>Remove a selection from the set of selected options in a multi-select element using an option locator.502 /// 503 /// @see #doSelect for details of option locators504 /// </summary>505 /// <param name="locator">an <a href="#locators">element locator</a> identifying a multi-select box</param>506 /// <param name="optionLocator">an option locator (a label by default)</param>507 public void RemoveSelection(String locator,String optionLocator)508 {509 commandProcessor.DoCommand("removeSelection", new String[] {locator,optionLocator,});510 }511 /// <summary>Unselects all of the selected options in a multi-select element.512 /// </summary>513 /// <param name="locator">an <a href="#locators">element locator</a> identifying a multi-select box</param>514 public void RemoveAllSelections(String locator)515 {516 commandProcessor.DoCommand("removeAllSelections", new String[] {locator,});517 }518 /// <summary>Submit the specified form. This is particularly useful for forms without519 /// submit buttons, e.g. single-input "Search" forms.520 /// </summary>521 /// <param name="formLocator">an <a href="#locators">element locator</a> for the form you want to submit</param>522 public void Submit(String formLocator)523 {524 commandProcessor.DoCommand("submit", new String[] {formLocator,});525 }526 /// <summary>Opens an URL in the test frame. This accepts both relative and absolute527 /// URLs.528 /// 529 /// The "open" command waits for the page to load before proceeding,530 /// ie. the "AndWait" suffix is implicit.531 /// 532 /// <em>Note</em>: The URL must be on the same domain as the runner HTML533 /// due to security restrictions in the browser (Same Origin Policy). If you534 /// need to open an URL on another domain, use the Selenium Server to start a535 /// new browser session on that domain.536 /// </summary>537 /// <param name="url">the URL to open; may be relative or absolute</param>538 public void Open(String url)539 {540 commandProcessor.DoCommand("open", new String[] {url,});541 }542 /// <summary>Opens a popup window (if a window with that ID isn't already open).543 /// After opening the window, you'll need to select it using the selectWindow544 /// command.545 /// 546 /// <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).547 /// In those cases, you can force Selenium to notice the open window's name by using the Selenium openWindow command, using548 /// an empty (blank) url, like this: openWindow("", "myFunnyWindow").</p>549 /// </summary>550 /// <param name="url">the URL to open, which can be blank</param>551 /// <param name="windowID">the JavaScript window ID of the window to select</param>552 public void OpenWindow(String url,String windowID)553 {554 commandProcessor.DoCommand("openWindow", new String[] {url,windowID,});555 }556 /// <summary>Selects a popup window using a window locator; once a popup window has been selected, all557 /// commands go to that window. To select the main window again, use null558 /// as the target.559 /// 560 /// <p>561 /// 562 /// Window locators provide different ways of specifying the window object:563 /// by title, by internal JavaScript "name," or by JavaScript variable.564 /// </p><ul><li><strong>title</strong>=<em>My Special Window</em>:565 /// Finds the window using the text that appears in the title bar. Be careful;566 /// two windows can share the same title. If that happens, this locator will567 /// just pick one.568 /// </li><li><strong>name</strong>=<em>myWindow</em>:569 /// Finds the window using its internal JavaScript "name" property. This is the second 570 /// parameter "windowName" passed to the JavaScript method window.open(url, windowName, windowFeatures, replaceFlag)571 /// (which Selenium intercepts).572 /// </li><li><strong>var</strong>=<em>variableName</em>:573 /// Some pop-up windows are unnamed (anonymous), but are associated with a JavaScript variable name in the current574 /// application window, e.g. "window.foo = window.open(url);". In those cases, you can open the window using575 /// "var=foo".576 /// </li></ul><p>577 /// 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 assumed578 /// 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".579 /// 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 messages580 /// which identify the names of windows created via window.open (and therefore intercepted by Selenium). You will see messages581 /// 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).582 /// (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, using583 /// an empty (blank) url, like this: openWindow("", "myFunnyWindow").</p>584 /// </summary>585 /// <param name="windowID">the JavaScript window ID of the window to select</param>586 public void SelectWindow(String windowID)587 {588 commandProcessor.DoCommand("selectWindow", new String[] {windowID,});589 }590 /// <summary>Simplifies the process of selecting a popup window (and does not offer591 /// functionality beyond what <code>selectWindow()</code> already provides).592 /// <ul><li>If <code>windowID</code> is either not specified, or specified as593 /// "null", the first non-top window is selected. The top window is the one594 /// that would be selected by <code>selectWindow()</code> without providing a595 /// <code>windowID</code> . This should not be used when more than one popup596 /// window is in play.</li><li>Otherwise, the window will be looked up considering597 /// <code>windowID</code> as the following in order: 1) the "name" of the598 /// window, as specified to <code>window.open()</code>; 2) a javascript599 /// variable which is a reference to a window; and 3) the title of the600 /// window. This is the same ordered lookup performed by601 /// <code>selectWindow</code> .</li></ul>602 /// </summary>603 /// <param name="windowID">an identifier for the popup window, which can take on a number of different meanings</param>604 public void SelectPopUp(String windowID)605 {606 commandProcessor.DoCommand("selectPopUp", new String[] {windowID,});607 }608 /// <summary>Selects the main window. Functionally equivalent to using609 /// <code>selectWindow()</code> and specifying no value for610 /// <code>windowID</code>.611 /// </summary>612 public void DeselectPopUp()613 {614 commandProcessor.DoCommand("deselectPopUp", new String[] {});615 }616 /// <summary>Selects a frame within the current window. (You may invoke this command617 /// multiple times to select nested frames.) To select the parent frame, use618 /// "relative=parent" as a locator; to select the top frame, use "relative=top".619 /// You can also select a frame by its 0-based index number; select the first frame with620 /// "index=0", or the third frame with "index=2".621 /// 622 /// <p>You may also use a DOM expression to identify the frame you want directly,623 /// like this: <code>dom=frames["main"].frames["subframe"]</code></p>624 /// </summary>625 /// <param name="locator">an <a href="#locators">element locator</a> identifying a frame or iframe</param>626 public void SelectFrame(String locator)627 {628 commandProcessor.DoCommand("selectFrame", new String[] {locator,});629 }630 /// <summary>Determine whether current/locator identify the frame containing this running code.631 /// 632 /// <p>This is useful in proxy injection mode, where this code runs in every633 /// browser frame and window, and sometimes the selenium server needs to identify634 /// the "current" frame. In this case, when the test calls selectFrame, this635 /// routine is called for each frame to figure out which one has been selected.636 /// The selected frame will return true, while all others will return false.</p>637 /// </summary>638 /// <param name="currentFrameString">starting frame</param>639 /// <param name="target">new frame (which might be relative to the current one)</param>640 /// <returns>true if the new frame is this code's window</returns>641 public bool GetWhetherThisFrameMatchFrameExpression(String currentFrameString,String target)642 {643 return commandProcessor.GetBoolean("getWhetherThisFrameMatchFrameExpression", new String[] {currentFrameString,target,});644 }645 /// <summary>Determine whether currentWindowString plus target identify the window containing this running code.646 /// 647 /// <p>This is useful in proxy injection mode, where this code runs in every648 /// browser frame and window, and sometimes the selenium server needs to identify649 /// the "current" window. In this case, when the test calls selectWindow, this650 /// routine is called for each window to figure out which one has been selected.651 /// The selected window will return true, while all others will return false.</p>652 /// </summary>653 /// <param name="currentWindowString">starting window</param>654 /// <param name="target">new window (which might be relative to the current one, e.g., "_parent")</param>655 /// <returns>true if the new window is this code's window</returns>656 public bool GetWhetherThisWindowMatchWindowExpression(String currentWindowString,String target)657 {658 return commandProcessor.GetBoolean("getWhetherThisWindowMatchWindowExpression", new String[] {currentWindowString,target,});659 }660 /// <summary>Waits for a popup window to appear and load up.661 /// </summary>662 /// <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>663 /// <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>664 public void WaitForPopUp(String windowID,String timeout)665 {666 commandProcessor.DoCommand("waitForPopUp", new String[] {windowID,timeout,});667 }668 /// <summary><p>669 /// By default, Selenium's overridden window.confirm() function will670 /// return true, as if the user had manually clicked OK; after running671 /// this command, the next call to confirm() will return false, as if672 /// the user had clicked Cancel. Selenium will then resume using the673 /// default behavior for future confirmations, automatically returning 674 /// true (OK) unless/until you explicitly call this command for each675 /// confirmation.676 /// </p><p>677 /// Take note - every time a confirmation comes up, you must678 /// consume it with a corresponding getConfirmation, or else679 /// the next selenium operation will fail.680 /// </p>681 /// </summary>682 public void ChooseCancelOnNextConfirmation()683 {684 commandProcessor.DoCommand("chooseCancelOnNextConfirmation", new String[] {});685 }686 /// <summary><p>687 /// Undo the effect of calling chooseCancelOnNextConfirmation. Note688 /// that Selenium's overridden window.confirm() function will normally automatically689 /// return true, as if the user had manually clicked OK, so you shouldn't690 /// need to use this command unless for some reason you need to change691 /// your mind prior to the next confirmation. After any confirmation, Selenium will resume using the692 /// default behavior for future confirmations, automatically returning 693 /// true (OK) unless/until you explicitly call chooseCancelOnNextConfirmation for each694 /// confirmation.695 /// </p><p>696 /// Take note - every time a confirmation comes up, you must697 /// consume it with a corresponding getConfirmation, or else698 /// the next selenium operation will fail.699 /// </p>700 /// </summary>701 public void ChooseOkOnNextConfirmation()702 {703 commandProcessor.DoCommand("chooseOkOnNextConfirmation", new String[] {});704 }705 /// <summary>Instructs Selenium to return the specified answer string in response to706 /// the next JavaScript prompt [window.prompt()].707 /// </summary>708 /// <param name="answer">the answer to give in response to the prompt pop-up</param>709 public void AnswerOnNextPrompt(String answer)710 {711 commandProcessor.DoCommand("answerOnNextPrompt", new String[] {answer,});712 }713 /// <summary>Simulates the user clicking the "back" button on their browser.714 /// </summary>715 public void GoBack()716 {717 commandProcessor.DoCommand("goBack", new String[] {});718 }719 /// <summary>Simulates the user clicking the "Refresh" button on their browser.720 /// </summary>721 public void Refresh()722 {723 commandProcessor.DoCommand("refresh", new String[] {});724 }725 /// <summary>Simulates the user clicking the "close" button in the titlebar of a popup726 /// window or tab.727 /// </summary>728 public void Close()729 {730 commandProcessor.DoCommand("close", new String[] {});731 }732 /// <summary>Has an alert occurred?733 /// 734 /// <p>735 /// This function never throws an exception736 /// </p>737 /// </summary>738 /// <returns>true if there is an alert</returns>739 public bool IsAlertPresent()740 {741 return commandProcessor.GetBoolean("isAlertPresent", new String[] {});742 }743 /// <summary>Has a prompt occurred?744 /// 745 /// <p>746 /// This function never throws an exception747 /// </p>748 /// </summary>749 /// <returns>true if there is a pending prompt</returns>750 public bool IsPromptPresent()751 {752 return commandProcessor.GetBoolean("isPromptPresent", new String[] {});753 }754 /// <summary>Has confirm() been called?755 /// 756 /// <p>757 /// This function never throws an exception758 /// </p>759 /// </summary>760 /// <returns>true if there is a pending confirmation</returns>761 public bool IsConfirmationPresent()762 {763 return commandProcessor.GetBoolean("isConfirmationPresent", new String[] {});764 }765 /// <summary>Retrieves the message of a JavaScript alert generated during the previous action, or fail if there were no alerts.766 /// 767 /// <p>Getting an alert has the same effect as manually clicking OK. If an768 /// alert is generated but you do not consume it with getAlert, the next Selenium action769 /// will fail.</p><p>Under Selenium, JavaScript alerts will NOT pop up a visible alert770 /// dialog.</p><p>Selenium does NOT support JavaScript alerts that are generated in a771 /// page's onload() event handler. In this case a visible dialog WILL be772 /// generated and Selenium will hang until someone manually clicks OK.</p>773 /// </summary>774 /// <returns>The message of the most recent JavaScript alert</returns>775 public String GetAlert()776 {777 return commandProcessor.GetString("getAlert", new String[] {});778 }779 /// <summary>Retrieves the message of a JavaScript confirmation dialog generated during780 /// the previous action.781 /// 782 /// <p>783 /// By default, the confirm function will return true, having the same effect784 /// as manually clicking OK. This can be changed by prior execution of the785 /// chooseCancelOnNextConfirmation command. 786 /// </p><p>787 /// If an confirmation is generated but you do not consume it with getConfirmation,788 /// the next Selenium action will fail.789 /// </p><p>790 /// NOTE: under Selenium, JavaScript confirmations will NOT pop up a visible791 /// dialog.792 /// </p><p>793 /// NOTE: Selenium does NOT support JavaScript confirmations that are794 /// generated in a page's onload() event handler. In this case a visible795 /// dialog WILL be generated and Selenium will hang until you manually click796 /// OK.797 /// </p>798 /// </summary>799 /// <returns>the message of the most recent JavaScript confirmation dialog</returns>800 public String GetConfirmation()801 {802 return commandProcessor.GetString("getConfirmation", new String[] {});803 }804 /// <summary>Retrieves the message of a JavaScript question prompt dialog generated during805 /// the previous action.806 /// 807 /// <p>Successful handling of the prompt requires prior execution of the808 /// answerOnNextPrompt command. If a prompt is generated but you809 /// do not get/verify it, the next Selenium action will fail.</p><p>NOTE: under Selenium, JavaScript prompts will NOT pop up a visible810 /// dialog.</p><p>NOTE: Selenium does NOT support JavaScript prompts that are generated in a811 /// page's onload() event handler. In this case a visible dialog WILL be812 /// generated and Selenium will hang until someone manually clicks OK.</p>813 /// </summary>814 /// <returns>the message of the most recent JavaScript question prompt</returns>815 public String GetPrompt()816 {817 return commandProcessor.GetString("getPrompt", new String[] {});818 }819 /// <summary>Gets the absolute URL of the current page.820 /// </summary>821 /// <returns>the absolute URL of the current page</returns>822 public String GetLocation()823 {824 return commandProcessor.GetString("getLocation", new String[] {});825 }826 /// <summary>Gets the title of the current page.827 /// </summary>828 /// <returns>the title of the current page</returns>829 public String GetTitle()830 {831 return commandProcessor.GetString("getTitle", new String[] {});832 }833 /// <summary>Gets the entire text of the page.834 /// </summary>835 /// <returns>the entire text of the page</returns>836 public String GetBodyText()837 {838 return commandProcessor.GetString("getBodyText", new String[] {});839 }840 /// <summary>Gets the (whitespace-trimmed) value of an input field (or anything else with a value parameter).841 /// For checkbox/radio elements, the value will be "on" or "off" depending on842 /// whether the element is checked or not.843 /// </summary>844 /// <param name="locator">an <a href="#locators">element locator</a></param>845 /// <returns>the element value, or "on/off" for checkbox/radio elements</returns>846 public String GetValue(String locator)847 {848 return commandProcessor.GetString("getValue", new String[] {locator,});849 }850 /// <summary>Gets the text of an element. This works for any element that contains851 /// text. This command uses either the textContent (Mozilla-like browsers) or852 /// the innerText (IE-like browsers) of the element, which is the rendered853 /// text shown to the user.854 /// </summary>855 /// <param name="locator">an <a href="#locators">element locator</a></param>856 /// <returns>the text of the element</returns>857 public String GetText(String locator)858 {859 return commandProcessor.GetString("getText", new String[] {locator,});860 }861 /// <summary>Briefly changes the backgroundColor of the specified element yellow. Useful for debugging.862 /// </summary>863 /// <param name="locator">an <a href="#locators">element locator</a></param>864 public void Highlight(String locator)865 {866 commandProcessor.DoCommand("highlight", new String[] {locator,});867 }868 /// <summary>Gets the result of evaluating the specified JavaScript snippet. The snippet may869 /// have multiple lines, but only the result of the last line will be returned.870 /// 871 /// <p>Note that, by default, the snippet will run in the context of the "selenium"872 /// object itself, so <code>this</code> will refer to the Selenium object. Use <code>window</code> to873 /// refer to the window of your application, e.g. <code>window.document.getElementById('foo')</code></p><p>If you need to use874 /// a locator to refer to a single element in your application page, you can875 /// use <code>this.browserbot.findElement("id=foo")</code> where "id=foo" is your locator.</p>876 /// </summary>877 /// <param name="script">the JavaScript snippet to run</param>878 /// <returns>the results of evaluating the snippet</returns>879 public String GetEval(String script)880 {881 return commandProcessor.GetString("getEval", new String[] {script,});882 }883 /// <summary>Gets whether a toggle-button (checkbox/radio) is checked. Fails if the specified element doesn't exist or isn't a toggle-button.884 /// </summary>885 /// <param name="locator">an <a href="#locators">element locator</a> pointing to a checkbox or radio button</param>886 /// <returns>true if the checkbox is checked, false otherwise</returns>887 public bool IsChecked(String locator)888 {889 return commandProcessor.GetBoolean("isChecked", new String[] {locator,});890 }891 /// <summary>Gets the text from a cell of a table. The cellAddress syntax892 /// tableLocator.row.column, where row and column start at 0.893 /// </summary>894 /// <param name="tableCellAddress">a cell address, e.g. "foo.1.4"</param>895 /// <returns>the text from the specified cell</returns>896 public String GetTable(String tableCellAddress)897 {898 return commandProcessor.GetString("getTable", new String[] {tableCellAddress,});899 }900 /// <summary>Gets all option labels (visible text) for selected options in the specified select or multi-select element.901 /// </summary>902 /// <param name="selectLocator">an <a href="#locators">element locator</a> identifying a drop-down menu</param>903 /// <returns>an array of all selected option labels in the specified select drop-down</returns>904 public String[] GetSelectedLabels(String selectLocator)905 {906 return commandProcessor.GetStringArray("getSelectedLabels", new String[] {selectLocator,});907 }908 /// <summary>Gets option label (visible text) for selected option in the specified select element.909 /// </summary>910 /// <param name="selectLocator">an <a href="#locators">element locator</a> identifying a drop-down menu</param>911 /// <returns>the selected option label in the specified select drop-down</returns>912 public String GetSelectedLabel(String selectLocator)913 {914 return commandProcessor.GetString("getSelectedLabel", new String[] {selectLocator,});915 }916 /// <summary>Gets all option values (value attributes) for selected options in the specified select or multi-select element.917 /// </summary>918 /// <param name="selectLocator">an <a href="#locators">element locator</a> identifying a drop-down menu</param>919 /// <returns>an array of all selected option values in the specified select drop-down</returns>920 public String[] GetSelectedValues(String selectLocator)921 {922 return commandProcessor.GetStringArray("getSelectedValues", new String[] {selectLocator,});923 }924 /// <summary>Gets option value (value attribute) for selected option in the specified select element.925 /// </summary>926 /// <param name="selectLocator">an <a href="#locators">element locator</a> identifying a drop-down menu</param>927 /// <returns>the selected option value in the specified select drop-down</returns>928 public String GetSelectedValue(String selectLocator)929 {930 return commandProcessor.GetString("getSelectedValue", new String[] {selectLocator,});931 }932 /// <summary>Gets all option indexes (option number, starting at 0) for selected options in the specified select or multi-select element.933 /// </summary>934 /// <param name="selectLocator">an <a href="#locators">element locator</a> identifying a drop-down menu</param>935 /// <returns>an array of all selected option indexes in the specified select drop-down</returns>936 public String[] GetSelectedIndexes(String selectLocator)937 {938 return commandProcessor.GetStringArray("getSelectedIndexes", new String[] {selectLocator,});939 }940 /// <summary>Gets option index (option number, starting at 0) for selected option in the specified select element.941 /// </summary>942 /// <param name="selectLocator">an <a href="#locators">element locator</a> identifying a drop-down menu</param>943 /// <returns>the selected option index in the specified select drop-down</returns>944 public String GetSelectedIndex(String selectLocator)945 {946 return commandProcessor.GetString("getSelectedIndex", new String[] {selectLocator,});947 }948 /// <summary>Gets all option element IDs for selected options in the specified select or multi-select element.949 /// </summary>950 /// <param name="selectLocator">an <a href="#locators">element locator</a> identifying a drop-down menu</param>951 /// <returns>an array of all selected option IDs in the specified select drop-down</returns>952 public String[] GetSelectedIds(String selectLocator)953 {954 return commandProcessor.GetStringArray("getSelectedIds", new String[] {selectLocator,});955 }956 /// <summary>Gets option element ID for selected option in the specified select element.957 /// </summary>958 /// <param name="selectLocator">an <a href="#locators">element locator</a> identifying a drop-down menu</param>959 /// <returns>the selected option ID in the specified select drop-down</returns>960 public String GetSelectedId(String selectLocator)961 {962 return commandProcessor.GetString("getSelectedId", new String[] {selectLocator,});963 }964 /// <summary>Determines whether some option in a drop-down menu is selected.965 /// </summary>966 /// <param name="selectLocator">an <a href="#locators">element locator</a> identifying a drop-down menu</param>967 /// <returns>true if some option has been selected, false otherwise</returns>968 public bool IsSomethingSelected(String selectLocator)969 {970 return commandProcessor.GetBoolean("isSomethingSelected", new String[] {selectLocator,});971 }972 /// <summary>Gets all option labels in the specified select drop-down.973 /// </summary>974 /// <param name="selectLocator">an <a href="#locators">element locator</a> identifying a drop-down menu</param>975 /// <returns>an array of all option labels in the specified select drop-down</returns>976 public String[] GetSelectOptions(String selectLocator)977 {978 return commandProcessor.GetStringArray("getSelectOptions", new String[] {selectLocator,});979 }980 /// <summary>Gets the value of an element attribute. The value of the attribute may981 /// differ across browsers (this is the case for the "style" attribute, for982 /// example).983 /// </summary>984 /// <param name="attributeLocator">an element locator followed by an @ sign and then the name of the attribute, e.g. "foo@bar"</param>985 /// <returns>the value of the specified attribute</returns>986 public String GetAttribute(String attributeLocator)987 {988 return commandProcessor.GetString("getAttribute", new String[] {attributeLocator,});989 }990 /// <summary>Verifies that the specified text pattern appears somewhere on the rendered page shown to the user.991 /// </summary>992 /// <param name="pattern">a <a href="#patterns">pattern</a> to match with the text of the page</param>993 /// <returns>true if the pattern matches the text, false otherwise</returns>994 public bool IsTextPresent(String pattern)995 {996 return commandProcessor.GetBoolean("isTextPresent", new String[] {pattern,});997 }998 /// <summary>Verifies that the specified element is somewhere on the page.999 /// </summary>1000 /// <param name="locator">an <a href="#locators">element locator</a></param>1001 /// <returns>true if the element is present, false otherwise</returns>1002 public bool IsElementPresent(String locator)1003 {1004 return commandProcessor.GetBoolean("isElementPresent", new String[] {locator,});1005 }1006 /// <summary>Determines if the specified element is visible. An1007 /// element can be rendered invisible by setting the CSS "visibility"1008 /// property to "hidden", or the "display" property to "none", either for the1009 /// element itself or one if its ancestors. This method will fail if1010 /// the element is not present.1011 /// </summary>1012 /// <param name="locator">an <a href="#locators">element locator</a></param>1013 /// <returns>true if the specified element is visible, false otherwise</returns>1014 public bool IsVisible(String locator)1015 {1016 return commandProcessor.GetBoolean("isVisible", new String[] {locator,});1017 }1018 /// <summary>Determines whether the specified input element is editable, ie hasn't been disabled.1019 /// This method will fail if the specified element isn't an input element.1020 /// </summary>1021 /// <param name="locator">an <a href="#locators">element locator</a></param>1022 /// <returns>true if the input element is editable, false otherwise</returns>1023 public bool IsEditable(String locator)1024 {1025 return commandProcessor.GetBoolean("isEditable", new String[] {locator,});1026 }1027 /// <summary>Returns the IDs of all buttons on the page.1028 /// 1029 /// <p>If a given button has no ID, it will appear as "" in this array.</p>1030 /// </summary>1031 /// <returns>the IDs of all buttons on the page</returns>1032 public String[] GetAllButtons()1033 {1034 return commandProcessor.GetStringArray("getAllButtons", new String[] {});1035 }1036 /// <summary>Returns the IDs of all links on the page.1037 /// 1038 /// <p>If a given link has no ID, it will appear as "" in this array.</p>1039 /// </summary>1040 /// <returns>the IDs of all links on the page</returns>1041 public String[] GetAllLinks()1042 {1043 return commandProcessor.GetStringArray("getAllLinks", new String[] {});1044 }1045 /// <summary>Returns the IDs of all input fields on the page.1046 /// 1047 /// <p>If a given field has no ID, it will appear as "" in this array.</p>1048 /// </summary>1049 /// <returns>the IDs of all field on the page</returns>1050 public String[] GetAllFields()1051 {1052 return commandProcessor.GetStringArray("getAllFields", new String[] {});1053 }1054 /// <summary>Returns an array of JavaScript property values from all known windows having one.1055 /// </summary>1056 /// <param name="attributeName">name of an attribute on the windows</param>1057 /// <returns>the set of values of this attribute from all known windows.</returns>1058 public String[] GetAttributeFromAllWindows(String attributeName)1059 {1060 return commandProcessor.GetStringArray("getAttributeFromAllWindows", new String[] {attributeName,});1061 }1062 /// <summary>deprecated - use dragAndDrop instead1063 /// </summary>1064 /// <param name="locator">an element locator</param>1065 /// <param name="movementsString">offset in pixels from the current location to which the element should be moved, e.g., "+70,-300"</param>1066 public void Dragdrop(String locator,String movementsString)1067 {1068 commandProcessor.DoCommand("dragdrop", new String[] {locator,movementsString,});1069 }1070 /// <summary>Configure the number of pixels between "mousemove" events during dragAndDrop commands (default=10).1071 /// <p>Setting this value to 0 means that we'll send a "mousemove" event to every single pixel1072 /// in between the start location and the end location; that can be very slow, and may1073 /// 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'll1074 /// just send one "mousemove" at the start location and then one final one at the end location.</p>1075 /// </summary>1076 /// <param name="pixels">the number of pixels between "mousemove" events</param>1077 public void SetMouseSpeed(String pixels)1078 {1079 commandProcessor.DoCommand("setMouseSpeed", new String[] {pixels,});1080 }1081 /// <summary>Returns the number of pixels between "mousemove" events during dragAndDrop commands (default=10).1082 /// </summary>1083 /// <returns>the number of pixels between "mousemove" events during dragAndDrop commands (default=10)</returns>1084 public Decimal GetMouseSpeed()1085 {1086 return commandProcessor.GetNumber("getMouseSpeed", new String[] {});1087 }1088 /// <summary>Drags an element a certain distance and then drops it1089 /// </summary>1090 /// <param name="locator">an element locator</param>1091 /// <param name="movementsString">offset in pixels from the current location to which the element should be moved, e.g., "+70,-300"</param>1092 public void DragAndDrop(String locator,String movementsString)1093 {1094 commandProcessor.DoCommand("dragAndDrop", new String[] {locator,movementsString,});1095 }1096 /// <summary>Drags an element and drops it on another element1097 /// </summary>1098 /// <param name="locatorOfObjectToBeDragged">an element to be dragged</param>1099 /// <param name="locatorOfDragDestinationObject">an element whose location (i.e., whose center-most pixel) will be the point where locatorOfObjectToBeDragged is dropped</param>1100 public void DragAndDropToObject(String locatorOfObjectToBeDragged,String locatorOfDragDestinationObject)1101 {1102 commandProcessor.DoCommand("dragAndDropToObject", new String[] {locatorOfObjectToBeDragged,locatorOfDragDestinationObject,});1103 }1104 /// <summary>Gives focus to the currently selected window1105 /// </summary>1106 public void WindowFocus()1107 {1108 commandProcessor.DoCommand("windowFocus", new String[] {});1109 }1110 /// <summary>Resize currently selected window to take up the entire screen1111 /// </summary>1112 public void WindowMaximize()1113 {1114 commandProcessor.DoCommand("windowMaximize", new String[] {});1115 }1116 /// <summary>Returns the IDs of all windows that the browser knows about in an array.1117 /// </summary>1118 /// <returns>Array of identifiers of all windows that the browser knows about.</returns>1119 public String[] GetAllWindowIds()1120 {1121 return commandProcessor.GetStringArray("getAllWindowIds", new String[] {});1122 }1123 /// <summary>Returns the names of all windows that the browser knows about in an array.1124 /// </summary>1125 /// <returns>Array of names of all windows that the browser knows about.</returns>1126 public String[] GetAllWindowNames()1127 {1128 return commandProcessor.GetStringArray("getAllWindowNames", new String[] {});1129 }1130 /// <summary>Returns the titles of all windows that the browser knows about in an array.1131 /// </summary>1132 /// <returns>Array of titles of all windows that the browser knows about.</returns>1133 public String[] GetAllWindowTitles()1134 {1135 return commandProcessor.GetStringArray("getAllWindowTitles", new String[] {});1136 }1137 /// <summary>Returns the entire HTML source between the opening and1138 /// closing "html" tags.1139 /// </summary>1140 /// <returns>the entire HTML source</returns>1141 public String GetHtmlSource()1142 {1143 return commandProcessor.GetString("getHtmlSource", new String[] {});1144 }1145 /// <summary>Moves the text cursor to the specified position in the given input element or textarea.1146 /// This method will fail if the specified element isn't an input element or textarea.1147 /// </summary>1148 /// <param name="locator">an <a href="#locators">element locator</a> pointing to an input element or textarea</param>1149 /// <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>1150 public void SetCursorPosition(String locator,String position)1151 {1152 commandProcessor.DoCommand("setCursorPosition", new String[] {locator,position,});1153 }1154 /// <summary>Get the relative index of an element to its parent (starting from 0). The comment node and empty text node1155 /// will be ignored.1156 /// </summary>1157 /// <param name="locator">an <a href="#locators">element locator</a> pointing to an element</param>1158 /// <returns>of relative index of the element to its parent (starting from 0)</returns>1159 public Decimal GetElementIndex(String locator)1160 {1161 return commandProcessor.GetNumber("getElementIndex", new String[] {locator,});1162 }1163 /// <summary>Check if these two elements have same parent and are ordered siblings in the DOM. Two same elements will1164 /// not be considered ordered.1165 /// </summary>1166 /// <param name="locator1">an <a href="#locators">element locator</a> pointing to the first element</param>1167 /// <param name="locator2">an <a href="#locators">element locator</a> pointing to the second element</param>1168 /// <returns>true if element1 is the previous sibling of element2, false otherwise</returns>1169 public bool IsOrdered(String locator1,String locator2)1170 {1171 return commandProcessor.GetBoolean("isOrdered", new String[] {locator1,locator2,});1172 }1173 /// <summary>Retrieves the horizontal position of an element1174 /// </summary>1175 /// <param name="locator">an <a href="#locators">element locator</a> pointing to an element OR an element itself</param>1176 /// <returns>of pixels from the edge of the frame.</returns>1177 public Decimal GetElementPositionLeft(String locator)1178 {1179 return commandProcessor.GetNumber("getElementPositionLeft", new String[] {locator,});1180 }1181 /// <summary>Retrieves the vertical position of an element1182 /// </summary>1183 /// <param name="locator">an <a href="#locators">element locator</a> pointing to an element OR an element itself</param>1184 /// <returns>of pixels from the edge of the frame.</returns>1185 public Decimal GetElementPositionTop(String locator)1186 {1187 return commandProcessor.GetNumber("getElementPositionTop", new String[] {locator,});1188 }1189 /// <summary>Retrieves the width of an element1190 /// </summary>1191 /// <param name="locator">an <a href="#locators">element locator</a> pointing to an element</param>1192 /// <returns>width of an element in pixels</returns>1193 public Decimal GetElementWidth(String locator)1194 {1195 return commandProcessor.GetNumber("getElementWidth", new String[] {locator,});1196 }1197 /// <summary>Retrieves the height of an element1198 /// </summary>1199 /// <param name="locator">an <a href="#locators">element locator</a> pointing to an element</param>1200 /// <returns>height of an element in pixels</returns>1201 public Decimal GetElementHeight(String locator)1202 {1203 return commandProcessor.GetNumber("getElementHeight", new String[] {locator,});1204 }1205 /// <summary>Retrieves the text cursor position in the given input element or textarea; beware, this may not work perfectly on all browsers.1206 /// 1207 /// <p>Specifically, if the cursor/selection has been cleared by JavaScript, this command will tend to1208 /// 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>1209 /// This method will fail if the specified element isn't an input element or textarea, or there is no cursor in the element.1210 /// </summary>1211 /// <param name="locator">an <a href="#locators">element locator</a> pointing to an input element or textarea</param>1212 /// <returns>the numerical position of the cursor in the field</returns>1213 public Decimal GetCursorPosition(String locator)1214 {1215 return commandProcessor.GetNumber("getCursorPosition", new String[] {locator,});1216 }1217 /// <summary>Returns the specified expression.1218 /// 1219 /// <p>This is useful because of JavaScript preprocessing.1220 /// It is used to generate commands like assertExpression and waitForExpression.</p>1221 /// </summary>1222 /// <param name="expression">the value to return</param>1223 /// <returns>the value passed in</returns>1224 public String GetExpression(String expression)1225 {1226 return commandProcessor.GetString("getExpression", new String[] {expression,});1227 }1228 /// <summary>Returns the number of nodes that match the specified xpath, eg. "//table" would give1229 /// the number of tables.1230 /// </summary>1231 /// <param name="xpath">the xpath expression to evaluate. do NOT wrap this expression in a 'count()' function; we will do that for you.</param>1232 /// <returns>the number of nodes that match the specified xpath</returns>1233 public Decimal GetXpathCount(String xpath)1234 {1235 return commandProcessor.GetNumber("getXpathCount", new String[] {xpath,});1236 }1237 /// <summary>Temporarily sets the "id" attribute of the specified element, so you can locate it in the future1238 /// using its ID rather than a slow/complicated XPath. This ID will disappear once the page is1239 /// reloaded.1240 /// </summary>1241 /// <param name="locator">an <a href="#locators">element locator</a> pointing to an element</param>1242 /// <param name="identifier">a string to be used as the ID of the specified element</param>1243 public void AssignId(String locator,String identifier)1244 {1245 commandProcessor.DoCommand("assignId", new String[] {locator,identifier,});1246 }1247 /// <summary>Specifies whether Selenium should use the native in-browser implementation1248 /// of XPath (if any native version is available); if you pass "false" to1249 /// this function, we will always use our pure-JavaScript xpath library.1250 /// Using the pure-JS xpath library can improve the consistency of xpath1251 /// element locators between different browser vendors, but the pure-JS1252 /// version is much slower than the native implementations.1253 /// </summary>1254 /// <param name="allow">boolean, true means we'll prefer to use native XPath; false means we'll only use JS XPath</param>1255 public void AllowNativeXpath(String allow)1256 {1257 commandProcessor.DoCommand("allowNativeXpath", new String[] {allow,});1258 }1259 /// <summary>Specifies whether Selenium will ignore xpath attributes that have no1260 /// value, i.e. are the empty string, when using the non-native xpath1261 /// evaluation engine. You'd want to do this for performance reasons in IE.1262 /// However, this could break certain xpaths, for example an xpath that looks1263 /// for an attribute whose value is NOT the empty string.1264 /// 1265 /// The hope is that such xpaths are relatively rare, but the user should1266 /// have the option of using them. Note that this only influences xpath1267 /// evaluation when using the ajaxslt engine (i.e. not "javascript-xpath").1268 /// </summary>1269 /// <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>1270 public void IgnoreAttributesWithoutValue(String ignore)1271 {1272 commandProcessor.DoCommand("ignoreAttributesWithoutValue", new String[] {ignore,});1273 }1274 /// <summary>Runs the specified JavaScript snippet repeatedly until it evaluates to "true".1275 /// The snippet may have multiple lines, but only the result of the last line1276 /// will be considered.1277 /// 1278 /// <p>Note that, by default, the snippet will be run in the runner's test window, not in the window1279 /// of your application. To get the window of your application, you can use1280 /// the JavaScript snippet <code>selenium.browserbot.getCurrentWindow()</code>, and then1281 /// run your JavaScript in there</p>1282 /// </summary>1283 /// <param name="script">the JavaScript snippet to run</param>1284 /// <param name="timeout">a timeout in milliseconds, after which this command will return with an error</param>1285 public void WaitForCondition(String script,String timeout)1286 {1287 commandProcessor.DoCommand("waitForCondition", new String[] {script,timeout,});1288 }1289 /// <summary>Specifies the amount of time that Selenium will wait for actions to complete.1290 /// 1291 /// <p>Actions that require waiting include "open" and the "waitFor*" actions.</p>1292 /// The default timeout is 30 seconds.1293 /// </summary>1294 /// <param name="timeout">a timeout in milliseconds, after which the action will return with an error</param>1295 public void SetTimeout(String timeout)1296 {1297 commandProcessor.DoCommand("setTimeout", new String[] {timeout,});1298 }1299 /// <summary>Waits for a new page to load.1300 /// 1301 /// <p>You can use this command instead of the "AndWait" suffixes, "clickAndWait", "selectAndWait", "typeAndWait" etc.1302 /// (which are only available in the JS API).</p><p>Selenium constantly keeps track of new pages loading, and sets a "newPageLoaded"1303 /// flag when it first notices a page load. Running any other Selenium command after1304 /// turns the flag to false. Hence, if you want to wait for a page to load, you must1305 /// wait immediately after a Selenium command that caused a page-load.</p>1306 /// </summary>1307 /// <param name="timeout">a timeout in milliseconds, after which this command will return with an error</param>1308 public void WaitForPageToLoad(String timeout)1309 {1310 commandProcessor.DoCommand("waitForPageToLoad", new String[] {timeout,});1311 }1312 /// <summary>Waits for a new frame to load.1313 /// 1314 /// <p>Selenium constantly keeps track of new pages and frames loading, 1315 /// and sets a "newPageLoaded" flag when it first notices a page load.</p>1316 /// 1317 /// See waitForPageToLoad for more information.1318 /// </summary>1319 /// <param name="frameAddress">FrameAddress from the server side</param>1320 /// <param name="timeout">a timeout in milliseconds, after which this command will return with an error</param>1321 public void WaitForFrameToLoad(String frameAddress,String timeout)1322 {1323 commandProcessor.DoCommand("waitForFrameToLoad", new String[] {frameAddress,timeout,});1324 }1325 /// <summary>Return all cookies of the current page under test.1326 /// </summary>1327 /// <returns>all cookies of the current page under test</returns>1328 public String GetCookie()1329 {1330 return commandProcessor.GetString("getCookie", new String[] {});1331 }1332 /// <summary>Returns the value of the cookie with the specified name, or throws an error if the cookie is not present.1333 /// </summary>1334 /// <param name="name">the name of the cookie</param>1335 /// <returns>the value of the cookie</returns>1336 public String GetCookieByName(String name)1337 {1338 return commandProcessor.GetString("getCookieByName", new String[] {name,});1339 }1340 /// <summary>Returns true if a cookie with the specified name is present, or false otherwise.1341 /// </summary>1342 /// <param name="name">the name of the cookie</param>1343 /// <returns>true if a cookie with the specified name is present, or false otherwise.</returns>1344 public bool IsCookiePresent(String name)1345 {1346 return commandProcessor.GetBoolean("isCookiePresent", new String[] {name,});1347 }1348 /// <summary>Create a new cookie whose path and domain are same with those of current page1349 /// under test, unless you specified a path for this cookie explicitly.1350 /// </summary>1351 /// <param name="nameValuePair">name and value of the cookie in a format "name=value"</param>1352 /// <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>1353 public void CreateCookie(String nameValuePair,String optionsString)1354 {1355 commandProcessor.DoCommand("createCookie", new String[] {nameValuePair,optionsString,});1356 }1357 /// <summary>Delete a named cookie with specified path and domain. Be careful; to delete a cookie, you1358 /// need to delete it using the exact same path and domain that were used to create the cookie.1359 /// If the path is wrong, or the domain is wrong, the cookie simply won't be deleted. Also1360 /// note that specifying a domain that isn't a subset of the current domain will usually fail.1361 /// 1362 /// Since there's no way to discover at runtime the original path and domain of a given cookie,1363 /// we've added an option called 'recurse' to try all sub-domains of the current domain with1364 /// all paths that are a subset of the current path. Beware; this option can be slow. In1365 /// big-O notation, it operates in O(n*m) time, where n is the number of dots in the domain1366 /// name and m is the number of slashes in the path.1367 /// </summary>1368 /// <param name="name">the name of the cookie to be deleted</param>1369 /// <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>1370 public void DeleteCookie(String name,String optionsString)1371 {1372 commandProcessor.DoCommand("deleteCookie", new String[] {name,optionsString,});1373 }1374 /// <summary>Calls deleteCookie with recurse=true on all cookies visible to the current page.1375 /// As noted on the documentation for deleteCookie, recurse=true can be much slower1376 /// than simply deleting the cookies using a known domain/path.1377 /// </summary>1378 public void DeleteAllVisibleCookies()1379 {1380 commandProcessor.DoCommand("deleteAllVisibleCookies", new String[] {});1381 }1382 /// <summary>Sets the threshold for browser-side logging messages; log messages beneath this threshold will be discarded.1383 /// Valid logLevel strings are: "debug", "info", "warn", "error" or "off".1384 /// To see the browser logs, you need to1385 /// either show the log window in GUI mode, or enable browser-side logging in Selenium RC.1386 /// </summary>1387 /// <param name="logLevel">one of the following: "debug", "info", "warn", "error" or "off"</param>1388 public void SetBrowserLogLevel(String logLevel)1389 {1390 commandProcessor.DoCommand("setBrowserLogLevel", new String[] {logLevel,});1391 }1392 /// <summary>Creates a new "script" tag in the body of the current test window, and 1393 /// adds the specified text into the body of the command. Scripts run in1394 /// this way can often be debugged more easily than scripts executed using1395 /// Selenium's "getEval" command. Beware that JS exceptions thrown in these script1396 /// tags aren't managed by Selenium, so you should probably wrap your script1397 /// in try/catch blocks if there is any chance that the script will throw1398 /// an exception.1399 /// </summary>1400 /// <param name="script">the JavaScript snippet to run</param>1401 public void RunScript(String script)1402 {1403 commandProcessor.DoCommand("runScript", new String[] {script,});1404 }1405 /// <summary>Defines a new function for Selenium to locate elements on the page.1406 /// For example,1407 /// if you define the strategy "foo", and someone runs click("foo=blah"), we'll1408 /// run your function, passing you the string "blah", and click on the element 1409 /// that your function1410 /// returns, or throw an "Element not found" error if your function returns null.1411 /// 1412 /// We'll pass three arguments to your function:1413 /// <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>1414 /// The function must return null if the element can't be found.1415 /// </summary>1416 /// <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>1417 /// <param name="functionDefinition">a string defining the body of a function in JavaScript. For example: <code>return inDocument.getElementById(locator);</code></param>1418 public void AddLocationStrategy(String strategyName,String functionDefinition)1419 {1420 commandProcessor.DoCommand("addLocationStrategy", new String[] {strategyName,functionDefinition,});1421 }1422 /// <summary>Saves the entire contents of the current window canvas to a PNG file.1423 /// Contrast this with the captureScreenshot command, which captures the1424 /// contents of the OS viewport (i.e. whatever is currently being displayed1425 /// on the monitor), and is implemented in the RC only. Currently this only1426 /// works in Firefox when running in chrome mode, and in IE non-HTA using1427 /// the EXPERIMENTAL "Snapsie" utility. The Firefox implementation is mostly1428 /// borrowed from the Screengrab! Firefox extension. Please see1429 /// http://www.screengrab.org and http://snapsie.sourceforge.net/ for1430 /// details.1431 /// </summary>1432 /// <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>1433 /// <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>1434 public void CaptureEntirePageScreenshot(String filename,String kwargs)1435 {1436 commandProcessor.DoCommand("captureEntirePageScreenshot", new String[] {filename,kwargs,});1437 }1438 /// <summary>Executes a command rollup, which is a series of commands with a unique1439 /// name, and optionally arguments that control the generation of the set of1440 /// commands. If any one of the rolled-up commands fails, the rollup is1441 /// considered to have failed. Rollups may also contain nested rollups.1442 /// </summary>1443 /// <param name="rollupName">the name of the rollup command</param>1444 /// <param name="kwargs">keyword arguments string that influences how the rollup expands into commands</param>1445 public void Rollup(String rollupName,String kwargs)1446 {1447 commandProcessor.DoCommand("rollup", new String[] {rollupName,kwargs,});1448 }1449 /// <summary>Loads script content into a new script tag in the Selenium document. This1450 /// differs from the runScript command in that runScript adds the script tag1451 /// to the document of the AUT, not the Selenium document. The following1452 /// entities in the script content are replaced by the characters they1453 /// represent:1454 /// 1455 /// &lt;1456 /// &gt;1457 /// &amp;1458 /// 1459 /// The corresponding remove command is removeScript.1460 /// </summary>1461 /// <param name="scriptContent">the Javascript content of the script to add</param>1462 /// <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>1463 public void AddScript(String scriptContent,String scriptTagId)1464 {1465 commandProcessor.DoCommand("addScript", new String[] {scriptContent,scriptTagId,});1466 }1467 /// <summary>Removes a script tag from the Selenium document identified by the given1468 /// id. Does nothing if the referenced tag doesn't exist.1469 /// </summary>1470 /// <param name="scriptTagId">the id of the script element to remove.</param>1471 public void RemoveScript(String scriptTagId)1472 {1473 commandProcessor.DoCommand("removeScript", new String[] {scriptTagId,});1474 }1475 /// <summary>Allows choice of one of the available libraries.1476 /// </summary>1477 /// <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>1478 public void UseXpathLibrary(String libraryName)1479 {1480 commandProcessor.DoCommand("useXpathLibrary", new String[] {libraryName,});1481 }1482 /// <summary>Writes a message to the status bar and adds a note to the browser-side1483 /// log.1484 /// </summary>1485 /// <param name="context">the message to be sent to the browser</param>1486 public void SetContext(String context)1487 {1488 commandProcessor.DoCommand("setContext", new String[] {context,});1489 }1490 /// <summary>Sets a file input (upload) field to the file listed in fileLocator1491 /// </summary>1492 /// <param name="fieldLocator">an <a href="#locators">element locator</a></param>1493 /// <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>1494 public void AttachFile(String fieldLocator,String fileLocator)1495 {1496 commandProcessor.DoCommand("attachFile", new String[] {fieldLocator,fileLocator,});1497 }1498 /// <summary>Captures a PNG screenshot to the specified file.1499 /// </summary>1500 /// <param name="filename">the absolute path to the file to be written, e.g. "c:\blah\screenshot.png"</param>1501 public void CaptureScreenshot(String filename)1502 {1503 commandProcessor.DoCommand("captureScreenshot", new String[] {filename,});1504 }1505 /// <summary>Capture a PNG screenshot. It then returns the file as a base 64 encoded string.1506 /// </summary>1507 /// <returns>The base 64 encoded string of the screen shot (PNG file)</returns>1508 public String CaptureScreenshotToString()1509 {1510 return commandProcessor.GetString("captureScreenshotToString", new String[] {});1511 }1512 1513 /// <summary>1514 /// Captures the Network Traffic that is passing through Selenium Server1515 /// </summary>1516 /// <param name="type"></param>1517 /// <returns></returns>1518 public string CaptureNetworkTraffic(string type)1519 {1520 return commandProcessor.GetString("captureNetworkTraffic", new string[] {type});1521 }1522 /// <summary>Downloads a screenshot of the browser current window canvas to a 1523 /// based 64 encoded PNG file. The <em>entire</em> windows canvas is captured,1524 /// including parts rendered outside of the current view port.1525 /// 1526 /// Currently this only works in Mozilla and when running in chrome mode.1527 /// </summary>1528 /// <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>1529 /// <returns>The base 64 encoded string of the page screenshot (PNG file)</returns>1530 public String CaptureEntirePageScreenshotToString(String kwargs)1531 {1532 return commandProcessor.GetString("captureEntirePageScreenshotToString", new String[] {kwargs,});1533 }1534 /// <summary>Kills the running Selenium Server and all browser sessions. After you run this command, you will no longer be able to send1535 /// commands to the server; you can't remotely start the server once it has been stopped. Normally1536 /// you should prefer to run the "stop" command, which terminates the current browser session, rather than 1537 /// shutting down the entire server.1538 /// </summary>1539 public void ShutDownSeleniumServer()1540 {1541 commandProcessor.DoCommand("shutDownSeleniumServer", new String[] {});1542 }1543 /// <summary>Retrieve the last messages logged on a specific remote control. Useful for error reports, especially1544 /// when running multiple remote controls in a distributed environment. The maximum number of log messages1545 /// that can be retrieve is configured on remote control startup.1546 /// </summary>1547 /// <returns>The last N log messages as a multi-line string.</returns>1548 public String RetrieveLastRemoteControlLogs()1549 {1550 return commandProcessor.GetString("retrieveLastRemoteControlLogs", new String[] {});1551 }1552 /// <summary>Simulates a user pressing a key (without releasing it yet) by sending a native operating system keystroke.1553 /// This function uses the java.awt.Robot class to send a keystroke; this more accurately simulates typing1554 /// a key on the keyboard. It does not honor settings from the shiftKeyDown, controlKeyDown, altKeyDown and1555 /// metaKeyDown commands, and does not target any particular HTML element. To send a keystroke to a particular1556 /// element, focus on the element first before running this command.1557 /// </summary>1558 /// <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>1559 public void KeyDownNative(String keycode)1560 {1561 commandProcessor.DoCommand("keyDownNative", new String[] {keycode,});1562 }1563 /// <summary>Simulates a user releasing a key by sending a native operating system keystroke.1564 /// This function uses the java.awt.Robot class to send a keystroke; this more accurately simulates typing1565 /// a key on the keyboard. It does not honor settings from the shiftKeyDown, controlKeyDown, altKeyDown and1566 /// metaKeyDown commands, and does not target any particular HTML element. To send a keystroke to a particular1567 /// element, focus on the element first before running this command.1568 /// </summary>1569 /// <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>1570 public void KeyUpNative(String keycode)1571 {1572 commandProcessor.DoCommand("keyUpNative", new String[] {keycode,});1573 }1574 /// <summary>Simulates a user pressing and releasing a key by sending a native operating system keystroke.1575 /// This function uses the java.awt.Robot class to send a keystroke; this more accurately simulates typing1576 /// a key on the keyboard. It does not honor settings from the shiftKeyDown, controlKeyDown, altKeyDown and1577 /// metaKeyDown commands, and does not target any particular HTML element. To send a keystroke to a particular1578 /// element, focus on the element first before running this command.1579 /// </summary>1580 /// <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>1581 public void KeyPressNative(String keycode)1582 {1583 commandProcessor.DoCommand("keyPressNative", new String[] {keycode,});1584 }1585 }1586}1587 ...

Full Screen

Full Screen

Program.cs

Source:Program.cs Github

copy

Full Screen

2using System.Threading.Tasks;3using PuppeteerSharp;4namespace Example.GetAllLinks5{6 class Program7 {8 public static async Task Main(string[] args)9 {10 var options = new LaunchOptions { Headless = true };11 Console.WriteLine("Downloading chromium");12 await new BrowserFetcher().DownloadAsync(BrowserFetcher.DefaultRevision);13 Console.WriteLine("Navigating to google.com");14 using (var browser = await Puppeteer.LaunchAsync(options))15 using (var page = await browser.NewPageAsync())16 {17 await page.GoToAsync("http://www.google.com");18 var jsSelectAllAnchors = @"Array.from(document.querySelectorAll('a')).map(a => a.href);";19 var urls = await page.EvaluateExpressionAsync<string[]>(jsSelectAllAnchors);20 foreach (string url in urls)...

Full Screen

Full Screen

Program

Using AI Code Generation

copy

Full Screen

1using Example.GetAllLinks;2using System;3using System.Collections.Generic;4using System.Linq;5using System.Text;6using System.Threading.Tasks;7{8 {9 static void Main(string[] args)10 {11 Console.WriteLine("Hello World!");12 Console.ReadKey();13 }14 }15}16using Example.GetAllLinks;17using System;18using System.Collections.Generic;19using System.Linq;20using System.Text;21using System.Threading.Tasks;22{23 {24 static void Main(string[] args)25 {26 Console.WriteLine("Hello World!");27 Console.ReadKey();28 }29 }30}

Full Screen

Full Screen

Program

Using AI Code Generation

copy

Full Screen

1using Example.GetAllLinks;2{3 static void Main(string[] args)4 {5 Program obj = new Program();6 obj.GetAllLinks();7 }8}9using Example.GetAllLinks;10{11 static void Main(string[] args)12 {13 Program obj = new Program();14 obj.GetAllLinks();15 }16}17using Example.GetAllLinks;18{19 static void Main(string[] args)20 {21 Program obj = new Program();22 obj.GetAllLinks();23 }24}25using Example.GetAllLinks;26{27 static void Main(string[] args)28 {29 Program obj = new Program();30 obj.GetAllLinks();31 }32}33using Example.GetAllLinks;34{35 static void Main(string[] args)36 {37 Program obj = new Program();38 obj.GetAllLinks();39 }40}41using Example.GetAllLinks;42{43 static void Main(string[] args)44 {45 Program obj = new Program();46 obj.GetAllLinks();47 }48}49using Example.GetAllLinks;50{51 static void Main(string[] args)52 {53 Program obj = new Program();54 obj.GetAllLinks();55 }56}57using Example.GetAllLinks;58{59 static void Main(string[] args)60 {61 Program obj = new Program();62 obj.GetAllLinks();63 }64}65using Example.GetAllLinks;66{67 static void Main(string[] args)68 {69 Program obj = new Program();70 obj.GetAllLinks();71 }72}73using Example.GetAllLinks;74{75 static void Main(string[] args)76 {

Full Screen

Full Screen

Program

Using AI Code Generation

copy

Full Screen

1using Example.GetAllLinks;2{3 static void Main(string[] args)4 {5 Program p = new Program();6 p.GetAllLinks();7 }8 public void GetAllLinks()9 {10 GetAllLinks obj = new GetAllLinks();11 }12}13using System;14using System.Net;15using System.Text.RegularExpressions;16{17 {18 public void GetAllLinksFromURL(string url)19 {20 using (WebClient client = new WebClient())21 {22 string htmlCode = client.DownloadString(url);23 MatchCollection matches = Regex.Matches(htmlCode, @"<a.*?href=[""'](?<href>.*?)[""'].*?>(?<text>.*?)</a>");24 foreach (Match match in matches)25 {26 Console.WriteLine("Link Text: " + match.Groups["text"].Value);27 Console.WriteLine("Link URL: " + match.Groups["href"].Value);28 }29 }30 }31 public void GetAllLinksFromHTML(string html)32 {33 MatchCollection matches = Regex.Matches(html, @"<a.*?href=[""'](?<href>.*?)[""'].*?>(?<text>.*?)</a>");34 foreach (Match match in matches)35 {36 Console.WriteLine("Link Text: " + match.Groups["text"].Value);37 Console.WriteLine("Link URL: " + match.Groups["href"].Value);38 }39 }40 }41}

Full Screen

Full Screen

Program

Using AI Code Generation

copy

Full Screen

1using Example.GetAllLinks;2{3 public static void Main()4 {5 Program p = new Program();6 p.GetAllLinks();7 }8 public void GetAllLinks()9 {10 GetAllLinks getAllLinks = new GetAllLinks();11 getAllLinks.GetAllLinks();12 }13}

Full Screen

Full Screen

Program

Using AI Code Generation

copy

Full Screen

1using System;2using Example.GetAllLinks;3{4 {5 public static void Main(string[] args)6 {7 Program p = new Program();8 p.GetLinks();9 Console.Read();10 }11 }12}13using System;14using Example.GetAllLinks;15{16 {17 public void GetLinks()18 {19 Console.WriteLine("Get Links");20 }21 }22}23using Example.GetAllLinks;24{25 {26 public static void Main(string[] args)27 {28 Example.GetAllLinks.Program p = new Example.GetAllLinks.Program();29 p.GetLinks();30 Console.Read();31 }32 }33}34using GetAllLinks = Example.GetAllLinks;35{36 {37 public static void Main(string[]

Full Screen

Full Screen

Program

Using AI Code Generation

copy

Full Screen

1using Example.GetAllLinks;2{3 static void Main()4 {5 Program p = new Program();6 p.Main();7 }8}

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Puppeteer-sharp automation tests on LambdaTest cloud grid

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

Most used methods in Program

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful