How to store text of selected item in a dropdown list

Hi, i am trying to use storetext command for selected item on any dropdown list (class=combobox on inspect element), but it copies entire list and not just the item selected from the list.

i tried storevalue but it gives a number(eg.[ '<'option value= “42” ‘>‘garden ‘<’/option’>’]) whereas i had selected a name(‘garden’ in this case) from the list which i want to store.

how to store the selected item

thanks in advance

You can use Execute Script in this case:

    var d  = document.getElementById("WhatSoftware");
    var selectedText = d.options[d.selectedIndex].text; return selectedText;

Test macro:

    {
      "Name": "dropdown_scraping",
      "CreationDate": "2021-5-28",
      "Commands": [
        {
          "Command": "open",
          "Target": "https://ui.vision/contact",
          "Value": "",
          "Description": ""
        },
        {
          "Command": "select",
          "Target": "id=WhatSoftware",
          "Value": "label=UI Vision Pro/Enterprise [Priority Support]",
          "Description": "Select the value. We will scrape it in the next line"
        },
        {
          "Command": "executeScript",
          "Target": "var d  = document.getElementById(\"WhatSoftware\");\nvar selectedText = d.options[d.selectedIndex].text; return selectedText;",
          "Value": "t",
          "Description": ""
        },
        {
          "Command": "echo",
          "Target": "Dropwdown text=${t} ",
          "Value": "green",
          "Description": ""
        }
      ]
    }
1 Like