public function appendField($field, $value)
    {
        $el = $this->findField($field);

        switch ($el->getTagName()) {
            //Multiple select
            case "select":
                $matched = false;
                $wdSelect = new WebDriverSelect($el);
                try {
                    $wdSelect->selectByVisibleText($value);
                    $matched = true;
                } catch (NoSuchElementException $e) {
                    // exception treated at the end
                }

                try {
                    $wdSelect->selectByValue($value);
                    $matched = true;
                } catch (NoSuchElementException $e) {
                    // exception treated at the end
                }
                if ($matched) {
                    return;
                }

                throw new ElementNotFound(json_encode($value), "Option inside $field matched by name or value");
            case "textarea":
                $el->sendKeys($value);
                return;
            case "div": //allows for content editable divs
                $el->sendKeys(WebDriverKeys::END);
                $el->sendKeys($value);
                return;
            //Text, Checkbox, Radio
            case "input":
                $type = $el->getAttribute('type');

                if ($type == 'checkbox') {
                    //Find by value or css,id,xpath
                    $field = $this->findCheckable($this->getBaseElement(), $value, true);
                    if (!$field) {
                        throw new ElementNotFound($value, "Checkbox or Radio by Label or CSS or XPath");
                    }
                    if ($field->isSelected()) {
                        return;
                    }
                    $field->click();
                    return;
                } elseif ($type == 'radio') {
                    $this->selectOption($field, $value);
                    return;
                }

                $el->sendKeys($value);
                return;
        }

        throw new ElementNotFound($field, "Field by name, label, CSS or XPath");
    }
public function appendField($field, $value)
    {
        $el = $this->findField($field);

        switch ($el->getTagName()) {
            //Multiple select
            case "select":
                $matched = false;
                $wdSelect = new WebDriverSelect($el);
                try {
                    $wdSelect->selectByVisibleText($value);
                    $matched = true;
                } catch (NoSuchElementException $e) {
                    // exception treated at the end
                }

                try {
                    $wdSelect->selectByValue($value);
                    $matched = true;
                } catch (NoSuchElementException $e) {
                    // exception treated at the end
                }
                if ($matched) {
                    return;
                }

                throw new ElementNotFound(json_encode($value), "Option inside $field matched by name or value");
            case "textarea":
                $el->sendKeys($value);
                return;
            case "div": //allows for content editable divs
                $el->sendKeys(WebDriverKeys::END);
                $el->sendKeys($value);
                return;
            //Text, Checkbox, Radio
            case "input":
                $type = $el->getAttribute('type');

                if ($type == 'checkbox') {
                    //Find by value or css,id,xpath
                    $field = $this->findCheckable($this->getBaseElement(), $value, true);
                    if (!$field) {
                        throw new ElementNotFound($value, "Checkbox or Radio by Label or CSS or XPath");
                    }
                    if ($field->isSelected()) {
                        return;
                    }
                    $field->click();
                    return;
                } elseif ($type == 'radio') {
                    $this->selectOption($field, $value);
                    return;
                }

                $el->sendKeys($value);
                return;
        }

        throw new ElementNotFound($field, "Field by name, label, CSS or XPath");
    }
public function appendField ( $ field , $ value ) { $ el = $ this -> findField ( $ field ) ; switch ( $ el -> getTagName ( ) ) { //Multiple select case "select" : $ matched = false ; $ wdSelect = new WebDriverSelect ( $ el ) ; try { $ wdSelect -> selectByVisibleText ( $ value ) ; $ matched = true ; } catch ( NoSuchElementException $ e ) { // exception treated at the end } try { $ wdSelect -> selectByValue ( $ value ) ; $ matched = true ; } catch ( NoSuchElementException $ e ) { // exception treated at the end } if ( $ matched ) { return ; } throw new ElementNotFound ( json_encode ( $ value ) , "Option inside $field matched by name or value" ) ; case "textarea" : $ el -> sendKeys ( $ value ) ; return ; case "div" : //allows for content editable divs $ el -> sendKeys ( WebDriverKeys :: END ) ; $ el -> sendKeys ( $ value ) ; return ; //Text, Checkbox, Radio case "input" : $ type = $ el -> getAttribute ( 'type' ) ; if ( $ type == 'checkbox' ) { //Find by value or css,id,xpath $ field = $ this -> findCheckable ( $ this -> getBaseElement ( ) , $ value , true ) ; if ( ! $ field ) { throw new ElementNotFound ( $ value , "Checkbox or Radio by Label or CSS or XPath" ) ; } if ( $ field -> isSelected ( ) ) { return ; } $ field -> click ( ) ; return ; } elseif ( $ type == 'radio' ) { $ this -> selectOption ( $ field , $ value ) ; return ; } $ el -> sendKeys ( $ value ) ; return ; } throw new ElementNotFound ( $ field , "Field by name, label, CSS or XPath" ) ; }
Append the given text to the given element.
Can also add a selection to a select box.

``` php
<?php
$I->appendField('#mySelectbox', 'SelectValue');
$I->appendField('#myTextField', 'appended');
?>
```

@param string $field
@param string $value
@throws \Codeception\Exception\ElementNotFound
Append the given text to the given element . Can also add a selection to a select box .