samedi 14 janvier 2017

Laravel testing unreachable field error when there is two forms in page

I want to test a page which has two forms in. When I want to test one of my forms the following error occurs:

Unreachable field "count"

Which count is a field in that form (it doesn't exit in the other form). When i remove the other form completely, it works correctly but I need to have both in the page.

It's my view:

    <section class="content">
        <div class="row">
            <div class="col-md-6">
                <div class="panel panel-green">
                    <div class="panel-heading">
                        <h3 class="panel-title">
                            Passenger Credit Adjustment
                        </h3>
                    </div>
                    <div class="panel-body">
                        <form method="post" action="">
                            
                            <div class="form-group">
                                <label for="amount">Name</label>
                                <input type="text" class="form-control" id="name" name="name" disabled="disabled"
                                       title="" value="">
                            </div>
                            <div class="form-group">
                                <label for="amount">Credit</label>
                                <input type="text" class="form-control" id="cashable" name="name" title=""
                                       disabled="disabled" value="">
                            </div>
                            <div class="form-group">
                                <label for="amount">Add/DeductAmount</label>
                                <input type="text" class="form-control" id="amount" name="amount">
                            </div>
                            <div class="form-group">
                                <label for="description">Description</label>
                                <input type="text" class="form-control" id="description" name="description">
                            </div>
                            <button type="submit" class="btn btn-danger">Apply</button>
                        </form>
                    </div>
                    <div class="panel-heading">
                        <h3 class="panel-title">
                            <i class="livicon" data-name="money" data-loop="true" data-color="#fff"
                               data-hovercolor="#fff" data-size="18"></i>
                            Voucher
                        </h3>
                    </div>
                    <div class="panel-body">
                        <form method="post"
                              action="">
                            
                            <div class="form-group">
                                <label for="type">Type</label>
                                <select id="single-prepend-text" class="form-control select2" title=""
                                        name="type">
                                    <option value="5k">5k</option>
                                    <option value="10k">10k</option>
                                    <option value="20k">20k</option>
                                    <option value="15p">15%</option>
                                    <option value="20p">20%</option>
                                    <option value="25p">25%</option>
                                    <option value="30p">30%</option>
                                    <option value="50p">50% (Max 10k)</option>
                                    <option value="100p">100% (Max 20k)</option>
                                </select>
                            </div>
                            <button type="submit" class="btn btn-danger" name="generate">Generate</button>
                        </form>
                    </div>
                </div>
            </div>

            <div class="col-md-6">
                <div class="panel panel-green">
                    <div class="panel-heading">
                        <h3 class="panel-title">
                            Free Ride
                        </h3>
                    </div>
                    <div class="panel-body">
                        <form method="post"
                              action="">
                            
                            <div class="form-group">
                                <label>Number of free ride(s):</label>
                                <input type="number" name="count" value="1" title="Count"  id="count"
                                       class="form-control">
                            </div>
                            <div class="form-group">
                                <label>Cap:</label>
                                <select class="form-control" name="cap" title="">
                                    <option value="">[NOT SELECTED]</option>
                                    <option value="50000">5,000 T</option>
                                    <option value="100000">10,000 T</option>
                                    <option value="150000">15,000 T</option>
                                    <option value="200000">20,000 T</option>
                                </select>
                            </div>
                            <input type="submit" class="btn btn-danger" name="generate" value="Generate">
                        </form>
                    </div>
                </div>
            </div>
        </div>

It's my test:

$this->visit($uri)
        ->type(3, 'count')
        ->select($cap, 'cap')
        ->press('Generate')

I'm using Laravel 5.1.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire