0

I'n trying to check multiple checkboxes through my python code:

checkboxes=driver.find_elements_by_xpath("//input[@type='checkbox']")
    for i in range(0,len(checkboxes)):
            if checkboxes[i].is_selected():
                    time.sleep(2)
            else:
                    checkboxes[i].click()

It works fine for the first checkbox but it fails for the rest giving me the following error:

  Element <input _ngcontent-rnm-59="" type="checkbox" class="ng-untouched 
  ng-pristine ng-valid"> is not clickable at point (584, 215).

The HTML code of the dropbox is as follows:

<div class="ps-content">

                        <div _ngcontent-rnm-59="" style="width: 300px;" class="scroll-300">
                            <!--template bindings={}--><div _ngcontent-rnm-59="">
                                <!--template bindings={}--><div _ngcontent-rnm-59="">
                                    <label _ngcontent-rnm-59="" style="width: 100%; background-color: #d6d4d4">
                                        LTE BASIC - Serving Cell
                                    </label>
                                    <!--template bindings={}--><li _ngcontent-rnm-59="" style="margin-right:-20 px">
                                        <div _ngcontent-rnm-59="" class="checkbox-new" style="display:flex; width:100%; justify-content: space-between;">
                                            <label _ngcontent-rnm-59="" style="width: 100%">
                                                <input _ngcontent-rnm-59="" type="checkbox" class="ng-valid ng-dirty ng-touched"><span _ngcontent-rnm-59="" class="checkbox-material"></span> Voice RAT
                                            </label>

Please suggest the way to debug it.

amit
  • 73
  • 2
  • 15
  • That error can happen if the checkbox you are trying to click is not in view. You may want to make the window start in a larger size or to scroll down the page so the checkbox is in view. (You could also click the box via Javascript, [this](https://stackoverflow.com/questions/27934945/selenium-move-to-element-does-not-always-mouse-hover) shows how to move to an element) – AceLewis Oct 25 '17 at 12:06
  • Also not really related to the question but to Python in general, you should not use `for i in range(0,len(checkboxes))` you should just do `for checkbox in checkboxes`. If for some reason you also need the index of the checkbox then you can use enumerate: https://docs.python.org/3/library/functions.html#enumerate – AceLewis Oct 25 '17 at 12:08
  • The error `Element is not clickable at point` can stem out from different possible factors. Possible duplicate of [Selenium Web Driver & Java. Element is not clickable at point (36, 72). Other element would receive the click:](https://stackoverflow.com/questions/44912203/selenium-web-driver-java-element-is-not-clickable-at-point-36-72-other-el) – undetected Selenium Oct 25 '17 at 13:10
  • Give a screenshot of the area includes those checkbox. After click on the first checkbox, will the page load something dynamically? will the location of rest checkbox change? – yong Oct 25 '17 at 13:32

0 Answers0