# Unable to select specific option from dropdown

**URL:** <https://forum.katalon.com/t/unable-to-select-specific-option-from-dropdown/21051>\
**Category:** Web Testing\
**Tags:** katalon-studio\
**Created:** [March 13, 2019, 6:12am UTC](https://forum.katalon.com/t/unable-to-select-specific-option-from-dropdown/21051 "2019-03-13T06:12:12Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![creta](https://avatars.discourse-cdn.com/v4/letter/c/a5b964/32.png) [@creta](https://forum.katalon.com/u/creta)\
**Post date:** [March 13, 2019, 6:12am UTC](https://forum.katalon.com/t/unable-to-select-specific-option-from-dropdown/21051/1 "2019-03-13T06:12:12Z")

</div>

Hi All,

I have a web application and One of our page consists Search and Sort dropdowns with a exact same options in it. Here when i try to select the option from search dropdown it actually selects option from sort dropdown.Some times it works but some times it doesn’t. So can anyone tell me how to select a specific option from dropdown? I had used “Selectoptionbyvalue” but here i have a “SPAN element” Not a “SELECT element”.Any other solution on this?

Here is the my Search dropdown UI looks like

 ![image](https://europe1.discourse-cdn.com/katalon/original/2X/3/373391bb94fb6483a75d23a0c4e9e10f20fd1f1e.png)

And HTML for the same looks like

 ![image](https://europe1.discourse-cdn.com/katalon/original/2X/b/b836da1fe8f2e64d91fb2f84c695c16a62b16ccd.png)

Awaitng for swift help!!  
Thank you

---

<div class="post-metadata">

**Author:** ![HeleneB](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/heleneb/32/2775_2.png) [@HeleneB](https://forum.katalon.com/u/HeleneB)\
**Post date:** [March 13, 2019, 8:25am UTC](https://forum.katalon.com/t/unable-to-select-specific-option-from-dropdown/21051/2 "2019-03-13T08:25:52Z")

</div>

Hi !  
Your select seems to be under the span element. Did you try click on span then selectOptionByValue on select ?

---

<div class="post-metadata">

**Author:** ![creta](https://avatars.discourse-cdn.com/v4/letter/c/a5b964/32.png) [@creta](https://forum.katalon.com/u/creta)\
**Post date:** [March 13, 2019, 9:25am UTC](https://forum.katalon.com/t/unable-to-select-specific-option-from-dropdown/21051/3 "2019-03-13T09:25:58Z")

</div>

Hi @HeleneB

I tried it but got an error. Please find below

 ![image](https://europe1.discourse-cdn.com/katalon/original/2X/9/9cedd6d74e58d0666418c86eaff6a639bc4e42cf.png)

My script is here

```
 WebUiBuiltInKeywords.delay(2)
WebUiBuiltInKeywords.click(findTestObject('Work order module/Search WO/Select dropdown'))

WebUiBuiltInKeywords.delay(2)

WebUiBuiltInKeywords.selectOptionByLabel(findTestObject('Work order module/Search WO/Select dropdown'), 'Class Name', 
    false)

WebUiBuiltInKeywords.delay(2)

```

Thank you

---

<div class="post-metadata">

**Author:** ![HeleneB](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/heleneb/32/2775_2.png) [@HeleneB](https://forum.katalon.com/u/HeleneB)\
**Post date:** [March 13, 2019, 9:58am UTC](https://forum.katalon.com/t/unable-to-select-specific-option-from-dropdown/21051/5 "2019-03-13T09:58:59Z")

</div>

> [@creta](#):
>
> WebUiBuiltInKeywords.click(**findTestObject(‘Work order module/Search WO/Select dropdown’)**) WebUiBuiltInKeywords.selectOptionByLabel(**findTestObject(‘Work order module/Search WO/Select dropdown’)**, ‘Class Name’, false)

You click and select on the same object, but you have to create a new object for the select

---

<div class="post-metadata">

**Author:** ![hpulsford](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/hpulsford/32/2985_2.png) [@hpulsford](https://forum.katalon.com/u/hpulsford)\
**Post date:** [March 13, 2019, 10:02am UTC](https://forum.katalon.com/t/unable-to-select-specific-option-from-dropdown/21051/6 "2019-03-13T10:02:03Z")

</div>

Yes like Helene said - your not actually selecting an option in your script - your just clicking on the drop down arrow again

---

<div class="post-metadata">

**Author:** ![creta](https://avatars.discourse-cdn.com/v4/letter/c/a5b964/32.png) [@creta](https://forum.katalon.com/u/creta)\
**Post date:** [March 13, 2019, 10:05am UTC](https://forum.katalon.com/t/unable-to-select-specific-option-from-dropdown/21051/7 "2019-03-13T10:05:01Z")

</div>

Hi

Can you show me how to create an object for select option?

Thank u

---

<div class="post-metadata">

**Author:** ![HeleneB](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/heleneb/32/2775_2.png) [@HeleneB](https://forum.katalon.com/u/HeleneB)\
**Post date:** [March 13, 2019, 10:15am UTC](https://forum.katalon.com/t/unable-to-select-specific-option-from-dropdown/21051/8 "2019-03-13T10:15:02Z")

</div>

Try to capture the object with ObjectSpy.

Or right click on Object repository, and create a new Test Object.  
Choose xpath in Selection Method, then on Selector editor, add

> //select[@class=‘pure-u-1 ng-pristine ng-valid ng-touched’]

Save and call this new object for the selectOption step

---

<div class="post-metadata">

**Author:** ![creta](https://avatars.discourse-cdn.com/v4/letter/c/a5b964/32.png) [@creta](https://forum.katalon.com/u/creta)\
**Post date:** [March 13, 2019, 10:36am UTC](https://forum.katalon.com/t/unable-to-select-specific-option-from-dropdown/21051/9 "2019-03-13T10:36:10Z")

</div>

> [@HeleneB](#):
>
> //select[@class=‘pure-u-1 ng-pristine ng-valid ng-touched’]

I created the new test object Still facing some error:(

Test Object

 ![image](https://europe1.discourse-cdn.com/katalon/original/2X/4/49b90593ae5b1795ec73c04e0d08fe937eda651d.png)

My Script is here

```
WebUiBuiltInKeywords.delay(2)
WebUiBuiltInKeywords.click(findTestObject('Work order module/Search WO/Select dropdown'))

WebUiBuiltInKeywords.delay(2)

WebUiBuiltInKeywords.selectOptionByLabel(findTestObject('New changes/Asset Plan/Select Option'), 'Class Name', false)

WebUiBuiltInKeywords.delay(2)

```

And Error showing something like this.

Unable to select option by label ‘Class Name’ of object ‘Object Repository/New changes/Asset Plan/Select Option’ using regular expression (Root cause: org.openqa.selenium.InvalidSelectorException: invalid selector: Unable to locate an element with the xpath expression because of the following error:  
SyntaxError: Failed to execute ‘evaluate’ on ‘Document’: The string ‘’ is not a valid XPath expression.  
(Session info: chrome=72.0.3626.121)  
(Driver info: chromedriver=2.35.528161 (5b82f2d2aae0ca24b877009200ced9065a772e73),platform=Windows NT 10.0.17763 x86\_64) (WARNING: The server did not provide any stacktrace information)  
Command duration or timeout: 0 milliseconds  
For documentation on this error, please visit: [http://seleniumhq.org/exceptions/invalid\_selector\_exception.html](http://seleniumhq.org/exceptions/invalid_selector_exception.html)  
Build info: version: ‘3.7.1’, revision: ‘8a0099a’, time: ‘2017-11-06T21:07:36.161Z’  
System info: host: ‘D’, ip: ‘99’, os.name: 'Windows ', os.arch: ‘am’, os.version: ‘10.0’, java.version: ‘1’  
Driver info: com.kms.katalon.core.webui.driver.ExistingRemoteWebDriver  
Capabilities {javascriptEnabled: true, platform: ANY, platformName: ANY}  
Session ID: e89b47ab505d8807ee9534cafd1e9472  
\*\*\* Element info: {Using=xpath, value=})

Thank you

---

<div class="post-metadata">

**Author:** ![hpulsford](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/hpulsford/32/2985_2.png) [@hpulsford](https://forum.katalon.com/u/hpulsford)\
**Post date:** [March 13, 2019, 10:38am UTC](https://forum.katalon.com/t/unable-to-select-specific-option-from-dropdown/21051/10 "2019-03-13T10:38:47Z")

</div>

Use the spy web tool - it will be much easier for you

Capture the option in the drop down that you want to select - save the object - then place this object in here

```auto
WebUiBuiltInKeywords.selectOptionByLabel(findTestObject('New changes/Asset Plan/Select Option'), 'Class Name', false)

```

---

<div class="post-metadata">

**Author:** ![creta](https://avatars.discourse-cdn.com/v4/letter/c/a5b964/32.png) [@creta](https://forum.katalon.com/u/creta)\
**Post date:** [March 13, 2019, 10:55am UTC](https://forum.katalon.com/t/unable-to-select-specific-option-from-dropdown/21051/11 "2019-03-13T10:55:22Z")

</div>

Hi

I tried this before and it says "Element should have been “select” but was “li” Cause captured object tag is “li”.

This the captured object

 ![image](https://europe1.discourse-cdn.com/katalon/original/2X/b/b5f8e3cf801c52a8596581088db3a37b013b6a40.png)

Script is here

```
     WebUiBuiltInKeywords.delay(2)
WebUiBuiltInKeywords.click(findTestObject('Work order module/Search WO/Select dropdown'))

WebUiBuiltInKeywords.delay(2)

WebUiBuiltInKeywords.selectOptionByLabel(findTestObject('New changes/Asset Plan/li_Class Name'), 'Class Name', false)

WebUiBuiltInKeywords.delay(2)

```

Regards!

---

<div class="post-metadata">

**Author:** ![hpulsford](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/hpulsford/32/2985_2.png) [@hpulsford](https://forum.katalon.com/u/hpulsford)\
**Post date:** [March 13, 2019, 10:56am UTC](https://forum.katalon.com/t/unable-to-select-specific-option-from-dropdown/21051/12 "2019-03-13T10:56:40Z")

</div>

ok then change it from WebUI.selectOptioByLabel to WebUI.click - see how that works

Also if i were you, i would change the delay step to

```auto
WebUiBuiltInKeywords.waitForElementVisible(findTestObject('New changes/Asset Plan/li_Class Name'), 'Class Name', false)
```

---

<div class="post-metadata">

**Author:** ![creta](https://avatars.discourse-cdn.com/v4/letter/c/a5b964/32.png) [@creta](https://forum.katalon.com/u/creta)\
**Post date:** [March 14, 2019, 12:13pm UTC](https://forum.katalon.com/t/unable-to-select-specific-option-from-dropdown/21051/13 "2019-03-14T12:13:44Z")

</div>

Hi

It Worked for me!! Thank You:)

---

<div class="post-metadata">

**Author:** ![januari](https://avatars.discourse-cdn.com/v4/letter/j/35a633/32.png) [@januari](https://forum.katalon.com/u/januari)\
**Post date:** [September 23, 2019, 8:58am UTC](https://forum.katalon.com/t/unable-to-select-specific-option-from-dropdown/21051/14 "2019-09-23T08:58:33Z")

</div>

How about if we have i dropdown list, but on my dropdown list we search first using text input then select?  
#help

---

<div class="post-metadata">

**Author:** ![hpulsford](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/hpulsford/32/2985_2.png) [@hpulsford](https://forum.katalon.com/u/hpulsford)\
**Post date:** [September 23, 2019, 12:10pm UTC](https://forum.katalon.com/t/unable-to-select-specific-option-from-dropdown/21051/15 "2019-09-23T12:10:53Z")

</div>

Raise a seperate topic with the behaviour your experiencing and ill take a look 🙂

---

<div class="post-metadata">

**Author:** ![januari](https://avatars.discourse-cdn.com/v4/letter/j/35a633/32.png) [@januari](https://forum.katalon.com/u/januari)\
**Post date:** [September 24, 2019, 2:46am UTC](https://forum.katalon.com/t/unable-to-select-specific-option-from-dropdown/21051/16 "2019-09-24T02:46:36Z")

</div>

Ohh I see, I think this same topic 🙂

I have UI like this,

 ![36](https://europe1.discourse-cdn.com/katalon/original/2X/e/eef566a8fa7e92be95a28fe0c53052f53e35ef96.png)

Reproduce:

- When a user clicks the select group, it will have a dropdown list. But also have text input. the cursor direct to text input.

---

<div class="post-metadata">

**Author:** ![acze3003](https://avatars.discourse-cdn.com/v4/letter/a/90db22/32.png) [@acze3003](https://forum.katalon.com/u/acze3003)\
**Post date:** [January 8, 2020, 7:39pm UTC](https://forum.katalon.com/t/unable-to-select-specific-option-from-dropdown/21051/17 "2020-01-08T19:39:33Z")

</div>

Hello guys,

I need help, I want to select an option but it fails to do so, because to select I do the following:

 ![image](https://europe1.discourse-cdn.com/katalon/original/2X/6/6717fd27e5baa5eab38f5c2106b92d29d5417f28.png)

 ![image](https://europe1.discourse-cdn.com/katalon/original/2X/3/3fcf8476a50c1c5deb57748f2ee5bbf0ed9a57a0.png)

The message you give me is this:

**Unable to find the element located by ‘By.xpath: //select[@id=‘ctl00\_ContentPlaceHolder\_NoAjax\_ddType\_ddControl’]’. Please recheck the objects properties to make sure the desired element is located.**

Log:

Test Cases/New Test Case FAILED.

Reason:

com.kms.katalon.core.exception.StepFailedException: Unable to select option by label ‘NA’ of object ‘Object Repository/DropDownObjects/Page\_P… G… S…/select\_NADriver LogsFuel ReceiptLumber ReceiptManifestShort pay approvalTrip Envelope’ using regular expression

at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.stepFailed(WebUIKeywordMain.groovy:64)

at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:26)

at com.kms.katalon.core.webui.keyword.builtin.SelectOptionByLabelKeyword.selectOptionByLabel(SelectOptionByLabelKeyword.groovy:98)

at com.kms.katalon.core.webui.keyword.builtin.SelectOptionByLabelKeyword.execute(SelectOptionByLabelKeyword.groovy:71)

at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:60)

at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.selectOptionByLabel(WebUiBuiltInKeywords.groovy:1200)

at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$selectOptionByLabel$5.call(Unknown Source)

at New Test Case.run(New Test Case:73)

at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)

at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)

at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:337)

at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:328)

at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:307)

at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:299)

at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:233)

at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:114)

at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:105)

at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)

at TempTestCase1578509476326.run(TempTestCase1578509476326.groovy:23)

Caused by: com.kms.katalon.core.webui.exception.WebElementNotFoundException: Web element with id: ‘Object Repository/DropDownObjects/Page\_P… G… S…/select\_NADriver LogsFuel ReceiptLumber ReceiptManifestShort pay approvalTrip Envelope’ located by ‘By.xpath: //select[@id=‘ctl00\_ContentPlaceHolder\_NoAjax\_ddType\_ddControl’]’ not found

at com.kms.katalon.core.webui.common.WebUiCommonHelper.findWebElement(WebUiCommonHelper.java:1113)

at com.kms.katalon.core.webui.keyword.internal.WebUIAbstractKeyword.findWebElement(WebUIAbstractKeyword.groovy:27)

at com.kms.katalon.core.webui.keyword.internal.WebUIAbstractKeyword.findWebElement(WebUIAbstractKeyword.groovy:26)

at com.kms.katalon.core.webui.keyword.builtin.SelectOptionByLabelKeyword$\_selectOptionByLabel\_closure1.doCall(SelectOptionByLabelKeyword.groovy:86)

at com.kms.katalon.core.webui.keyword.builtin.SelectOptionByLabelKeyword$\_selectOptionByLabel\_closure1.call(SelectOptionByLabelKeyword.groovy)

at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:20)

… 17 more

Thanks!

---

<div class="post-metadata">

**Author:** ![accuervo](https://avatars.discourse-cdn.com/v4/letter/a/858c86/32.png) [@accuervo](https://forum.katalon.com/u/accuervo)\
**Post date:** [January 17, 2020, 10:02pm UTC](https://forum.katalon.com/t/unable-to-select-specific-option-from-dropdown/21051/18 "2020-01-17T22:02:35Z")

</div>

HI

On many occasions it worked for me first to select the label corresponding to the drop-down list and then there is whether to display and select the option.

It is also good to note that the capture of objects is different when the recording method is used and when spy web is used

---

<div class="post-metadata">

**Author:** ![Brandon\_Hein](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/brandon_hein/32/1092_2.png) [@Brandon\_Hein](https://forum.katalon.com/u/Brandon_Hein)\
**Post date:** [January 17, 2020, 10:06pm UTC](https://forum.katalon.com/t/unable-to-select-specific-option-from-dropdown/21051/19 "2020-01-17T22:06:42Z")

</div>

> [@accuervo](#):
>
> On many occasions it worked for me first to select the label corresponding to the drop-down list and then there is whether to display and select the option.

This only works when the `<label>` is associated with the actual `<select>` element using the `for` attribute. For example:

```
<label id="some_label" for="some_select">Label Text</label>
<select id="some_select">
    <option>Option 1 Text</option>
    .
    .
    .
</select>

```

If the `<label>` doesn’t have a `for` attribute that references the `id` of the associated `<select>`, then clicking on the label will do nothing.

---

<div class="post-metadata">

**Author:** ![Russ\_Thomas](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/russ_thomas/32/11884_2.png) [@Russ\_Thomas](https://forum.katalon.com/u/Russ_Thomas)\
**Post date:** [May 25, 2022, 12:58pm UTC](https://forum.katalon.com/t/unable-to-select-specific-option-from-dropdown/21051/20 "2022-05-25T12:58:08Z")

</div>

Split this topic on May 25, 2022, 12:58pm UTC

2 posts were split to a new topic: [Select option from dropdown](https://forum.katalon.com/t/select-option-from-dropdown/65389)
