Unable to select checkbox using javascript in browser console

i am automating our application using a tool that supports javascript.Navigated to the page at browser console, i am trying to select the checkbox inside a web component using document.queryselector method but i am not able to succeed in checking the box.

tried .checked = true, select and submitform.

i am relatively new in this company and to the tool, so need some tip.

screenshot attached

2 answers

  • answered 2022-01-21 17:26 Isaac Rodriguez

    You are using querySelectorAll() that return an array, so you need to specify the position of the array that you want to change. Actually in the image show that the function return an array with 2 elements.

  • answered 2022-01-21 17:33 Srimurugan Subramanian

    You can use for loop or need to specify the position.

    var checkboxes = document.querySelectorAll('selector');
    for (var i = 0, len = checkboxes.length; i < len; i++) {
    //work with checkboxes[i].checked = true;

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum