I am new in Phpunit and selenium2.

Need help to get all the values of drop-down in a list.

<select id="month" class="_5dba" title="Month" name="birthday_month" aria-label="Month">
  <option selected="1" value="0">Month</option>
  <option value="1">Jan</option>
  <option value="2">Feb</option>
  <option value="3">Mar</option>
  <option value="4">Apr</option>
  <option value="5">May</option>
  <option value="6">Jun</option>
  <option value="7">Jul</option>
  <option value="8">Aug</option>
  <option value="9">Sep</option>
  <option value="10">Oct</option>
  <option value="11">Nov</option>
  <option value="12">Dec</option>

so, values that should be in the list are : jan, feb, .....

  • I am trying to do this as well, but first I would like to count the selections, and if possible return the results. For testing purposes I feel it would be best to allow for changes made in large dropdown lists by simply counting and returning all the possible values (then I can select one randomly). It seems odd that I cannot find any methods for doing this. Commented May 23, 2017 at 21:09

2 Answers 2


This is the way as per the link



$this->select("month", "label=Option label");
$this->select("month", "value=Option value"); 
$this->select("month", "id=Option id"); 
$this->select("month", "index=Option index"); 

I see 2 ways:

$options = array('1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12');

foreach ($options as $option) {




for ($i = 0; $i < 12; $i++ ) {



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.