Dusk testing a < select > field just doesn't work

Posted 3 months ago by lyleyboy

Hi folks,

I'm hoping this is pretty straight forward but I'm using Dusk to test creating a new user (there are a few extra fields compared to the standard)

One field on the form is

<select name="campaign_id" id="campaign_id"
                                    class="ftna_campaign_id form-control {{ $errors->has('campaign_id') ? ' is-invalid' : '' }}">

                                <option value="">-- Please Select --</option>
                                @foreach($campaigns as $campaign)
                                    <option value="{{ $campaign->id }}">{{ $campaign->name }}</option>


When I run the dusk test, it fills out all the other fields but this one. The test fails and states that it can't get to the submitted page because the Request catches the fact that the campaign_id isn't set.

I've tried all sorts to get it to work but this is what I have tried

->select('.ftna_campaign_id', 1)

->select('campaign_id', 1)

->select('campaign_id', 'Campaign Name')

Does anyone have any thoughts? Thanks

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.