src/FakerContext.php
protected function fillForm(Element\NodeElement $form)
    {
        $inputs = $form->findAll('css', 'input[type="text"]');
        foreach ($inputs as $i)
        {
            /** @var  Element\NodeElement $i */
            if ($i->isVisible())
            {
                if ($i->hasAttribute('name'))
                {
                    $name = $i->getAttribute('name');
                    $value = $this->getFakerValue($name);
                }
                else
                {
                    $value = $this->faker()->text();
                }
                $i->setValue($value);
            }


        }

        $passwords = $form->findAll('css', 'input[type="password"]');
        $password = $this->faker()->password;
        foreach ($passwords as $p)
        {
            if ($p->isVisible())
            {
                $p->setValue($password);
            }
        }

        $selects = $form->findAll('css', 'select');
        foreach ($selects as $s)
        {
            /** @var  Element\NodeElement $s */
            if ($s->isVisible())
            {
                $s->selectOption($s->find('css', 'option')->getAttribute('name'));
            }
        }

        $checkboxes = $form->findAll('css', 'checkbox');
        foreach ($checkboxes as $c)
        {
            /** @var  Element\NodeElement $c */
            if ($c->isVisible())
            {
                $c->check();
            }
        }

        $radios = $form->findAll('css', 'input[type="radio"]');
        $radio_names = array();
        foreach ($radios as $r)
        {
            /** @var  Element\NodeElement $r */
            if ($r->isVisible())
            {
                if ($r->hasAttribute('name'))
                {
                    $name = $r->getAttribute('name');
                    if (!isset($radio_names[$name]))
                    {
                        $radio_names[$name] = true;
                        $r->click();
                    }
                }
            }
        }

    }
protected function fillForm(Element\NodeElement $form)
    {
        $inputs = $form->findAll('css', 'input[type="text"]');
        foreach ($inputs as $i)
        {
            /** @var  Element\NodeElement $i */
            if ($i->isVisible())
            {
                if ($i->hasAttribute('name'))
                {
                    $name = $i->getAttribute('name');
                    $value = $this->getFakerValue($name);
                }
                else
                {
                    $value = $this->faker()->text();
                }
                $i->setValue($value);
            }


        }

        $passwords = $form->findAll('css', 'input[type="password"]');
        $password = $this->faker()->password;
        foreach ($passwords as $p)
        {
            if ($p->isVisible())
            {
                $p->setValue($password);
            }
        }

        $selects = $form->findAll('css', 'select');
        foreach ($selects as $s)
        {
            /** @var  Element\NodeElement $s */
            if ($s->isVisible())
            {
                $s->selectOption($s->find('css', 'option')->getAttribute('name'));
            }
        }

        $checkboxes = $form->findAll('css', 'checkbox');
        foreach ($checkboxes as $c)
        {
            /** @var  Element\NodeElement $c */
            if ($c->isVisible())
            {
                $c->check();
            }
        }

        $radios = $form->findAll('css', 'input[type="radio"]');
        $radio_names = array();
        foreach ($radios as $r)
        {
            /** @var  Element\NodeElement $r */
            if ($r->isVisible())
            {
                if ($r->hasAttribute('name'))
                {
                    $name = $r->getAttribute('name');
                    if (!isset($radio_names[$name]))
                    {
                        $radio_names[$name] = true;
                        $r->click();
                    }
                }
            }
        }

    }
protected function fillForm ( Element \ NodeElement $ form ) { $ inputs = $ form -> findAll ( 'css' , 'input[type="text"]' ) ; foreach ( $ inputs as $ i ) { /** @var  Element\NodeElement $i */ if ( $ i -> isVisible ( ) ) { if ( $ i -> hasAttribute ( 'name' ) ) { $ name = $ i -> getAttribute ( 'name' ) ; $ value = $ this -> getFakerValue ( $ name ) ; } else { $ value = $ this -> faker ( ) -> text ( ) ; } $ i -> setValue ( $ value ) ; } } $ passwords = $ form -> findAll ( 'css' , 'input[type="password"]' ) ; $ password = $ this -> faker ( ) -> password ; foreach ( $ passwords as $ p ) { if ( $ p -> isVisible ( ) ) { $ p -> setValue ( $ password ) ; } } $ selects = $ form -> findAll ( 'css' , 'select' ) ; foreach ( $ selects as $ s ) { /** @var  Element\NodeElement $s */ if ( $ s -> isVisible ( ) ) { $ s -> selectOption ( $ s -> find ( 'css' , 'option' ) -> getAttribute ( 'name' ) ) ; } } $ checkboxes = $ form -> findAll ( 'css' , 'checkbox' ) ; foreach ( $ checkboxes as $ c ) { /** @var  Element\NodeElement $c */ if ( $ c -> isVisible ( ) ) { $ c -> check ( ) ; } } $ radios = $ form -> findAll ( 'css' , 'input[type="radio"]' ) ; $ radio_names = array ( ) ; foreach ( $ radios as $ r ) { /** @var  Element\NodeElement $r */ if ( $ r -> isVisible ( ) ) { if ( $ r -> hasAttribute ( 'name' ) ) { $ name = $ r -> getAttribute ( 'name' ) ; if ( ! isset ( $ radio_names [ $ name ] ) ) { $ radio_names [ $ name ] = true ; $ r -> click ( ) ; } } } } }
Fuzz fill all form fields with random data

@param Element\NodeElement $form
Fuzz fill all form fields with random data