How to Select a drop down value Based on a variable IN TestNG

How to Select a drop down value Based on a variable

I want to select a drop down  { year month  date } in Facebook Sign up page with the value from the excel sheet 

Am having a @Test method which reads the data from the Data Provider and use it in the webpage

Test(dataProvider =”excelRead” )
public void faceBook( String FirstName ,String LastName, String email, String Password, String Month, String day , String year , String sex) throws InterruptedException

String Month, String day , String year   – which gives the value for the dropdown to choose,
following method didn’t do anything

could you please suggest me a way to solve  this issue

Default Asked on July 13, 2015 in Selenium WebDriver.
Add Comment
  • 1 Answer(s)
    Best answer

    Hi, there are three different methods how to do it

    WebElement month = driver.findElement(“month”));
    Select select = new Select(month);

    WebElement day = driver.findElement(“day”));
    Select selectDay = new Select(day);

    WebElement year = driver.findElement(“year”));
    Select selectYear = new Select(year);

    Wait for feedback.

    Reviewer Answered on July 13, 2015.

    Thanks Victor  for the Valuable solution

    on July 15, 2015.
    Add Comment
  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.