1

I want to check the (SELECT ALL) checkbox from the input dropdown menu. How could I do that? Here is the screenshot of the dropdown menu. The field's id next to the dropdown icon is rvrMain_ctl00_ctl09_ctl00.

enter image description here

So far here is my code, but gave me no good result.

checkboxes = browser.find_elements_by_xpath("//input[@id='rvrMain_ctl00_ctl09_ctl00']")
for checkbox in checkboxes:
    if not checkbox.is_selected():
        checkbox.click()

Another try, but still no good result.

browser.find_element_by_xpath("//input[@id='rvrMain_ctl00_ctl09_ctl00']").click()

Any help will be much appreciated. Thanks and regards,

Arnold

EDIT

If I try to inspect the element of the field, here is the HMTL code:

<table cellspacing="0" cellpadding="0">
   <tbody>
      <tr>
         <td nowrap="nowrap"><span style="font-family:Verdana;font-size:8pt;"><input id="rvrMain_ctl00_ctl09_ctl03_ctl00" name="rvrMain$ctl00$ctl09$ctl03$ctl00" onclick="MVClassrvrMain_ctl00_ctl09.SetAutoPostBackOnHide();MultiValidValuesSelectAll(this, 'rvrMain_ctl00_ctl09_ctl03');" type="checkbox"><label for="rvrMain_ctl00_ctl09_ctl03_ctl00">(Select All)</label></span></td>
      </tr>
      <tr>
         <td nowrap="nowrap"><span style="font-family:Verdana;font-size:8pt;"><input id="rvrMain_ctl00_ctl09_ctl03_ctl01" name="rvrMain$ctl00$ctl09$ctl03$ctl01" onclick="MVClassrvrMain_ctl00_ctl09.SetAutoPostBackOnHide();OnClickMultiValidValue(this, document.getElementById('rvrMain_ctl00_ctl09_ctl03_ctl00'));" type="checkbox"><label for="rvrMain_ctl00_ctl09_ctl03_ctl01">148950&nbsp;-&nbsp;PT.&nbsp;CATUR&nbsp;SENTOSA&nbsp;ADIPRANA&nbsp;-&nbsp;KOTABUMI</label></span></td>
      </tr>
      <tr>
         <td nowrap="nowrap"><span style="font-family:Verdana;font-size:8pt;"><input id="rvrMain_ctl00_ctl09_ctl03_ctl02" name="rvrMain$ctl00$ctl09$ctl03$ctl02" onclick="MVClassrvrMain_ctl00_ctl09.SetAutoPostBackOnHide();OnClickMultiValidValue(this, document.getElementById('rvrMain_ctl00_ctl09_ctl03_ctl00'));" type="checkbox"><label for="rvrMain_ctl00_ctl09_ctl03_ctl02">148961&nbsp;-&nbsp;PT.&nbsp;CATUR&nbsp;SENTOSA&nbsp;ADIPRANA&nbsp;-&nbsp;BANDAR&nbsp;LAMPUNG</label></span></td>
      </tr>
      --- the list keeps go on and on---
      <tr>
         <td nowrap="nowrap"><span style="font-family:Verdana;font-size:8pt;"><input id="rvrMain_ctl00_ctl09_ctl03_ctl203" name="rvrMain$ctl00$ctl09$ctl03$ctl203" onclick="MVClassrvrMain_ctl00_ctl09.SetAutoPostBackOnHide();OnClickMultiValidValue(this, document.getElementById('rvrMain_ctl00_ctl09_ctl03_ctl00'));" type="checkbox"><label for="rvrMain_ctl00_ctl09_ctl03_ctl203">320864&nbsp;-&nbsp;PT.&nbsp;LIQUID&nbsp;KENCANA&nbsp;ABADI&nbsp;-&nbsp;NIAS</label></span></td>
      </tr>
   </tbody>
</table>

I want to select the checkbox with label (Select All).

EDIT

As suggested by Dillanm, I revised my code and it worked. Basically I have to click on the dropdown menu icon first, and then click on the one of the checkboxes. So here is the code:

browser.find_element_by_id('rvrMain_ctl00_ctl09_ctl01').click() # this one click on the dropdown menu icon
browser.find_element_by_id('rvrMain_ctl00_ctl09_ctl03_ctl00').click() # this one click on the checkbox, either uncheck or check
8
  • Can you share HTML of pop-up? Commented Jan 25, 2017 at 8:53
  • have you performing click on the down arrow button of dropdown before moving to checkbox ? Commented Jan 25, 2017 at 8:54
  • You could try the Select class from the WebDriver Support package; see this answer for more details (not sure if it will work with checkboxes though) Commented Jan 25, 2017 at 9:33
  • 1
    @Dillanm thanks mate! Yes you are right. I have to click on the icon first and followed by click the checkbox. Now I can check the (Select All) checkbox! How can I mark that your comment is the right answer? Commented Jan 25, 2017 at 10:00
  • 1
    @Dillanm sorry for my tardy reply. Please see the updated post. I added my final code. Commented Jan 31, 2017 at 15:16

1 Answer 1

2

In your case you are missing the step to click on the down arrow icon of your element So Just click the down arrows, the dropdown items get visible and then have to perform your check option.

Like -

browser.find_element_by_xpath(down_arrow_icon_xpath).click()
checkbox = browser.find_element_by_id("rvrMain_ctl00_ctl09_ctl03_ctl00")
    if not checkbox.is_selected():
        checkbox.click()
Sign up to request clarification or add additional context in comments.

2 Comments

First line will cause error as you're trying to click on list (use find_element instead of find_elements). Also second line will return 0 elements as there is no input fields with id='rvrMain_ctl00_ctl09_ctl00' in provided HTML code (but this seem to be OP misleading). As target check-box is initially known there is no need to loop through all the options, you can just use "(Select All)" to check exact
@Andersson, you are right , The problem was he missed to click on down arrow icon . So i did mentioned that and pasted the code in hurry . Thanks for remind :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.