Exemple #1
0
 def toggle(self, element_index, modifiers = 0):
     """Checks the specified element if it is unchecked, and unchecks it if
        it is checked.
        Returns True if the element is checked as a result of this call,
        else False.
        Raises Exception if this list was created with radio=True.
        Element indexes are 0-based.
     """
     if self.radio:
         raise Exception('cannot toggle a radio button')
     click(self.element_regions[element_index], modifiers = modifiers,
             region = self.region)
     if self.auto_verify:
         # updates the state
         self.wait(element_index, not self.is_checked(element_index))
     else:
         self._toggle_state(element_index)
     return self.is_checked(element_index)
Exemple #2
0
 def toggle(self, element_index, modifiers=0):
     """Checks the specified element if it is unchecked, and unchecks it if
        it is checked.
        Returns True if the element is checked as a result of this call,
        else False.
        Raises Exception if this list was created with radio=True.
        Element indexes are 0-based.
     """
     if self.radio:
         raise Exception('cannot toggle a radio button')
     click(self.element_regions[element_index],
           modifiers=modifiers,
           region=self.region)
     if self.auto_verify:
         # updates the state
         self.wait(element_index, not self.is_checked(element_index))
     else:
         self._toggle_state(element_index)
     return self.is_checked(element_index)
Exemple #3
0
 def check(self, element_index, modifiers = 0):
     """Checks the specified element.
        If the element is already checked, does nothing.
        Returns True if the element was not previously checked, else false.
        Element indexes are 0-based.
     """
     if self.is_checked(element_index):
         return False
     if self.radio:
         old_index = self.checked_element()
     click(self.element_regions[element_index], modifiers = modifiers,
             region = self.region)
     if self.auto_verify:
         # updates the state
         self.wait(element_index, True)
     else:
         self._toggle_state(element_index)
     if self.radio:
         if old_index is not None:
             # old_index != element_index because element_index was not
             # checked
             self._toggle_state(old_index)
     return True
Exemple #4
0
 def check(self, element_index, modifiers=0):
     """Checks the specified element.
        If the element is already checked, does nothing.
        Returns True if the element was not previously checked, else false.
        Element indexes are 0-based.
     """
     if self.is_checked(element_index):
         return False
     if self.radio:
         old_index = self.checked_element()
     click(self.element_regions[element_index],
           modifiers=modifiers,
           region=self.region)
     if self.auto_verify:
         # updates the state
         self.wait(element_index, True)
     else:
         self._toggle_state(element_index)
     if self.radio:
         if old_index is not None:
             # old_index != element_index because element_index was not
             # checked
             self._toggle_state(old_index)
     return True