如何使用String值修复dusk $ browser-> select()

I have a filter and one option is to choose a device-type. There is a list of possible options and you can only use one of the options (so no plain text)

The filter-field is named typ_id and can be accessed with

$browser->select('type_id') 

The variable which I want to use is called

$type_id = "Laptop"

So my first try was

$browser->select('type_id',$type_id)

but this does not work.

So just to check I used

$browser->select('type_id',1)

this works but is not an option as I want to use the String "Laptop" to choose the type.

This is a screenshot of the filter and the type html code:

Filter

How can I use "Laptop" (or $type_id) to choose the Laptop option?

The issue here is that you are interpreting the use of select(selectTagId, optionValue) incorrectly.

Your code works when you do select('type_id',1) because you are using the correct option value, and it does not work when you use select('type_id', 'Laptop') because "Laptop" is the Display text and not the option value.

so if you want to use select('type_id','Laptop'), you should update your option tags from <option value=1> to <option value="Laptop">