Some commands require a target DOM element to operate on, specified in the
targetargument element of the
commandelement. Such targets can be links to click,
divto hover over and windows or tabs to switch to and so on. In cases when selectors find more elements, only the first one found will be used. Be advised to use selectors as specific as possible to make sure they match only one element, being the one you want. If the command requires the
targetbut it’s empty in your script, it’s equal to
tag=body, the page
bodyelement is used. If
targetcontents start with a double slash (//), the XPath selector is assumed.
ASM Webdriver supports the following selectors to find the target:
- id=elementIdID selector: This selector will match DOM element havingid=”elementId”in the DOM page structure.
- css=div.someClass pCSS selector: This example selector will mach<p>element inside<div>element withclass=”someClass”. Every expression supported by Selenium ByCssSelector method works in ASM Webdriver monitor.
- xpath=//img[@title=’Nice image’]XPath selector: This example will match an <img> element with the “Nice image” string in itstitleattribute. For more information, see the XPath specification.
- name=passwordName selector: This example finds an element having anameattribute set to”password”. Useful for locating form elements that usually have thenameattribute set.
- link=HomeLink text selector. This example will match<a>element that has Home text inside, such as<a href=”/”>Home</a>.
- partialLink=clickPartial link text selector works similar to thelinkbut you need not specify the whole text, but only a substring is required. For example,<a href=”/”>click here to go to Home page</a>.
- tag=imgTag name selector selects by tag name. This selector is particularly prone to find more elements but only the first one will be operated on so use with caution.
- class=wrapperClass name selector, selects by class attribute. Again, this selector will probably find more elements so use with caution. This example is equal to thecss=.wrapperselector.
- identifier=someIdWorks the same as id selector. Included for compatibility reasons.
- title=windowTitleTitle selector. Only useful for switching windows (selectWindowcommand)
- index=1Index selector. Only works when switching frames. (selectFramecommand)
- relative=parentThe relative selector to switch back to the parent frame. The only value allowed after the equals sign is“parent”, as shown. Only forselectFramecommand.