-3

I'm unable to find drop-down list on webpage. Help to locate it and create the method for it. Following is the code -

<select name="equipment_type" class="smalltext0" onchange="return submitByFormNameAndAction('featureAddChangeForm','FeatureAddChangeValidateMobile.do')">
 <option class="device" selected="" value="P">iPhone</option>
 <option class="device" value="Z">Blackberry</option>
 <option class="device" value="3">Android</option>
</select>*
Vince Bowdren
  • 8,326
  • 3
  • 31
  • 56
Peter
  • 1
  • 1
  • Seriously, use internet next time. -1 http://sqa.stackexchange.com/questions/1355/what-is-the-correct-way-to-select-an-option-using-seleniums-python-webdriver – e1che May 01 '13 at 19:16

2 Answers2

1

Previous Answer + new stuff:

@Findby(css = "#id")
private Webelement selectElement;

public Select getPageSelectElement(){
  return new Select(selectElement);
}

Would be cool if we could get it directly from PageFactory though.

Jason Smiley
  • 289
  • 4
  • 12
0

You probably want something like this in your PageFactory:

@FindBy(how = How.NAME, using = "equipment_type")
WebElement selectElement

...

Select getPageSelectElement(){
    return new Select(selectElement);
}

You can then use the getPageSelectElement function to return a Select object from your page factory that can be used in your test.

Please note that the above is not code for a full page factory, just the bits you need to add to your page factory to find and return the Select element.

Ardesco
  • 7,281
  • 26
  • 49