I am new to Selenium and i am stuck in one implementation My requirements are
- Go to Settings page
- Look for the dropdown
- Fetch all values from dropdown
- Look for a certain text in dropdown
- If the text is not selected,Select the particular text in dropdown
My code is as follows
void setru() { driver.switchTo().frame("contentFrame"); Select rudropdown=new Select(driver.findElement(By.id("DefaultOrganisationDropDown"))); List<WebElement> drop=rudropdown.getOptions(); int e=drop.size(); for(int i=0;i<e;i++) { String temp=drop.get(i).getText(); String actual_RU="000139, NEXTRAN CORPORATION - JACKSONVILLE"; boolean flag=false; if(temp.contains("000139")) { flag=true; rudropdown.selectByValue("actual_RU"); } }
But this is giving me error message. org.openqa.selenium.NoSuchElementException: Cannot locate option with value: actual_RU