JS to click a button automatically

Asked

Viewed 19 times

0

Good morning! I have a problem that I need to make more than 1000 changes to some web pages, and I wanted to automate this. My idea was to do this via JS. I searched through the web and found the example document.getElementById("myButtonId").click(); but the button in question does not have ID and has a property I’ve never seen (that editor-command). How can I do that?

<li editor-command="insertoptions">
  <span class="KB_Editor_Bdr_div Insert_Type" orgtitle="Insert options">Insert
    <svg>
      <use xlink:href="#KBEditortools_block_down_arrow"></use>
    </svg>
  </span>
</li>

The button in question:

botão

  • 1

    document.querySelector('[editor-command="insertoptions"]'). You can use this way to select by attribute, but I don’t know if this is what you need... O onclick is in this li?

  • 1

    I deleted my comments because with the information you gave me I managed to solve, thank you very much! Do you have any link where I can understand how this querySelector works to learn more?

  • 1

    The above question has an answer with the link to MDN documentation

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.