src/Concerns/InteractsWithElements.php
public function select($field, $value = null)
    {
        $element = $this->resolver->resolveForSelection($field);

        $options = $element->findElements(WebDriverBy::cssSelector('option:not([disabled])'));

        if (is_null($value)) {
            $options[array_rand($options)]->click();
        } else {
            foreach ($options as $option) {
                if ((string) $option->getAttribute('value') === (string) $value) {
                    $option->click();

                    break;
                }
            }
        }

        return $this;
    }
public function select($field, $value = null)
    {
        $element = $this->resolver->resolveForSelection($field);

        $options = $element->findElements(WebDriverBy::cssSelector('option:not([disabled])'));

        if (is_null($value)) {
            $options[array_rand($options)]->click();
        } else {
            foreach ($options as $option) {
                if ((string) $option->getAttribute('value') === (string) $value) {
                    $option->click();

                    break;
                }
            }
        }

        return $this;
    }
public function select ( $ field , $ value = null ) { $ element = $ this -> resolver -> resolveForSelection ( $ field ) ; $ options = $ element -> findElements ( WebDriverBy :: cssSelector ( 'option:not([disabled])' ) ) ; if ( is_null ( $ value ) ) { $ options [ array_rand ( $ options ) ] -> click ( ) ; } else { foreach ( $ options as $ option ) { if ( ( string ) $ option -> getAttribute ( 'value' ) === ( string ) $ value ) { $ option -> click ( ) ; break ; } } } return $ this ; }
Select the given value or random value of a drop-down field.

@param  string  $field
@param  string  $value
@return $this
Select the given value or random value of a drop - down field .