This Question have no Text answers yet!

Going through all the check boxes and selecting the ones that are passed in the parameters

Question!

Lets say I have bunch of checkboxes listed as below:

a)All b)Test 1 c)Test 3 d)Test 4

When the user goes to the application sometimes all are selected and sometimes only b and c are selected. I want to write a script which can do two things:

1) Select All fields

If the All field is not selected, it will select it.

2) Select only one field

first checks if the every field is unchecked and select the specific field.

this is what I tried:

def checkbox(checkbox):
    # checkbox variable could be a single item or multiple items user wants to check

if self.driver.find_element_by_id('type').is_selected() == False and checkbox = False:
   self.execute_script_click("id", "type")

elif self.driver.find_element_by_id('type').is_selected() == False and checkbox = True:
    # click twice to make sure nothing is selected
    self.execute_script_click("id", "type")
    self.execute_script_click("id", "type")
    for i in checkbox:
        # click is a function that finds an element and clicks the button
        self.click(10, "id", i)


Video about Going through all the check boxes and selecting the ones that are passed in the parameters