# Monitoring element's href attribute - EJAVASCRIPT & Selection\_Empty errors

**URL:** <https://forums.distill.io/t/monitoring-elements-href-attribute-ejavascript-selection-empty-errors/4855>\
**Category:** Help and Support\
**Tags:** visual-selector\
**Created:** [March 13, 2025, 12:36am UTC](https://forums.distill.io/t/monitoring-elements-href-attribute-ejavascript-selection-empty-errors/4855 "2025-03-13T00:36:24Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![sturmstrive](https://forums.distill.io/letter_avatar_proxy/v4/letter/s/46a35a/32.png) [@sturmstrive](https://forums.distill.io/u/sturmstrive)\
**Post date:** [March 13, 2025, 12:36am UTC](https://forums.distill.io/t/monitoring-elements-href-attribute-ejavascript-selection-empty-errors/4855/1 "2025-03-13T00:36:24Z")

</div>

I keep getting the same errors despite me knowing the xlink works

This is the website I am monitoring  
[https://www.jobs.nhs.uk/candidate/search/results?searchFormType=sortBy&sort=publicationDateDesc&searchByLocationOnly=true&language=en](https://www.jobs.nhs.uk/candidate/search/results?searchFormType=sortBy&sort=publicationDateDesc&searchByLocationOnly=true&language=en)

Console Check for Xlink  
`$x("(//a[@data-test='search-result-job-title']/@href)[1]")`

Full JSON:

```auto
{
  "selections": [
    {
      "frames": [
        {
          "index": 0,
          "excludes": [],
          "includes": [
            {
              "expr": "(//a[@data-test='search-result-job-title'])[1]/@href",
              "type": "xpath",
              "fields": [
                {
                  "name": "href",
                  "type": "builtin"
                }
              ]
            }
          ]
        }
      ],
      "dynamic": true,
      "delay": 2
    }
  ],
  "regexp": {
    "expr": "",
    "flags": "gim"
  },
  "ignoreEmptyText": true,
  "includeStyle": false,
  "viewport": {},
  "dataAttr": "href",
  "blockAdsAndCookies": true
}

```

I got this to give me a list of all the URLS but it never actually gave me the URLS just the names associated with the URLS (header)

---

<div class="post-metadata">

**Author:** ![ajitk](https://forums.distill.io/letter_avatar_proxy/v4/letter/a/ec9cab/32.png) [@ajitk](https://forums.distill.io/u/ajitk)\
**Post date:** [March 13, 2025, 1:48am UTC](https://forums.distill.io/t/monitoring-elements-href-attribute-ejavascript-selection-empty-errors/4855/2 "2025-03-13T01:48:35Z")

</div>

a selection in distill must always select a list of elements. check out the docs to learn more about how to monitor changes to attributes:

[#how-to-monitor-attribute-and-property-value-for-the-selected-element](https://distill.io/docs/web-monitor/what-is-visual-selector/#how-to-monitor-attribute-and-property-value-for-the-selected-element)

in this case,

1. use the following xpath: `(//a[@data-test='search-result-job-title'])[1]`
2. and, change the monitored field from `text` to `href`.

---

<div class="post-metadata">

**Author:** ![sturmstrive](https://forums.distill.io/letter_avatar_proxy/v4/letter/s/46a35a/32.png) [@sturmstrive](https://forums.distill.io/u/sturmstrive)\
**Post date:** [March 13, 2025, 11:14am UTC](https://forums.distill.io/t/monitoring-elements-href-attribute-ejavascript-selection-empty-errors/4855/3 "2025-03-13T11:14:34Z")

</div>

Sorry to be a pain but my xpath isn’t working and no idea why

the console test for this on the website is:

`document.querySelectorAll('a.iCIMS_Anchor')[0].href`

This is my xpath  
`(//a[contains(@class, 'iCIMS_Anchor')])[1]`

Website is:

> **[Change Grow Live - believe in people](https://careers-changegrowlive.icims.com/jobs/search?mode=redo&pr=0&schemaId=%24T%7BJob%7D.%24T%7BJobPost%7D.%24F%7BPostedDateTime%7D&o=A&searchRelation=keyword_all)**
>
> We are a health and social care charity. We help people achieve their goals.

Full JSON:

```auto
{
  "selections": [
    {
      "frames": [
        {
          "index": 0,
          "excludes": [],
          "includes": [
            {
              "expr": "(//a[contains(@class, 'iCIMS_Anchor')])[1]/@href",
              "type": "xpath",
              "fields": [
                {
                  "name": "href",
                  "type": "attribute"
                }
              ]
            }
          ]
        }
      ],
      "dynamic": true,
      "delay": 15
    }
  ],
  "regexp": {
    "expr": "",
    "flags": "gim"
  },
  "ignoreEmptyText": true,
  "includeStyle": true,
  "viewport": {},
  "dataAttr": "text",
  "blockAdsAndCookies": true
}

```

---

<div class="post-metadata">

**Author:** ![ajitk](https://forums.distill.io/letter_avatar_proxy/v4/letter/a/ec9cab/32.png) [@ajitk](https://forums.distill.io/u/ajitk)\
**Post date:** [March 13, 2025, 12:04pm UTC](https://forums.distill.io/t/monitoring-elements-href-attribute-ejavascript-selection-empty-errors/4855/4 "2025-03-13T12:04:38Z")

</div>

this one has the same problem. remove the `/@href` from the xpath in config.

---

<div class="post-metadata">

**Author:** ![sturmstrive](https://forums.distill.io/letter_avatar_proxy/v4/letter/s/46a35a/32.png) [@sturmstrive](https://forums.distill.io/u/sturmstrive)\
**Post date:** [March 13, 2025, 2:27pm UTC](https://forums.distill.io/t/monitoring-elements-href-attribute-ejavascript-selection-empty-errors/4855/5 "2025-03-13T14:27:05Z")

</div>

I have removed it and still getting the same error - in the console it’s coming up fine, I change the xpath in Distill to

(//a[contains(@class, ‘iCIMS\_Anchor’)])[1]

but this still returns no value

---

<div class="post-metadata">

**Author:** ![sturmstrive](https://forums.distill.io/letter_avatar_proxy/v4/letter/s/46a35a/32.png) [@sturmstrive](https://forums.distill.io/u/sturmstrive)\
**Post date:** [March 13, 2025, 3:48pm UTC](https://forums.distill.io/t/monitoring-elements-href-attribute-ejavascript-selection-empty-errors/4855/6 "2025-03-13T15:48:00Z")

</div>

I think the issue I am now having is that it’s within an Iframe - I could run a macro but that only works if my device is open right?

Screenshot below of website showing Iframe

 ![image](https://forums.distill.io/uploads/default/original/2X/8/831c85fd00e1a3a54c0553c4dbf384a0512ae52e.png)

---

<div class="post-metadata">

**Author:** ![ajitk](https://forums.distill.io/letter_avatar_proxy/v4/letter/a/ec9cab/32.png) [@ajitk](https://forums.distill.io/u/ajitk)\
**Post date:** [March 14, 2025, 8:17am UTC](https://forums.distill.io/t/monitoring-elements-href-attribute-ejavascript-selection-empty-errors/4855/7 "2025-03-14T08:17:37Z")

</div>

got it. the frame index in the config was `0` which is always the topmost window.

are you using the browser extension for checks? if not, install one from [distill.io/app/web-monitor](http://distill.io/app/web-monitor). once done, use the visual selector to select the page’s content instead of manually entering the selector. this will ensure that the correct frame is selected. note that the frame index in the config is always greater that zero for child frames.

as a test, try using the following cofig and see how it works:

```json
{
  "ignoreEmptyText": true,
  "includeStyle": false,
  "dataAttr": "text",
  "selections": [
    {
      "frames": [
        {
          "index": 1,
          "uri": "https://careers-changegrowlive.icims.com/jobs/search?mode=redo&pr=0&schemaId=%24T%7BJob%7D.%24T%7BJobPost%7D.%24F%7BPostedDateTime%7D&o=A&searchRelation=keyword_all&in_iframe=1",
          "excludes": [],
          "includes": [
            {
              "type": "css",
              "expr": "div:first-child .iCIMS_Anchor",
              "fields": [
                {
                  "name": "text",
                  "type": "builtin"
                },
                {
                  "type": "attribute",
                  "name": "href"
                }
              ]
            }
          ]
        }
      ],
      "dynamic": true,
      "delay": 4
    }
  ],
  "incognito": false,
  "regexp": {
    "expr": "",
    "flags": "gim"
  },
  "blockAdsAndCookies": true
}

```
