0

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?

Bilaal Rashid
  • 828
  • 2
  • 13
  • 21
  • Possible duplicate of [Select an option based on text in drop-down with Laravel Dusk](https://stackoverflow.com/questions/51082201/select-an-option-based-on-text-in-drop-down-with-laravel-dusk) – Jonas Staudenmeir Apr 07 '19 at 00:37

1 Answers1

1

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">

Ian Preglo
  • 421
  • 2
  • 10