Information:

Environment

  • Dynatrace Recorder

 

Symptoms

How can I adjust the locators used in the Dynatrace Recorder?

Solution

The Dynatrace Recorder uses two different types of locators for its actions.

The first is the HTML DOM (Document Object Model). The Dynatrace Recorder can reference many elements through the DOM by name or ID.

Some common DOM calls are:

  • document.getElementByID("ELEMENT_ID")
  • document.links["LINK_NAME"]
  • document.forms["FORM_NAME"]["ELEMENT_NAME"]

For more information on the DOM, go here: http://www.w3schools.com/jsref/default.asp

The second is the CSS selector. The CSS selectors can offer much more dynamic options in selecting elements.

Some common CSS selectors are:

  • #mylink - the element with ID mylink
  • a:contains("mylink") - the link that contains mylink
  • input[name="myinput"][class="nameinput"] - input element with name myinput and class nameinput

To select from multiple elements with the same attributes, end the selector with :eq(n) where n is the nth instance of that element starting from 0

To match partial values in the attributes use the following options

  • input[name^="my"] - input element whose name begins with my
  • a[href$=".html"] - link whose href ends in .html
  • a[href*="test"] - link whose href contains test

For more information on CSS selectors, go here: http://www.w3.org/TR/css3-selectors/

 

 

 

 

 

  • No labels
  1. Anonymous (login to see details)

    CSS selectors do follow the W3 standards, but there are additional selectors, known as pseudo selectors, that are defined by the Sizzle library.  These are all used with a colon after the standard selectors (e.g. – div.back:contains("Total gains") ).

     

    Sizzle library documentation:    https://github.com/jquery/sizzle/wiki

     

    Currently supported pseudo selectors

    pseudos:      not, enabled, disabled, checked, selected, parent, empty, contains, has, header, text, focus, active

                        input (with sub-add-ons: radio, checkbox, file, password, image, submit, reset, button)

    setFilters:     first, last, even, odd, lt,  gt, eq

     

    The sub-add-ons for the "input" pseudo selector are just added with another colon (e.g. –  #myName:input:submit).