3 Locators Browsers And Keys Reference - essenius/FitNesseFitSharpSelenium GitHub Wiki

Element Locators

Element locators are the parameters to the element functions. They have the format SearchMethod:Criterion.

In general, the selectors will find the first element that meets the criteria.

Supported search methods for web drivers are:

Search Method Means searching by Example
ClassName value of the class attribute ClassName:MyClass
Content content of the element. Elements can be button, input, meter, progress, select or textArea Content:Full Expected Content
CssSelector a CSS selector CssSelector:button#okButton
Id value of the Id attribute Id:okButton
Label associated label content Label:Address
LinkText text in a link element LinkText:click here
Name value of the name attribute Name:addressField
PartialContent partial content of the element (see also Content). PartialContent:Expected Content
PartialLinkText partial match of the text in a link PartialLinkText:click
TagName tag name of the element TagName:button
Trial on Id, Name, LinkText, ClassName, Label, Content, PartialLinkText, PartialContent or Tagname (whichever is found first) Trial:myId
XPath an XPath query XPath://table[@id='normalTable']

Additional search methods for mobile/native devices are AccessibilityId, AndroidAutomator, IosClassChain, IosNsPredicate, IosUiAutomation, TizenAutomation, WindowsAutomation.

The default search method (i.e. if you only use Criterion) is Trial.

Browsers and drivers

  • Supported browser names are Chrome, Chrome Headless, Edge, Edge Headless, Firefox, Firefox Headless, IE, Internet Explorer, Safari (on Macs), Opera.
  • Supported mobile/native drivers are Android, Ipad, Iphone, and WinApp.

Special Keys in the ‘Send Keys To Element’ Function

The Send Keys To Element function follows the standard Selenium convention. The special keys that you can use are:

Category Keys
Modifier keys Control = ^, Shift = +, Alt = %
Function keys {F1}, {F2}, {F3}{F12}
Arrow keys {UP}, {DOWN}, {LEFT}, {RIGHT}, {PGUP}, {PGDN}, {HOME}, {END}
Calculation {ADD}, {SUBTRACT}, {MULTIPLY}, {DIVIDE}, {ENTER}. For Enter you can also use ~
Other {INSERT}, {INS}, {DELETE}, {DEL}, {BACKSPACE}, {BKSP}, {BS}, {TAB}, {ESC}, {HELP}

Modifier keys operate as toggles: the first occurrence of the symbol switches it on; the next one will switch it off. If the state is still on at the end of the sequence, it will switch off automatically.

Besides marking the special keys shown above, curly braces can also be used to combine keys. A special case is the closing curly brace itself: if two occur without an opening curly brace in between, then the first one will be considered part of the text to be escaped. It is also possible to use repeaters: e.g. {BKSP 5} will send 5 backspaces.

Examples applied to a text element are shown in the table below.

Send Keys Result
abc+def+ghi type in abcDEFghi
^ac Copy the content to the clipboard (i.e. Ctrl-A Ctrl-C)
{END}+{LEFT}{LEFT}{LEFT}|+^c Copy the last three characters of the content to the clipboard
{{}content{}} type in {content}
Abc{def}ghi}jkl type in Abcdef}ghijkl
{a 5} type in aaaaa