How to select Dropdown value

During web testing, i select a value from the dropdown while recording but when i run that script, the value from the dropdown is not selected(picked) . How can i make it work? Please help.
Thanks!!!

@simran.kaur1 First check that the tag of the drop-down is a select. Also, does the drop-down have an arrow indicator. If the tag is a select, then you can use either:

WebUI.selectOptionByLabel(findTestObject(‘to’),‘text wanted’, false)

OR

WebUI.selectOptionByValue(findTestObject(‘to’),‘value attribute’, false)

Addendum1

You can verify the option was selected by using:

WebUI.verifyOptionSelectedByLabel(findTestObject(‘to’),‘selected text’, false, 10)

OR

WebUI.verifyOptionSelectedByValue(findTestObject(‘to’),‘selected value’, false, 10)

Addendum2

One other note is to check the drop-down text, or value, does not have any white space surrounding it. Look at the HTML code to check if a label is like: >LabelText< and not like > LabelText <

@simran.kaur1
Here is one example:
WebUI.selectOptionByValue(findTestObject(‘Object Repository/calculatortestcase3/Page_Refinance Calculator Home Mortgage Ca_7c1c11/select_10 - year fixed15 - year fixed20 - y_12cb38’),
‘10’, true)

Okay, your Test Object sample seems to be a select, but your reference of ‘10’ and true seem to be off.

The true means that you want to use Regular Expression, not standard comparison. I cannot see any reason to use RegEx since you are not using any expressions, so I suggest to change the true to false like I have in my example.

@grylion54
Ok thank you for info!:smiley: