0
votes

How to validate dropdown field using Java? For Example, we have dropdown A & dropdown B, in that if I select any of the option in dropdown A and the selected option has the value in Dropdown B. So, whenever if I select the dropdown A option the saved one in dropdown b should selected. How can I handle the above solution using selenium webdrive? Kindly provide me the solution.

1
I created the excel read script which is to get the set of data and when i execute parameter script the first dropdown value is picking but the second dropdown is not picking from Excel. - Raghav Vendran
Share your relevant code. - Ajinkya
1. JavascriptExecutor js = (JavascriptExecutor)driver; js.executeScript("document.getElementById('projbox1').style.display='block'"); new Select(driver.findElement(By.id("projbox1"))).selectByVisibleText(oExcel.getCellData("projbox1",3)); - Raghav Vendran
2. JavascriptExecutor js1 = (JavascriptExecutor)driver; js1.executeScript("document.getElementById('campbox1').style.display='block'"); new Select(driver.findElement(By.id("campbox1"))).selectByVisibleText(oExcel.getCellData("campbox1",3)); - Raghav Vendran
Both the dropdown has the relation with each other. For example In the country dropdown if you select India. After selecting you will get the city name which is under India in another dropdown. So, i need to handle to get the dropdown values. - Raghav Vendran

1 Answers

0
votes

Try to use selenium.Support library. Its have Select element and features of work with dropdowns. As selection another option/value, selecting of several options/values, clear selection and lot of another.

Details you will find here: http://selenium.googlecode.com/git/docs/api/java/org/openqa/selenium/support/ui/Select.html