Unable to seelct a value from a dropdown

Before raising thishere, i have read all the related topics and tried all the possible options. But i couldnt able to sleect the value from the dropdwon
I can able to click the dropdown but not the selection of a value from it

Here with im sharing the UI and the HTML

my script is
WebUI.click(findTestObject(‘Page_Final - datahub/div_Choose your optionSurveyPollRecurring Survey Choose your option Survey’))

//java.util.List dropDownContents = WebUiCommonHelper.findWebElements(findTestObject(‘Object Repository/Page_Final - datahub/div_Choose your optionSurveyPollRecurring Survey Choose your option Survey’), 30)
//WebUI.waitForElementVisible(findTestObject(‘Page_Final - datahub/span_Survey’), 30)
//WebUI.selectOptionByValue(findTestObject(‘Page_Final - datahub/span_Survey’),‘Survey’,false)

WebUI.click(findTestObject(‘New Test Object’))

WebUI.click(findTestObject(‘Page_Final - datahub/button_Save (1)’))

Above i have commented all the ways which i have tried.
Object ‘Span_Survey’ → is recorded using Object Spy
NewTestObject- is i have created using id

My guess…

The HTML SELECT element is the host that transfers the selected OPTIONS( )when the page is submitted to the server. However, the element above the SELECT element is the element you need to automate and interact with:


Hi Anitha,

Another way, maybe, possibly, worth to try hehe is to get the XPath of any of the three option value

<option value="1">Survey</option>

It will return something like this with the index at the last part


option[1] = Survey
option[2] = Poll
option[3] = Recurring Survey

From there, remove the index of the XPATH, like this:


Then, create a new test object and make that XPATH as your locator

The purpose of removing that index is when the script runs and those three options are already visible in your website your code will automatically collect those three items.

How? refer to the code below. . .

//import webelement
import org.openqa.selenium.WebElement


This is the code that will collect those three items once it is already visible on your website. Since, you're getting their common locator "//*[@id='survery_type']/li/option" all of them will be stored in your list as an array.
//create a list
java.util.List<WebElement> dropDownItems = WebUiCommonHelper.findWebElements(findTestObject("The_testobject_I_mention_to_create"), 30)

//to check if it gets all the items.
println dropDownItems.text.toString()

//to execute an event, just use their index. . . .

[0] = Survey
[1] = Poll
[2] = Recurring survey

Hope that helps. . . :slight_smile: