Select Value from Drop Down (WebDriver) - Bug Reaper

                  Bug Reaper

Lean about Automation Testing,Selenium WebDriver,RestAssured,Appium,Jenkins,JAVA,API Automation,TestNG,Maven, Rest API, SOAP API,Linux,Maven,Security Testing,Interview Questions

Monday 23 September 2013

Select Value from Drop Down (WebDriver)

Snippet for Selecting Value from Drop Down


1.)Select selectData=new Select(element);
selectData.deselectAll();
selectData.selectByValue("Education Organization");


2.)WebElement sec_ques1 = driver.findElement(By.id("securityQuestion_1"));
Select selectsec_ques1 = new Select(sec_ques1);
selectsec_ques1.selectByValue("What is your Pet's name?");


Example" 

<option value = "MD">MD</option>
<option value="prog">Programmer</option>



dropdown.selectByVisibleText("Programmer ");
or
dropdown.selectByIndex(1);
or

 dropdown.selectByValue("prog")

No comments:

Post a Comment