The first selected option in this select tag (or the currently selected option in a normal select).

@return SelectOption
@throws SelectException When no options were selected.
328699
public function getFirstSelectedOption()
	{
		foreach ( $this->getOptions() as $option ) {
			if ( $option->isSelected() ) {
				return $option;
			}
		}

		throw new SelectException('No options are selected', SelectException::TYPE_NOT_SELECTED);
	}
505206
protected function _getSelect() {
        $fields = $this->_entity->fields();

        switch ($this->_type) {
            case self::QUERY_SELECT :
                $this->_query .= 'SELECT ';

                $nFields = count($fields);
                $i = 0;

                //We add all fields to the select
                foreach ($fields as $value) {
                    //We mustn't add fields which don't exist in the SQL table
                    if ($value->foreign == null || in_array($value->foreign->type(), [ForeignKey::ONE_TO_ONE, ForeignKey::MANY_TO_ONE])) {
                        $this->_query .= $this->_entity->name() . '.' . $value->name . ' AS ' . $this->_entity->name() . '_' . $value->name;

                        if ($i < $nFields - 1) {
                            $this->_query .= ', ';
                        }
                    }
                    //To optimize the relation ONE TO MANY, we replace the join value by the number of element in this join
                    else if ($value->foreign != null && $value->foreign->type() == ForeignKey::ONE_TO_MANY) {
                        $currentEntity = $value->foreign->entity();
                        $currentField = $value->foreign->field();
                        $referenceEntity = $value->foreign->referenceEntity();
                        $referenceField = $value->foreign->referenceField();

                        $this->_query .= '(SELECT COUNT(*) FROM ' . $referenceEntity . ' WHERE ' . $referenceEntity . '.' . $referenceField . ' = ' . $currentEntity . '.' . $currentField . ') AS count_one_' . $this->_entity->name() . '_' . $value->name;

                        if ($i < $nFields - 1) {
                            $this->_query .= ', ';
                        }
                    }
                    //To optimize the relation MANY TO MANY, we replace the join value by the number of element in this join
                    else if ($value->foreign != null && $value->foreign->type() == ForeignKey::MANY_TO_MANY) {
                        $currentEntity = $value->foreign->entity();
                        $currentField = $this->_entity->primary();
                        $referenceEntity = $value->foreign->referenceEntity();
                        $referenceField = $value->foreign->referenceField();
                        $current = strtolower($currentEntity . $currentField);
                        $reference = strtolower($referenceEntity . $referenceField);
                        $table = [$current, $reference];
                        sort($table, SORT_STRING);
                        $table = ucfirst($table[0] . $table[1]);

                        $this->_query .= '(SELECT COUNT(*) FROM ' . $table . ' WHERE ' . $table . '.' . $currentEntity . '_' . $currentField . ' = ' . $currentEntity . '.' . $currentField . ') AS count_many_' . $this->_entity->name() . '_' . $value->name;

                        if ($i < $nFields - 1) {
                            $this->_query .= ', ';
                        }
                    }

                    $i++;
                }

                $this->_query = preg_replace('#^(.*)(, )$#isU', '$1', $this->_query);

                //if some fields have a relation one to one or many to one, we had a join
                foreach ($fields as $value) {
                    if ($value->foreign != null && in_array($value->foreign->type(), [ForeignKey::ONE_TO_ONE, ForeignKey::MANY_TO_ONE])) {
                        $this->_query .= ', ';

                        $class = $this->_getTableEntity($value->foreign->referenceEntity());

                        $fieldsRelation = $class->fields();
                        $nFieldsRelation = count($fieldsRelation);
                        $i = 0;

                        foreach ($fieldsRelation as $relation) {
                            if ($relation->foreign == null || in_array($relation->foreign->type(), [ForeignKey::ONE_TO_ONE, ForeignKey::MANY_TO_ONE])) {
                                $this->_query .= $value->name . '_' . $class->name() . '.' . $relation->name . ' AS ' . $value->name . '_' . $class->name() . '_' . $relation->name;

                                if ($i < $nFieldsRelation - 1) {
                                    $this->_query .= ', ';
                                }
                            }

                            $i++;
                        }

                        $this->_query = preg_replace('#^(.*)(, )$#isU', '$1', $this->_query);
                    }
                }
                break;

            case self::QUERY_DISTINCT :
                $primaryColumn = $this->_entity->name() . '.' . $this->_entity->fields()[$this->_entity->primary()]->name;

                if (preg_match('(' . $primaryColumn . ')', $this->_distinct)) {
                    $this->_query .= 'SELECT DISTINCT ' . $this->_distinct . ' ';
                }
                else {
                    $this->_query .= 'SELECT DISTINCT ' . $this->_distinct . ', ' . $primaryColumn . ' ';
                }
                break;

            case self::QUERY_COUNT :
                $this->_query .= 'SELECT COUNT(*) ';
                break;
        }

        $this->_query .= ' FROM ' . $this->_entity->name();

        /** If there are relations like one to one, many to one or many to many */
        foreach ($fields as $value) {
            if ($value->foreign != null && in_array($value->foreign->type(), [ForeignKey::ONE_TO_ONE, ForeignKey::MANY_TO_ONE])) {
                $entity = $value->foreign->entity();
                $field = $value->foreign->field();
                $referenceEntity = $value->foreign->referenceEntity();
                $referenceField = $value->foreign->referenceField();
                $this->join($value->foreign->join(), $referenceEntity, $entity . '.' . $field . ' = ' . $field . '_' . $referenceEntity . '.' . $referenceField, $field);
            }
            else if ($value->foreign != null && in_array($value->foreign->type(), [ForeignKey::MANY_TO_MANY])) {
                //We add here two join (relation table and table linked)
                $currentEntity = $value->foreign->entity();
                $currentField = $this->_entity->primary();
                $referenceEntity = $value->foreign->referenceEntity();
                $referenceField = $value->foreign->referenceField();

                $current = strtolower($currentEntity . $currentField);
                $reference = strtolower($referenceEntity . $referenceField);
                $table = [$current, $reference];
                sort($table, SORT_STRING);
                $table = ucfirst($table[0] . $table[1]);

                $this->join($value->foreign->join(), $table, $table . '.' . $this->_entity->name() . '_' . $currentField . ' = ' . $this->_entity->name() . '.' . $currentField);
                $this->join($value->foreign->join(), $value->foreign->referenceEntity(), $table . '.' . $referenceEntity . '_' . $referenceField . ' = ' . $referenceEntity . '.' . $referenceField);
            }
        }
    }
985434
protected function getOptions()
	{
		$options = array();

		foreach ($this->element->children() as $option)
		{
			// Only add <option /> elements.
			if ($option->getName() != 'option')
			{
				continue;
			}

			// Create a new option object based on the <option /> element.
			$tmp = HtmlSelect::option(
				(string) $option['value'], trim((string) $option), 'value', 'text', ((string) $option['disabled'] == 'true')
			);

			// Set some option attributes.
			$tmp->class = (string) $option['class'];

			// Set some JavaScript option attributes.
			$tmp->onclick = (string) $option['onclick'];

			// Add the option object to the result set.
			$options[] = $tmp;
		}

		reset($options);

		return $options;
	}
656463
public function selectedChoices()
    {
        $val = $this->parsedVal();

        if ($val !== null) {
            if (!$this->p()->multiple()) {
                $val = [$val];
            }

            $choices = iterator_to_array(parent::choices());

            /* Filter the all options down to those selected */
            foreach ($val as $v) {
                if (isset($choices[$v])) {
                    yield $choices[$v];
                }
            }
        }
    }
624425
protected function getOptionsString()
    {
        $value   = $this->getValue();
        $options = '';
        if ($this->get('_first_option')) {
            $options .= sprintf('<option value="">%s</option>', $this->get('_first_option'));
        }
        $optionsList = $this->get('_options') ?: array();
        foreach ($optionsList as $k => $v) {
            $selected = '';
            // be flexible, accept a non-array value
            if ((is_string($value) && $k == $value) || (is_array($value) && in_array($k, $value))) {
                $selected = 'selected="selected"';
            }
            $options .= sprintf('<option value="%s" %s>%s</option>', htmlentities($k, ENT_COMPAT), $selected, $v);
        }

        return $options;
    }
469339
protected function renderSelect()
    {
        $options = $this->getOptions();

        $selectedExtensionStyle = '';

        $renderedOptionTags = [];
        foreach ($options as $option) {
            if (isset($option['selected']) && $option['selected'] === 'selected') {
                $selectedExtensionStyle = $option['style'];
            }
            if ($option['value'] === \Tx_Phpunit_Testable::ALL_EXTENSIONS) {
                $optionValue = $this->translate('all_extensions');
            } else {
                $optionValue = $option['value'];
            }
            $renderedOptionTags[] = $this->renderTag('option', $option, $optionValue);
        }

        return $this->renderTag(
            'select',
            [
                'name' => \Tx_Phpunit_Interface_Request::PARAMETER_NAMESPACE .
                    '[' . \Tx_Phpunit_Interface_Request::PARAMETER_KEY_TESTABLE . ']',
                'onchange' => 'document.location = \'' . $this->action . '&' .
                    \Tx_Phpunit_Interface_Request::PARAMETER_NAMESPACE .
                    '[' . \Tx_Phpunit_Interface_Request::PARAMETER_KEY_TESTABLE . ']=' .
                    '\'+this.options[this.selectedIndex].value;',
                'style' => $selectedExtensionStyle,
            ],
            implode(LF, $renderedOptionTags)
        );
    }
1285986
private JButton getSelectButton() {
		if (selectButton == null) {
			selectButton = new JButton();
			selectButton.setText(Constant.messages.getString("siteselect.button.select"));
			selectButton.setEnabled(false);	// Enabled when a node is selected
			selectButton.addActionListener(new java.awt.event.ActionListener() { 
				@Override
				public void actionPerformed(java.awt.event.ActionEvent e) {
					if (treeSite.getLastSelectedPathComponent() != null) {
						nodeSelected();
					} else if (treeContext.getLastSelectedPathComponent() != null) {
						contextSelected();
					}
				}
			});

		}
		return selectButton;
	}
854957
protected function getOptions()
	{
		$options = array();

		$select = new HtmlSelect;

		// Try to inject the text object into the field
		try
		{
			$select->setText($this->getText());
		}
		catch (\RuntimeException $exception)
		{
			// A Text object was not set, ignore the error and try to continue processing
		}

		/** @var \SimpleXMLElement $option */
		foreach ($this->element->children() as $option)
		{
			// Only add <option /> elements.
			if ($option->getName() != 'option')
			{
				continue;
			}

			// Create a new option object based on the <option /> element.
			$tmp = $select->option(
				(string) $option['value'], trim((string) $option), 'value', 'text', ((string) $option['disabled'] == 'true')
			);

			// Set some option attributes.
			$tmp->class = (string) $option['class'];

			// Set some JavaScript option attributes.
			$tmp->onclick = (string) $option['onclick'];

			// Add the option object to the result set.
			$options[] = $tmp;
		}

		reset($options);

		return $options;
	}
602762
public String selectedValue() {
        if (isNotPresentSelect()) {
            return null;
        }
        WebElement webElement = element.getWebElement();
        Select dropdown = new Select(webElement);
        WebElement option = dropdown.getFirstSelectedOption();
        return option.getAttribute(VALUE);
    }
159435
protected function runSelect()
    {
        return $this->connection->select(
            $this->toSql(), $this->getBindings(), ! $this->useWritePdo
        );
    }
904478
@Override
    public List<String> getOptions() throws WidgetException {
        try {
            Select select = new Select(getByLocator());
            return select.getOptions();
        } catch (Exception e) {
            throw new WidgetException("Error while fetching drop down options", getByLocator(), e);
        }
    }
2914
@SuppressWarnings("unchecked")
    public <T> T getSelect(final String _selectStmt)
        throws EFapsException
    {
        final OneSelect oneselect = this.selectStmt2OneSelect.get(_selectStmt);
        return oneselect == null ? null : (T) oneselect.getObject();
    }
506220
protected function checkSelect(){
        return $this->select = is_array($this->select) ? $this->select :  [$this->select];
    }
82785
public function getSelect() {
        if ($this->fields && $this->fields != '*' && (!(is_string($this->fields) && '*' == $this->fields[0] && 'END) AS `__parentRelationKey`' == substr($this->fields, -29)))) {
            if (is_string($this->fields)) {
                return $this->fields;
            }
            $columns = array();
            foreach ($this->fields as $field) { // @TODO: column generation here.
                $columns[] = trim($field);
            }
            return implode(', ', $columns);
        }
        if ((is_string($this->fields) && '*' == $this->fields[0] && 'END) AS `__parentRelationKey`' == substr($this->fields, -29))){
            return implode(', ', $this->getAllColumnsForSelect()) . substr($this->fields, 1);
        } else {
            return implode(', ', $this->getAllColumnsForSelect());
        }
    }
155331
public function selectOptionInChosenById($selectId, $option)
	{
		$chosenSelectID = $selectId . '_chzn';

		$this->debug("I open the $chosenSelectID chosen selector");
		$this->click(array('xpath' => "//div[@id='$chosenSelectID']/a/div/b"));
		$this->debug("I select $option");
		$this->click(array('xpath' => "//div[@id='$chosenSelectID']//li[text()='$option']"));

		// Gives time to chosen to close
		$this->wait(1);
	}
1136646
public function select($multiple = false)
	{
		if ( !$this->isSelected() ) {
			if ( $this->select === null ) {
				throw new SelectException(
					'No SELECT element association defined',
					SelectException::TYPE_UNBOUND_OPTION
				);
			}

			$this->select->getWrappedElement()->selectOption($this->getValue(), $multiple);
		}

		return $this;
	}
680575
public function getDbSelect()
    {
        if ($this->_dbSelect == null) {
            $this->_dbSelect = $this->_zendDb->select();
        }

        return $this->_dbSelect;
    }