(self, text)
Select all options that display text matching the argument. That is, when given "Bar" this
           would select an option like:
             
            <option value="foo">Bar</option>
             
           :Args:
            - text - The visible text to match against
Select all options that display text matching the argument. That is, when given "Bar" this
           would select an option like:
             
            <option value="foo">Bar</option>
             
           :Args:
            - text - The visible text to match against
Select all options that display text matching the argument . That is when given Bar this would select an option like : <option value = foo > Bar< / option > : Args : - text - The visible text to match against
def select_by_visible_text(self, text):
        """Select all options that display text matching the argument. That is, when given "Bar" this
           would select an option like:
             
            <option value="foo">Bar</option>
             
           :Args:
            - text - The visible text to match against
           """
        xpath = ".//option[normalize-space(.) = %s]" % self._escapeString(text)
        opts = self._el.find_elements(By.XPATH, xpath)
        matched = False
        for opt in opts:
            self._setSelected(opt)
            if not self.is_multiple:
                return
            matched = True

        if len(opts) == 0 and " " in text:
            subStringWithoutSpace = self._get_longest_token(text)
            if subStringWithoutSpace == "":
                # seems weird to me that the java impl just selects the first or all if multiple
                # oh well... doing it here too.
                candidates = self.options
            else:
                xpath = ".//option[contains(.,%s)]" % self._escapeString(subStringWithoutSpace)
                candidates = self._el.find_elements(By.XPATH, xpath)
            for candidate in candidates:
                self._setSelected(candidate)
                if not self.is_multiple:
                    return
                matched = True

        if matched != True:
            raise NoSuchElementException("Could not locate element with visible text: %s" % text)
def select_by_visible_text ( self , text ) : xpath = ".//option[normalize-space(.) = %s]" % self . _escapeString ( text ) opts = self . _el . find_elements ( By . XPATH , xpath ) matched = False for opt in opts : self . _setSelected ( opt ) if not self . is_multiple : return matched = True if len ( opts ) == 0 and " " in text : subStringWithoutSpace = self . _get_longest_token ( text ) if subStringWithoutSpace == "" : # seems weird to me that the java impl just selects the first or all if multiple # oh well... doing it here too. candidates = self . options else : xpath = ".//option[contains(.,%s)]" % self . _escapeString ( subStringWithoutSpace ) candidates = self . _el . find_elements ( By . XPATH , xpath ) for candidate in candidates : self . _setSelected ( candidate ) if not self . is_multiple : return matched = True if matched != True : raise NoSuchElementException ( "Could not locate element with visible text: %s" % text )