i using page factory model in project, thus:
public class loginsingup { webdriver driver; public loginsingup(webdriver driver) { this.driver = driver; pagefactory.initelements(driver, this); } @findby(id="firstname") webelement fname; } how can identify drop down value in page factory. know way :
select country = new select(driver.findelement(by.id("selectedcountryid"))); country.selectbyvisibletext("united states"); but how in page factory. have created separate object repository package pages , created package test cases.
i have saved java classes in object repository. element drop down have write in java class , how can access in test cases.
add simple wrapper accessor around webelement accessor, this:
@findby(id="selectedcountryid") webelement countrydropdown; public select getcountryselect() { return new select(countrydropdown); } you can add helpful mutators too, (i've invented country class: might prefer pass ids around, or else):
public void setcountry(country country) { getcountryselect().selectbyvalue(country.getid()); }