Ejemplo n.º 1
0
 def _value__set(self, value):
     super(SelectElement, self)._value__set(value)
     selected = [el for el in _options_xpath(self)
                 if 'selected' in el.attrib]
     if self.multiple:
         values = value
         # TODO: decide when to send ctrl vs command key?
         # send command for multiple-select
         self.browser.webdriver('POST', 'keys', value=[u'\ue03d'])
     else:
         values = [value]
     for el in selected:
         val, option_locator = _get_value_and_locator_from_option(
             self.browser.webdriver, el)
         if val not in values:
             raise AssertionError("Option with value %r not present in "
                                  "remote document!" % val)
         if self.multiple:
             self.browser.webdriver('POST',
                                    'element/%s/click' % option_locator)
         else:
             self.browser.webdriver('POST',
                                    'element/%s/click' % option_locator)
             break
     if self.multiple:
         # clear modifier
         self.browser.webdriver('POST', 'keys', value=[u'\ue000'])
Ejemplo n.º 2
0
 def _value__set(self, value):
     super(SelectElement, self)._value__set(value)
     selected = [el for el in _options_xpath(self)
                 if 'selected' in el.attrib]
     if self.multiple:
         values = value
     else:
         values = [value]
     for el in selected:
         val, option_locator = _get_value_and_locator_from_option(el)
         if val not in values:
             raise AssertionError("Option with value %r not present in "
                                  "remote document!" % val)
         if self.multiple:
             self.browser.selenium('addSelection', self._locator,
                                     option_locator)
         else:
             self.browser.selenium('select', self._locator, option_locator)
             break
Ejemplo n.º 3
0
 def _value__set(self, value):
     super(SelectElement, self)._value__set(value)
     selected = [el for el in _options_xpath(self)
                 if 'selected' in el.attrib]
     for el in selected:
         if el.get('value') == value:
             if value is None:
                 option_locator = u'value=regexp:^$'
             else:
                 option_locator = u'value=%s' % value
             break
         el_text = (el.text or u'').strip()
         value_text = (value or u'').strip()
         if el_text == value_text:
             option_locator = u'label=%s' % value_text
             break
     else:
         raise AssertionError("Option with value %r not present in "
                              "remote document!" % value)
     self.browser.selenium('select', self._locator, option_locator)
Ejemplo n.º 4
0
 def _value__set(self, value):
     super(SelectElement, self)._value__set(value)
     selected = [
         el for el in _options_xpath(self) if 'selected' in el.attrib
     ]
     if self.multiple:
         values = value
     else:
         values = [value]
     for el in selected:
         val, option_locator = _get_value_and_locator_from_option(el)
         if val not in values:
             raise AssertionError("Option with value %r not present in "
                                  "remote document!" % val)
         if self.multiple:
             self.browser.selenium('addSelection', self._locator,
                                   option_locator)
         else:
             self.browser.selenium('select', self._locator, option_locator)
             break