<html xmlns:MSHelp="http://msdn.microsoft.com/mshelp" xmlns:mshelp="http://msdn.microsoft.com/mshelp" xmlns:ddue="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:msxsl="urn:schemas-microsoft-com:xslt"><head><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8" /><META NAME="save" CONTENT="history" /><title>Selenium Namespace</title><meta name="Language" content="en-us" /><meta name="System.Keywords" content="Selenium namespace" /><meta name="Microsoft.Help.F1" content="Selenium" /><meta name="Microsoft.Help.Id" content="N:Selenium" /><meta name="Description" content=" " /><meta name="Microsoft.Help.ContentType" content="Reference" /><link rel="stylesheet" type="text/css" href="../styles/Presentation.css" /><link rel="stylesheet" type="text/css" href="ms-help://Hx/HxRuntime/HxLink.css" /><script type="text/javascript" src="../scripts/EventUtilities.js"> </script><script type="text/javascript" src="../scripts/SplitScreen.js"> </script><script type="text/javascript" src="../scripts/Dropdown.js"> </script><script type="text/javascript" src="../scripts/script_manifold.js"> </script><script type="text/javascript" src="../scripts/script_feedBack.js"> </script><script type="text/javascript" src="../scripts/CheckboxMenu.js"> </script><script type="text/javascript" src="../scripts/CommonUtilities.js"> </script><meta name="container" content="Selenium" /><meta name="file" content="N_Selenium" /><meta name="guid" content="N_Selenium" /><xml><MSHelp:Attr Name="AssetID" Value="N:Selenium" /><MSHelp:TOCTitle Title="Selenium Namespace" /><MSHelp:RLTitle Title="Selenium Namespace ()" /><MSHelp:Keyword Index="A" Term="N:Selenium" /><MSHelp:Keyword Index="A" Term="frlrfSelenium" /><MSHelp:Keyword Index="K" Term="Selenium namespace" /><MSHelp:Keyword Index="F" Term="Selenium" /><MSHelp:Attr Name="HelpPriority" Value="1" /><MSHelp:Attr Name="DevLang" Value="CSharp" /><MSHelp:Attr Name="DevLang" Value="VB" /><MSHelp:Attr Name="Locale" Value="en-us" /><MSHelp:Attr Name="TopicType" Value="kbSyntax" /><MSHelp:Attr Name="TopicType" Value="apiref" /><MSHelp:Attr Name="Abstract" Value=" " /></xml></head><body><input type="hidden" id="userDataCache" class="userDataStyle" /><input type="hidden" id="hiddenScrollOffset" /><img id="collapseImage" style="display:none; height:0; width:0;" src="../icons/collapse_all.gif" alt="Collapse image" title="Collapse image" /><img id="expandImage" style="display:none; height:0; width:0;" src="../icons/expand_all.gif" alt="Expand Image" title="Expand Image" /><img id="collapseAllImage" style="display:none; height:0; width:0;" src="../icons/collapse_all.gif" /><img id="expandAllImage" style="display:none; height:0; width:0;" src="../icons/expand_all.gif" /><img id="dropDownImage" style="display:none; height:0; width:0;" src="../icons/dropdown.gif" /><img id="dropDownHoverImage" style="display:none; height:0; width:0;" src="../icons/dropdownHover.gif" /><img id="copyImage" style="display:none; height:0; width:0;" src="../icons/copycode.gif" alt="Copy image" title="Copy image" /><img id="copyHoverImage" style="display:none; height:0; width:0;" src="../icons/copycodeHighlight.gif" alt="CopyHover image" title="CopyHover image" /><div id="header"><table id="topTable" cellspacing="0" cellpadding="0"><tr><td><span onclick="ExpandCollapseAll(toggleAllImage)" style="cursor:default;" onkeypress="ExpandCollapseAll_CheckKey(toggleAllImage, event)" tabindex="0"><img ID="toggleAllImage" class="toggleAll" src="../icons/collapse_all.gif" /> <label id="collapseAllLabel" for="toggleAllImage" style="display: none;">Collapse All</label><label id="expandAllLabel" for="toggleAllImage" style="display: none;">Expand All</label> </span><span> </span><span id="devlangsDropdown" class="filter" tabindex="0"><img id="devlangsDropdownImage" src="../icons/dropdown.gif" /> <label id="devlangsMenuAllLabel" for="devlangsDropdownImage" style="display: none;"><nobr>Code: All </nobr></label><label id="devlangsMenuMultipleLabel" for="devlangsDropdownImage" style="display: none;"><nobr>Code: Multiple </nobr></label><label id="devlangsMenuCSharpLabel" for="devlangsDropdownImage" style="display: none;"><nobr>Code: C# </nobr></label><label id="devlangsMenuVisualBasicLabel" for="devlangsDropdownImage" style="display: none;"><nobr>Code: Visual Basic </nobr></label><label id="devlangsMenuManagedCPlusPlusLabel" for="devlangsDropdownImage" style="display: none;"><nobr>Code: Visual C++ </nobr></label></span></td></tr></table><div id="devlangsMenu"><input id="CSharpCheckbox" type="checkbox" data="CSharp,cs,'persist'" value="on" onClick="SetLanguage(this)" /><label class="checkboxLabel" for="CSharpCheckbox">C#</label><br /><input id="VisualBasicCheckbox" type="checkbox" data="VisualBasic,vb,'persist'" value="on" onClick="SetLanguage(this)" /><label class="checkboxLabel" for="VisualBasicCheckbox">Visual Basic</label><br /><input id="ManagedCPlusPlusCheckbox" type="checkbox" data="ManagedCPlusPlus,cpp,'persist'" value="on" onClick="SetLanguage(this)" /><label class="checkboxLabel" for="ManagedCPlusPlusCheckbox">Visual C++</label><br /></div><table id="bottomTable" cellpadding="0" cellspacing="0"><tr id="headerTableRow1"><td align="left"><span id="runningHeaderText">WebDriver</span></td></tr><tr id="headerTableRow2"><td align="left"><span id="nsrTitle">Selenium Namespace</span></td></tr><tr id="headerTableRow3"><td align="left"><span id="headfeedbackarea" class="feedbackhead"><a href="javascript:SubmitFeedback('webdriver@googlegroups.com','WebDriver','','','','%0\dYour%20feedback%20is%20used%20to%20improve%20the%20documentation%20and%20the%20product.%20Your%20e-mail%20address%20will%20not%20be%20used%20for%20any%20other%20purpose%20and%20is%20disposed%20of%20after%20the%20issue%20you%20report%20is%20resolved.%20%20While%20working%20to%20resolve%20the%20issue%20that%20you%20report,%20you%20may%20be%20contacted%20via%20e-mail%20to%20get%20further%20details%20or%20clarification%20on%20the%20feedback%20you%20sent.%20After%20the%20issue%20you%20report%20has%20been%20addressed,%20you%20may%20receive%20an%20e-mail%20to%20let%20you%20know%20that%20your%20feedback%20has%20been%20addressed.%0\A%0\d','Customer%20Feedback');">Send Feedback</a></span></td></tr></table><table id="gradientTable"><tr><td class="nsrBottom" background="../icons/gradient.gif" /></tr></table></div><div id="mainSection"><div id="mainBody"><div id="allHistory" class="saveHistory" onsave="saveAll()" onload="loadAll()" /><span style="color: DarkGray"></span><div class="summary"> </div><h1 class="heading"><span onclick="ExpandCollapse(classToggle)" style="cursor:default;" onkeypress="ExpandCollapse_CheckKey(classToggle, event)" tabindex="0"><img id="classToggle" class="toggle" name="toggleSwitch" src="../icons/collapse_all.gif" />Classes</span></h1><div id="classSection" class="section" name="collapseableSection" style=""><table id="typeList" class="members" frame="lhs" cellpadding="2"><col width="10%" /><tr><th class="iconColumn"> | |
</th><th class="nameColumn">Class</th><th class="descriptionColumn">Description</th></tr><tr data="class; public"><td><img src="../icons/pubclass.gif" alt="Public class" title="Public class" /></td><td><a href="T_Selenium_DefaultRemoteCommand.htm">DefaultRemoteCommand</a></td><td><div class="summary"> | |
A representation of a single remote Command | |
</div></td></tr><tr data="class; public"><td><img src="../icons/pubclass.gif" alt="Public class" title="Public class" /></td><td><a href="T_Selenium_DefaultSelenium.htm">DefaultSelenium</a></td><td><div class="summary">Defines an object that runs Selenium commands. | |
<h3><a name="locators" />Element Locators</h3><p> | |
Element Locators tell Selenium which HTML element a command refers to. | |
The format of a locator is:</p><blockquote><em>locatorType</em><strong>=</strong><em>argument</em></blockquote><p> | |
We support the following strategies for locating elements: | |
</p><ul><li><strong>identifier</strong>=<em>id</em>: | |
Select the element with the specified @id attribute. If no match is | |
found, select the first element whose @name attribute is <em>id</em>. | |
(This is normally the default; see below.)</li><li><strong>id</strong>=<em>id</em>: | |
Select the element with the specified @id attribute.</li><li><strong>name</strong>=<em>name</em>: | |
Select the first element with the specified @name attribute. | |
<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>: | |
Find an element by evaluating the specified string. This allows you to traverse the HTML Document Object | |
Model using JavaScript. Note that you must not return a value in this string; simply make it the last expression in the block. | |
<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>: | |
Locate an element using an XPath expression. | |
<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>: | |
Select the link (anchor) element which contains text matching the | |
specified <em>pattern</em>. | |
<ul class="first last simple"><li>link=The link text</li></ul></li><li><strong>css</strong>=<em>cssSelectorSyntax</em>: | |
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. | |
<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>: | |
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. | |
<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> | |
Without an explicit locator prefix, Selenium uses the following default | |
strategies: | |
</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> | |
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> | |
Selects a single element based on its position in the list (offset from zero).</blockquote></blockquote><h3><a name="patterns" />String-match Patterns</h3><p> | |
Various Pattern syntaxes are available for matching string values: | |
</p><ul><li><strong>glob:</strong><em>pattern</em>: | |
Match a string against a "glob" (aka "wildmat") pattern. "Glob" is a | |
kind of limited regular-expression syntax typically used in command-line | |
shells. In a glob pattern, "*" represents any sequence of characters, and "?" | |
represents any single character. Glob patterns match against the entire | |
string.</li><li><strong>regexp:</strong><em>regexp</em>: | |
Match a string using a regular-expression. The full power of JavaScript | |
regular-expressions is available.</li><li><strong>regexpi:</strong><em>regexpi</em>: | |
Match a string using a case-insensitive regular-expression.</li><li><strong>exact:</strong><em>string</em>: | |
Match a string exactly, verbatim, without any of that fancy wildcard | |
stuff.</li></ul><p> | |
If no pattern prefix is specified, Selenium assumes that it's a "glob" | |
pattern. | |
</p><p> | |
For commands that return multiple values (such as verifySelectOptions), | |
the string being matched is a comma-separated list of the return values, | |
where both commas and backslashes in the values are backslash-escaped. | |
When providing a pattern, the optional matching syntax (i.e. glob, | |
regexp, etc.) is specified once, as usual, at the beginning of the | |
pattern. | |
</p></div></td></tr><tr data="class; public"><td><img src="../icons/pubclass.gif" alt="Public class" title="Public class" /></td><td><a href="T_Selenium_HttpCommandProcessor.htm">HttpCommandProcessor</a></td><td><div class="summary"> | |
Sends commands and retrieves results via HTTP. | |
</div></td></tr><tr data="class; public"><td><img src="../icons/pubclass.gif" alt="Public class" title="Public class" /></td><td><a href="T_Selenium_SeleniumException.htm">SeleniumException</a></td><td><div class="summary"> | |
Thrown when a Selenium command fails. | |
</div></td></tr><tr data="class; public"><td><img src="../icons/pubclass.gif" alt="Public class" title="Public class" /></td><td><a href="T_Selenium_WebDriverBackedSelenium.htm">WebDriverBackedSelenium</a></td><td><div class="summary"> | |
Provides a Selenium instance that processes its commands via an IWebDriver instance. | |
</div></td></tr><tr data="class; public"><td><img src="../icons/pubclass.gif" alt="Public class" title="Public class" /></td><td><a href="T_Selenium_WebDriverCommandProcessor.htm">WebDriverCommandProcessor</a></td><td><div class="summary"> | |
Provides an implementation the ICommandProcessor interface which uses WebDriver to complete | |
the Selenium commands. | |
</div></td></tr></table></div><h1 class="heading"><span onclick="ExpandCollapse(interfaceToggle)" style="cursor:default;" onkeypress="ExpandCollapse_CheckKey(interfaceToggle, event)" tabindex="0"><img id="interfaceToggle" class="toggle" name="toggleSwitch" src="../icons/collapse_all.gif" />Interfaces</span></h1><div id="interfaceSection" class="section" name="collapseableSection" style=""><table id="typeList" class="members" frame="lhs" cellpadding="2"><col width="10%" /><tr><th class="iconColumn"> | |
</th><th class="nameColumn">Interface</th><th class="descriptionColumn">Description</th></tr><tr data="interface; public"><td><img src="../icons/pubinterface.gif" alt="Public interface" title="Public interface" /></td><td><a href="T_Selenium_ICommandProcessor.htm">ICommandProcessor</a></td><td><div class="summary"> | |
Provides a DoCommand method, which sends the command to the browser to be performed. | |
</div></td></tr><tr data="interface; public"><td><img src="../icons/pubinterface.gif" alt="Public interface" title="Public interface" /></td><td><a href="T_Selenium_IRemoteCommand.htm">IRemoteCommand</a></td><td><div class="summary"> | |
Summary description for IRemoteCommand. | |
</div></td></tr><tr data="interface; public"><td><img src="../icons/pubinterface.gif" alt="Public interface" title="Public interface" /></td><td><a href="T_Selenium_ISelenium.htm">ISelenium</a></td><td><div class="summary">Defines an object that runs Selenium commands. | |
<h3><a name="locators" />Element Locators</h3><p> | |
Element Locators tell Selenium which HTML element a command refers to. | |
The format of a locator is:</p><blockquote><em>locatorType</em><strong>=</strong><em>argument</em></blockquote><p> | |
We support the following strategies for locating elements: | |
</p><ul><li><strong>identifier</strong>=<em>id</em>: | |
Select the element with the specified @id attribute. If no match is | |
found, select the first element whose @name attribute is <em>id</em>. | |
(This is normally the default; see below.)</li><li><strong>id</strong>=<em>id</em>: | |
Select the element with the specified @id attribute.</li><li><strong>name</strong>=<em>name</em>: | |
Select the first element with the specified @name attribute. | |
<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>: | |
Find an element by evaluating the specified string. This allows you to traverse the HTML Document Object | |
Model using JavaScript. Note that you must not return a value in this string; simply make it the last expression in the block. | |
<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>: | |
Locate an element using an XPath expression. | |
<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>: | |
Select the link (anchor) element which contains text matching the | |
specified <em>pattern</em>. | |
<ul class="first last simple"><li>link=The link text</li></ul></li><li><strong>css</strong>=<em>cssSelectorSyntax</em>: | |
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. | |
<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>: | |
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. | |
<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> | |
Without an explicit locator prefix, Selenium uses the following default | |
strategies: | |
</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> | |
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> | |
Selects a single element based on its position in the list (offset from zero).</blockquote></blockquote><h3><a name="patterns" />String-match Patterns</h3><p> | |
Various Pattern syntaxes are available for matching string values: | |
</p><ul><li><strong>glob:</strong><em>pattern</em>: | |
Match a string against a "glob" (aka "wildmat") pattern. "Glob" is a | |
kind of limited regular-expression syntax typically used in command-line | |
shells. In a glob pattern, "*" represents any sequence of characters, and "?" | |
represents any single character. Glob patterns match against the entire | |
string.</li><li><strong>regexp:</strong><em>regexp</em>: | |
Match a string using a regular-expression. The full power of JavaScript | |
regular-expressions is available.</li><li><strong>regexpi:</strong><em>regexpi</em>: | |
Match a string using a case-insensitive regular-expression.</li><li><strong>exact:</strong><em>string</em>: | |
Match a string exactly, verbatim, without any of that fancy wildcard | |
stuff.</li></ul><p> | |
If no pattern prefix is specified, Selenium assumes that it's a "glob" | |
pattern. | |
</p><p> | |
For commands that return multiple values (such as verifySelectOptions), | |
the string being matched is a comma-separated list of the return values, | |
where both commas and backslashes in the values are backslash-escaped. | |
When providing a pattern, the optional matching syntax (i.e. glob, | |
regexp, etc.) is specified once, as usual, at the beginning of the | |
pattern. | |
</p></div></td></tr></table></div></div><div id="footer"><div class="footerLine"><img width="100%" height="3px" src="../icons/footer.gif" alt="Footer image" title="Footer image" /></div><A NAME="feedback"></A><span id="fb" class="feedbackcss"></span><p />Send comments on this topic to | |
<a id="HT_MailLink" href="mailto:webdriver%40googlegroups.com?Subject=WebDriver">WebDriver Users Google Group</a><script type="text/javascript"> | |
var HT_mailLink = document.getElementById("HT_MailLink"); | |
var HT_mailLinkText = HT_mailLink.innerHTML; | |
HT_mailLink.href += ": " + document.title; | |
HT_mailLink.innerHTML = HT_mailLinkText; | |
</script><p />Copyright © 2011 WebDriver Committers</div></div></body></html> |