function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
MattMet86MattMet86 

VF - How do you test apex:selectList ?

How do you simulate the action of changing the value in a selectlist element for a test class?
<apex:pageBlockSectionItem >
                            <apex:outputText value="Benefits Filter: " />
                            <apex:selectList value="{!benefitType}" size="1">
                                <apex:selectOptions value="{!benefitTypes}" />
                                <apex:actionSupport event="onchange" action="{!loadESBs}" rerender="Detail" status="status"/>
                            </apex:selectList>
                        </apex:pageBlockSectionItem>

 
Best Answer chosen by MattMet86
Pankaj_GanwaniPankaj_Ganwani
Hi Matt,

You can directly assign value to benefitType variable and then call the loadESBs() method in test class.

Like:

Suppose your controller is ABC:

ABC obj = new ABC();

obj.benefitType = 'value 1'
obj. loadESBs();// for one value

obj.benefitType = 'value 2'
obj. loadESBs();// for another value

and so on.

Thanks,
Pankaj