Select value in choice list

@param DocumentElement $page
@param string          $component
@param string          $field
@param string          $value
@throws \Exception
771344
private function selectComponentValue(DocumentElement $page, $component, $field, $value)
    {
        $select = $page->find('css', sprintf('#%s', $field));
        if (!$select) {
            throw new \Exception(sprintf('No select "%s" found', $field));
        }

        $selector = sprintf('.fs-%1$s button.fs-%1$s-item', $component);
        $choices  = $page->findAll('css', $selector);
        foreach ($choices as $choice) {
            if ($choice->getText() == $value) {
                $choice->click();
                return;
            }
        }

        throw new \Exception(sprintf('Value "%s" not found for "%s"', $value, $field));
    }
508176
public void selectField(ScreenField sfCurrent, int iSelectField)
    {
        ScreenField sField = this.getComponentAfter(sfCurrent, iSelectField);
        if (sField != null)
            sField.requestFocus();
    }
633523
function setSelectValue (elem, value) {
  var optionSet, option
  var options = elem.options
  var values = makeArray(value)
  var i = options.length

  while (i--) {
    option = options[ i ]
    /* eslint-disable no-cond-assign */
    if (values.indexOf(option.value) > -1) {
      option.setAttribute('selected', true)
      optionSet = true
    }
    /* eslint-enable no-cond-assign */
  }

  // Force browsers to behave consistently when non-matching value is set
  if (!optionSet) {
    elem.selectedIndex = -1
  }
}
1281035
private static function validateComp($component, $value, $min, $max)
    {
        if ($value < $min || $value > $max) {
            throw new Exception(
              "{$component} component {$value} must be {$min}-{$max}");
        }
    }
506511
private static function CreateElementary(DBInterfaces\IDatabaseConnection $connection, Selectable $field, Selectable $value, $operator)
    {
        return new self($connection, $field . ' ' . $operator .  ' ' . $value);
    }
1053645
public function assertRadioNotSelected($field, $value = null)
    {
        $element = $this->resolver->resolveForRadioSelection($field, $value);

        PHPUnit::assertFalse(
            $element->isSelected(),
            "Radio [{$field}] was unexpectedly selected."
        );

        return $this;
    }
122258
public function selectBy($field, $value, $table = null)
	{
		if(null === $table)
		{
			$table = $this->tableName();
		}
		return $this->where(array((false === $table ? '' : ($table . '.')) . $field=>$value))->select();
	}
306078
public static function selectDocument($id) 
    {
        $id = self::getDocumentID($id);
        self::debug("Selecting document '$id' as default one");
        self::$defaultDocumentID = self::getDocumentID($id);
    }
203908
public function vueAttribute($componentSelector, $key)
    {
        $fullSelector = $this->resolver->format($componentSelector);

        return $this->driver->executeScript(
            "return document.querySelector('".$fullSelector."').__vue__.".$key
        );
    }
1034335
public function setElementBy($element, $value, $nodeValue)
    {
        $xql = "//*[@$element='$value']";

        if (is_object($nodeValue)) {
            $result = $this->query($xql)->item(0)->appendChild($this->importNode($nodeValue, true));
        } else {
            $result = $this->query($xql)->item(0)->nodeValue = $nodeValue;
        }

        return $result;
    }
248812
public static function setDOMElementValue(DOMElement $element, $value)
    {
        switch (gettype($value)) {
            case 'boolean':
                $element->nodeValue = ($value === true) ? 'true' : 'false';
            break;

            default:
                $element->nodeValue = $value;
            break;
        }
    }
1012273
public static void setProperty(Object obj, String prop, Object value) throws PageException {
	boolean done = false;
	try {
	    if (setField(obj, prop, value)) done = true;
	}
	catch (Throwable t) {
	    ExceptionUtil.rethrowIfNecessary(t);
	}
	if (!done) callSetter(obj, prop, value);
    }
785621
protected static function LT(DBInterfaces\IDatabaseConnection $connection, Selectable $field, Selectable $value)
    {
        $op = '<';
        return self::CreateElementary($connection, $field, $value, $op);
    }
475503
public static function update_inplace_editable($component, $itemtype, $itemid, $value) {
        global $PAGE;
        // Validate and normalize parameters.
        $params = self::validate_parameters(self::update_inplace_editable_parameters(),
                      array('component' => $component, 'itemtype' => $itemtype, 'itemid' => $itemid, 'value' => $value));
        if (!$functionname = component_callback_exists($component, 'inplace_editable')) {
            throw new \moodle_exception('inplaceeditableerror');
        }
        $tmpl = component_callback($params['component'], 'inplace_editable',
            array($params['itemtype'], $params['itemid'], $params['value']));
        if (!$tmpl || !($tmpl instanceof \core\output\inplace_editable)) {
            throw new \moodle_exception('inplaceeditableerror');
        }
        return $tmpl->export_for_template($PAGE->get_renderer('core'));
    }
686698
@Override
    public void setValue(Object value) throws WidgetException {
        try {
            if (value instanceof String) {
                boolean selected = false;
                List<WebElement> elements = findElements();
                for (WebElement we : elements) {
                    if (we.getAttribute("value").equals(value)) {
                        we.click();
                        selected = true;
                        break;
                    }
                }

                if (!selected)
                    throw new WidgetException("Could not find desired option to select",
                            getLocator());
            } else {
                throw new WidgetException("Invalid type. 'value' must be a 'String' type of desired option to select",
                        getLocator());
            }
        } catch (Exception e) {
            throw new WidgetException("Error while selecting option on radio group", getLocator(),
                    e);
        }
    }
50708
public void init(PageContext pageContext, ComponentPageImpl componentPage, boolean executeConstr) throws PageException {
	this.pageSource = componentPage.getPageSource();

	// extends
	if (!StringUtil.isEmpty(properties.extend)) {
	    base = ComponentLoader.searchComponent(pageContext, componentPage.getPageSource(), properties.extend, Boolean.TRUE, null, true, executeConstr);
	}
	else {
	    CIPage p = ((ConfigWebImpl) pageContext.getConfig()).getBaseComponentPage(pageSource.getDialect(), pageContext);
	    if (!componentPage.getPageSource().equals(p.getPageSource())) {
		base = ComponentLoader.loadComponent(pageContext, p, "Component", false, false, true, executeConstr);
	    }
	}

	if (base != null) {
	    this.dataMemberDefaultAccess = base.dataMemberDefaultAccess;
	    this._static = new StaticScope(base._static, this, componentPage, dataMemberDefaultAccess);
	    // this._triggerDataMember=base._triggerDataMember;
	    this.absFin = base.absFin;
	    _data = base._data;
	    _udfs = new HashMapPro<Key, UDF>(base._udfs);
	    setTop(this, base);
	}
	else {
	    this.dataMemberDefaultAccess = pageContext.getCurrentTemplateDialect() == CFMLEngine.DIALECT_CFML ? pageContext.getConfig().getComponentDataMemberDefaultAccess()
		    : Component.ACCESS_PRIVATE;
	    this._static = new StaticScope(null, this, componentPage, dataMemberDefaultAccess);
	    // TODO get per CFC setting
	    // this._triggerDataMember=pageContext.getConfig().getTriggerComponentDataMember();
	    _udfs = new HashMapPro<Key, UDF>();
	    _data = MapFactory.getConcurrentMap();
	}
	// implements
	if (!StringUtil.isEmpty(properties.implement)) {
	    if (absFin == null) absFin = new AbstractFinal();
	    absFin.add(InterfaceImpl.loadInterfaces(pageContext, getPageSource(), properties.implement));
	    // abstrCollection.implement(pageContext,getPageSource(),properties.implement);
	}

	/*
	 * print.e("--------------------------------------"); print.e(_getPageSource().getDisplayPath());
	 * print.e(abstrCollection.getUdfs());
	 */

	// scope
	useShadow = base == null ? (pageSource.getDialect() == CFMLEngine.DIALECT_CFML ? pageContext.getConfig().useComponentShadow() : false) : base.useShadow;
	if (useShadow) {
	    if (base == null) scope = new ComponentScopeShadow(this, MapFactory.getConcurrentMap());
	    else scope = new ComponentScopeShadow(this, (ComponentScopeShadow) base.scope, false);
	}
	else {
	    scope = new ComponentScopeThis(this);
	}
	initProperties();

	// invoke static constructor
	if (!componentPage._static.isInit()) {
	    componentPage._static.setInit(true);// this needs to happen before the call
	    try {
		componentPage.staticConstructor(pageContext, this);
	    }
	    catch (Throwable t) {
		ExceptionUtil.rethrowIfNecessary(t);
		componentPage._static.setInit(false);
		throw Caster.toPageException(t);
	    }
	}
    }
844789
public function rowExists($field, $value)
    {
        $this->addWhere($field, $value);

        try {
            $this->selectOne();

            return true;
        } catch (ExceptionNoData $exception) {
            return false;
        }
    }