Monitoring element's href attribute - EJAVASCRIPT & Selection_Empty errors

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

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

Full JSON:

{
  "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)

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

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.
1 Like

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:

Full JSON:

{
  "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
}

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

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

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

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. 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:

{
  "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
}