Selectors

Selectors are the core object of Selectify. They facilitate user interaction with HTML elements, querying them with natural language descriptors as opposed to precise and overly specific DOM, XPath, or CSS selector syntax; which are typically fragile and easily disrupted.

You primarily interact with Selectors through the predict endpoint. Given html at a particular moment in time (the Page State), it executes change analysis, error correction, and model inference to identify the element in question. It returns the most relevant selectors to your query text.

To teach the system, you can initiate a training request. This operation enables you to label the desired selector within the web console. Further predictions will leverage this training example to better generalize to your specific webapp.


Train a page selector

This endpoint allows you to initiate a new query selector that you expect to manually tag.

Header Values

  • Name
    authorization
    Type
    Description

Request Body

Requests should be formatted as a PageSelectorCreate object.

  • Name
    text
    Type
    string
    Description
    The natural language description of the element that is being searched.
  • Name
    session_id
    Type
    string
    Description
    The session that this page selector belongs to.
  • Name
    page_state_id
    Type
    string
    Description
    The page state that this page selector belongs to.

Response Body

Responses will be formatted as a PageSelector object.

  • Name
    id
    Type
    string
    Description
  • Name
    text
    Type
    string
    Description
    The natural language description of the element that is being searched.
  • Name
    session_id
    Type
    string
    Description
    The session that this page selector belongs to.
  • Name
    page_state_id
    Type
    string
    Description
    The page state that this page selector belongs to.
  • Name
    selected_identifiers
    Type
    array[string]
    Description
    The identifiers of the elements that were selected.
  • Name
    selected_xpaths
    Type
    array[undefined]
    Description
    The xpaths of the elements that were selected.

Request

curl -X POST "https://api.selectify.ai/page_selector/train" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN"\
  -d '{
    "text": "string",
    "session_id": "00000000-0000-0000-0000-000000000000",
    "page_state_id": "00000000-0000-0000-0000-000000000000"
  }'

Response

{
  "id": "00000000-0000-0000-0000-000000000000",
  "text": "string",
  "session_id": "00000000-0000-0000-0000-000000000000",
  "page_state_id": "00000000-0000-0000-0000-000000000000",
  "selected_identifiers": [
    "string"
  ],
  "selected_xpaths": [
    null
  ]
}

Predict a page selector

This endpoint allows you to predict a new query selector. This is the endpoint to use within your CI or deployment pipeline. It accepts your query and returns once predictions are complete. Note predictions may take anywhere from 1s-1min, depending on page changes and current server load.

Header Values

  • Name
    authorization
    Type
    Description

Request Body

Requests should be formatted as a PageSelectorCreate object.

  • Name
    text
    Type
    string
    Description
    The natural language description of the element that is being searched.
  • Name
    session_id
    Type
    string
    Description
    The session that this page selector belongs to.
  • Name
    page_state_id
    Type
    string
    Description
    The page state that this page selector belongs to.

Response Body

Responses will be formatted as a PageSelector object.

  • Name
    id
    Type
    string
    Description
  • Name
    text
    Type
    string
    Description
    The natural language description of the element that is being searched.
  • Name
    session_id
    Type
    string
    Description
    The session that this page selector belongs to.
  • Name
    page_state_id
    Type
    string
    Description
    The page state that this page selector belongs to.
  • Name
    selected_identifiers
    Type
    array[string]
    Description
    The identifiers of the elements that were selected.
  • Name
    selected_xpaths
    Type
    array[undefined]
    Description
    The xpaths of the elements that were selected.

Request

curl -X POST "https://api.selectify.ai/page_selector/predict" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN"\
  -d '{
    "text": "string",
    "session_id": "00000000-0000-0000-0000-000000000000",
    "page_state_id": "00000000-0000-0000-0000-000000000000"
  }'

Response

{
  "id": "00000000-0000-0000-0000-000000000000",
  "text": "string",
  "session_id": "00000000-0000-0000-0000-000000000000",
  "page_state_id": "00000000-0000-0000-0000-000000000000",
  "selected_identifiers": [
    "string"
  ],
  "selected_xpaths": [
    null
  ]
}

Retrieve a page selector

Retrieve the current state of a page selector prediction.

URL Parameters

  • Name
    page_selector_id
    Type
    string
    Description

Header Values

  • Name
    authorization
    Type
    Description

Response Body

Responses will be formatted as a PageSelector object.

  • Name
    id
    Type
    string
    Description
  • Name
    text
    Type
    string
    Description
    The natural language description of the element that is being searched.
  • Name
    session_id
    Type
    string
    Description
    The session that this page selector belongs to.
  • Name
    page_state_id
    Type
    string
    Description
    The page state that this page selector belongs to.
  • Name
    selected_identifiers
    Type
    array[string]
    Description
    The identifiers of the elements that were selected.
  • Name
    selected_xpaths
    Type
    array[undefined]
    Description
    The xpaths of the elements that were selected.

Request

curl -X GET "https://api.selectify.ai/page_selector/{page_selector_id}" \
  -H "Authorization: Bearer YOUR_TOKEN"

Response

{
  "id": "00000000-0000-0000-0000-000000000000",
  "text": "string",
  "session_id": "00000000-0000-0000-0000-000000000000",
  "page_state_id": "00000000-0000-0000-0000-000000000000",
  "selected_identifiers": [
    "string"
  ],
  "selected_xpaths": [
    null
  ]
}