The Recorder Doesn't Capture the Correct Element for an Image

When a robot fails because the recorder doesn't capture the correct element for an icon or other image, you can use the built-in tools in Google Chrome to find the correct element.

Issue

A robot fails because the recorder wasn't able to capture the correct element for a graphical element, such as an icon.

Why It Happens

For some images with svg or img tags, the recorder can't identify the ID. You must target the ID, which is the element that an action acts on.

For example, consider the following options for targeting an icon and the elements that they target. None of these options records the element's ID.

Targeting option Element that is targeted
One way to target an icon In the Action Details panel, which appears after you target an element, the Element field shows TD
Another way to target an icon In the Action Details panel, which appears after you target an element, the Element field shows path
Another way to target an icon In the Action Details panel, which appears after you target an element, the Element field shows svg

What to Do

  1. Choose any of the incorrect targeting options in the recorder.

  2. Pause the recorder.

  3. In the application for which you're building a robot, right-click the element you're trying to target, and select Inspect.

    The DevTools appear.

  4. On the Elements tab, find the element that wraps the svg or img tag. This element contains a id=. For example:

    Within <tbody>, <tr>, and <td> is the <a id=> tag, which wraps the svg element

  5. Copy the value that appears within the quotation marks for id=" ".

  6. Test that you've identified the correct element.

    1. In DevTools, select the Console tab.

    2. Type the following value, and press Enter:

      document.getElementById('<value_you_copied>')

    3. Type the following value, and press Enter:

      document.getElementById('<value_you_copied>').click()

      If the menu opens for the icon, you've targeted the correct element.

    4. If the id=" " value is no longer in your clipboard, copy it again.

  7. In Oracle Integration, open the target for editing.

    See Update a Target.

  8. Update the Locator value. For instance, paste the value that you copied between the quotation marks in the @id=" " value.

    In the Locator field, if any additional text appears after the closing bracket ], remove the extra text. For example, the value should be something like this:

    xpath://*[@id="pt1:_UISatr:0:cil1"]

  9. Try running the robot again.