# Not able pick a value from a drop down list

**URL:** <https://forum.katalon.com/t/not-able-pick-a-value-from-a-drop-down-list/41400>\
**Category:** Web Testing\
**Tags:** katalon-studio\
**Created:** [March 23, 2020, 8:31pm UTC](https://forum.katalon.com/t/not-able-pick-a-value-from-a-drop-down-list/41400 "2020-03-23T20:31:16Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![upendras](https://avatars.discourse-cdn.com/v4/letter/u/7ab992/32.png) [@upendras](https://forum.katalon.com/u/upendras)\
**Post date:** [March 23, 2020, 8:31pm UTC](https://forum.katalon.com/t/not-able-pick-a-value-from-a-drop-down-list/41400/1 "2020-03-23T20:31:16Z")

</div>

Hi,  
I was trying to select a value from drop down list with help of selectOptionByIndex method but it was not successful.It is not also clicking that element with simple WebUI.Click method.  
I tried different options but all in Vain.could you please help me on this .  
Screenshot attached.  
katalon unable to capture the list of values available in the list.Only it capture the parent element(Location).  
The attribute of the element is //\*[@name = ‘pt1:contentAreaReg:0:tabrg1:2:soc1’ and @id = ‘pt1:contentAreaReg:0:tabrg1:2:soc1::content’].

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

---

<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:** [March 23, 2020, 9:23pm UTC](https://forum.katalon.com/t/not-able-pick-a-value-from-a-drop-down-list/41400/2 "2020-03-23T21:23:46Z")

</div>

`selectOptionByIndex` will only work if the element is a `<select>` element.

My guess is that you are working with some kind of `<input>` element here. Please share the HTML for the dropdown and surrounding elements so that we can provide a solution.

---

<div class="post-metadata">

**Author:** ![upendras](https://avatars.discourse-cdn.com/v4/letter/u/7ab992/32.png) [@upendras](https://forum.katalon.com/u/upendras)\
**Post date:** [March 24, 2020, 4:55pm UTC](https://forum.katalon.com/t/not-able-pick-a-value-from-a-drop-down-list/41400/3 "2020-03-24T16:55:14Z")

</div>

![image](https://europe1.discourse-cdn.com/katalon/original/2X/0/033b89f1125fc64ed456ad57dc94fd1ea9e2b66c.png)  
Not able to capture the elements present in the drop down list

---

<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:** [March 24, 2020, 4:59pm UTC](https://forum.katalon.com/t/not-able-pick-a-value-from-a-drop-down-list/41400/4 "2020-03-24T16:59:32Z")

</div>

Being so selective about what you’re choosing to reveal about the HTML is not helpful to us. If you really expect us to help, show **all** of that HTML

From looking at your image, I suspect some tinkering with the styles to reveal a (perhaps) hidden select element.

Please, make a clear statement about what you want to achieve and show the elements you expect to be targeted by the test code.

---

<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:** [March 24, 2020, 9:55pm UTC](https://forum.katalon.com/t/not-able-pick-a-value-from-a-drop-down-list/41400/5 "2020-03-24T21:55:11Z")

</div>

As Russ mentioned, we need to see all of the elements involved. In general, it’s useful to see at least:

1.) The target element,  
2.) the parent or first few ancestors of the element, and  
3.) all children or first few descendants of the target element.

Thanks

---

<div class="post-metadata">

**Author:** ![DummyAutomation](https://avatars.discourse-cdn.com/v4/letter/d/278dde/32.png) [@DummyAutomation](https://forum.katalon.com/u/DummyAutomation)\
**Post date:** [March 25, 2020, 6:08pm UTC](https://forum.katalon.com/t/not-able-pick-a-value-from-a-drop-down-list/41400/6 "2020-03-25T18:08:42Z")

</div>

I can see that this is probably an Outsystem web application. Sometimes u need to create the xpath manualy.

Note that you need to do like //parent[]/child/child/select[@name]. Because the way you do some times it may exist more then one select object with the same @name attribut

---

<div class="post-metadata">

**Author:** ![upendras](https://avatars.discourse-cdn.com/v4/letter/u/7ab992/32.png) [@upendras](https://forum.katalon.com/u/upendras)\
**Post date:** [March 26, 2020, 5:47pm UTC](https://forum.katalon.com/t/not-able-pick-a-value-from-a-drop-down-list/41400/7 "2020-03-26T17:47:33Z")

</div>

[HTML Code for location field…

---

<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:** [March 26, 2020, 5:50pm UTC](https://forum.katalon.com/t/not-able-pick-a-value-from-a-drop-down-list/41400/8 "2020-03-26T17:50:46Z")

</div>

Sorry, this is not the HTML code. you had it right in your previous post, we just need to see **more elements**.

---

<div class="post-metadata">

**Author:** ![upendras](https://avatars.discourse-cdn.com/v4/letter/u/7ab992/32.png) [@upendras](https://forum.katalon.com/u/upendras)\
**Post date:** [March 27, 2020, 2:24pm UTC](https://forum.katalon.com/t/not-able-pick-a-value-from-a-drop-down-list/41400/9 "2020-03-27T14:24:29Z")

</div>

This is all the elements available in the below window.

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

The HTML codes for all the elements attached herewith.[Cretae PO elements.txt](https://forum.katalon.com/uploads/short-url/8ZwU8v6HjXho8cEGnYiimuEdTrY.txt) (1.9 KB)

---

<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:** [March 27, 2020, 5:06pm UTC](https://forum.katalon.com/t/not-able-pick-a-value-from-a-drop-down-list/41400/10 "2020-03-27T17:06:28Z")

</div>

Sorry, you’re really not getting me. I think you are confused by what an **element** is. For the purposes of this discussion, an element is anything in the HTML code that starts with “\<” and ends with “\>”.

What you are asking about is specifically the “Location” field, and how to select an option from the drop-down associated with that field. This drop-down is represented by the `<select>` **element** that you’ve shared in this screenshot:

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

What we need to see in addition to this `<select>` element is:

1.) The parent of this element:

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

2.) The children of this element. Click the arrow to expand the element and view the children:

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

---

<div class="post-metadata">

**Author:** ![upendras](https://avatars.discourse-cdn.com/v4/letter/u/7ab992/32.png) [@upendras](https://forum.katalon.com/u/upendras)\
**Post date:** [March 28, 2020, 4:33pm UTC](https://forum.katalon.com/t/not-able-pick-a-value-from-a-drop-down-list/41400/11 "2020-03-28T16:33:24Z")

</div>

[Cretae PO elements-1.txt](https://forum.katalon.com/uploads/short-url/4QSmBlvxfsG58VUnLlmsjsbNyl2.txt) (497 Bytes)

Hi ,  
If you check the previous file i have already attached parent and child element in a single line.  
Anyway i am adding in a separate file in HTML format .Hope this is the details you want.  
plz check this.

---

<div class="post-metadata">

**Author:** ![upendras](https://avatars.discourse-cdn.com/v4/letter/u/7ab992/32.png) [@upendras](https://forum.katalon.com/u/upendras)\
**Post date:** [March 30, 2020, 10:56am UTC](https://forum.katalon.com/t/not-able-pick-a-value-from-a-drop-down-list/41400/12 "2020-03-30T10:56:03Z")

</div>

Any suggestion?

---

<div class="post-metadata">

**Author:** ![DummyAutomation](https://avatars.discourse-cdn.com/v4/letter/d/278dde/32.png) [@DummyAutomation](https://forum.katalon.com/u/DummyAutomation)\
**Post date:** [March 30, 2020, 11:31am UTC](https://forum.katalon.com/t/not-able-pick-a-value-from-a-drop-down-list/41400/13 "2020-03-30T11:31:18Z")

</div>

I did face an problem like this. And my solution was to go back to its parent

- Solution 1: //parent//child/child/child/child/select etc. this worked for me.

- Solution 2: I needed to first click its arrow first and then select the value.

- Solution 3: the fastest way is to create a custom keyword.

Test in Chrome console if you xpath is correct etc.

---

<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:** [March 30, 2020, 3:38pm UTC](https://forum.katalon.com/t/not-able-pick-a-value-from-a-drop-down-list/41400/14 "2020-03-30T15:38:57Z")

</div>

Try this:

```
WebDriver driver = DriverFactory.getWebDriver()
WebElement element = findElement(By.xpath("//label[text()='Location']/preceding-sibling::select"))
Select select = new Select(element)
select.selectByIndex(5)

```

If that doesn’t work, then from looking at the HTML, I suspect you are working with a React front end, in which case we may need to do some clever clicking.

---

<div class="post-metadata">

**Author:** ![upendras](https://avatars.discourse-cdn.com/v4/letter/u/7ab992/32.png) [@upendras](https://forum.katalon.com/u/upendras)\
**Post date:** [April 10, 2020, 9:27am UTC](https://forum.katalon.com/t/not-able-pick-a-value-from-a-drop-down-list/41400/15 "2020-04-10T09:27:08Z")

</div>

Hi Bradon ,  
Sorry for the late reply.  
I tried this set of code but i am not able to run the script .  
As this selenium code , i have added the import code import com.kms.katalon.core.webui.driver.DriverFactory as DriverFactory  
and tried run the script but after adding the piece of code , the script is not running at all.

As i am new to katalon , so i am not able to rectify the errors.  
Errors as mentioned below.  
Reason:  
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:  
file:/C:/Users/Public/Documents/Projects/Katalon%20Studio/RMS/Scripts/Create%20PO/Script1584964253873.groovy: 64: unable to resolve class WebDriver  
@ line 64, column 15.  
WebDriver driver = DriverFactory.getWebDriver()  
^

file:/C:/Users/Public/Documents/Projects/Katalon%20Studio/RMS/Scripts/Create%20PO/Script1584964253873.groovy: 65: unable to resolve class WebElement  
@ line 65, column 16.  
WebElement element = findElement(By.xpath("//label[text()=‘Location’]/preceding-sibling::select"))  
^

file:/C:/Users/Public/Documents/Projects/Katalon%20Studio/RMS/Scripts/Create%20PO/Script1584964253873.groovy: 66: unable to resolve class Select  
@ line 66, column 14.  
select = new Select(element)  
^

3 errors

```
at com.kms.katalon.core.main.ScriptEngine.getScript(ScriptEngine.java:199)
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 TempTestCase1586510315346.run(TempTestCase1586510315346.groovy:23)
```

---

<div class="post-metadata">

**Author:** ![jlegault](https://avatars.discourse-cdn.com/v4/letter/j/dc4da7/32.png) [@jlegault](https://forum.katalon.com/u/jlegault)\
**Post date:** [April 10, 2020, 3:54pm UTC](https://forum.katalon.com/t/not-able-pick-a-value-from-a-drop-down-list/41400/16 "2020-04-10T15:54:57Z")

</div>

```
import org.openqa.selenium.By
import org.openqa.selenium.WebDriver
import org.openqa.selenium.WebElement
import org.openqa.selenium.support.ui.Select
import internal.GlobalVariable as GlobalVariable

import com.kms.katalon.core.annotation.Keyword
import com.kms.katalon.core.webui.driver.DriverFactory
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords

```

I’m not sure you need 100% of these imports, but with these you should get the webdriver, the driverfactory, the select, and the webelement.

---

<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:** [April 10, 2020, 4:32pm UTC](https://forum.katalon.com/t/not-able-pick-a-value-from-a-drop-down-list/41400/17 "2020-04-10T16:32:13Z")

</div>

Press ctrl + shift + o on your keyboard to automatically import everything. You may see a few modals pop up asking which class you want whenever there are multiple classes of the same name available. If this occurs, choose the ones that have “selenium” in their package path.

---

<div class="post-metadata">

**Author:** ![upendras](https://avatars.discourse-cdn.com/v4/letter/u/7ab992/32.png) [@upendras](https://forum.katalon.com/u/upendras)\
**Post date:** [April 11, 2020, 9:42pm UTC](https://forum.katalon.com/t/not-able-pick-a-value-from-a-drop-down-list/41400/18 "2020-04-11T21:42:05Z")

</div>

HI Brandon,  
After trying the set of code you advised i am getting the below errors.Please advise.

org.openqa.selenium.JavascriptException: Cannot click on option element. Executing JavaScript click function returned an unexpected error, but no error could be returned from Internet Explorer’s JavaScript engine.  
Build info: version: ‘3.141.59’, revision: ‘e82be7d358’, time: ‘2018-11-14T08:25:53’  
System info: host: ‘TGGCTX095’, ip: ‘172.16.2.95’, os.name: ‘Windows Server 2008 R2’, os.arch: ‘amd64’, os.version: ‘6.1’, java.version: ‘1.8.0\_181’  
Driver info: com.kms.katalon.selenium.driver.CInternetExplorerDriver  
Capabilities {acceptInsecureCerts: false, browserName: internet explorer, browserVersion: 11, javascriptEnabled: true, pageLoadStrategy: normal, platform: WINDOWS, platformName: WINDOWS, proxy: Proxy(), se:ieOptions: {browserAttachTimeout: 0, elementScrollBehavior: 0, enablePersistentHover: false, ie.browserCommandLineSwitches: , ie.edgechromium: false, ie.edgepath: , ie.ensureCleanSession: false, ie.fileUploadDialogTimeout: 3000, ie.forceCreateProcessApi: false, ignoreProtectedModeSettings: true, ignoreZoomSetting: true, initialBrowserUrl: [http://localhost:43354/](http://localhost:43354/), nativeEvents: true, requireWindowFocus: false}, setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify}  
Session ID: cc1bad1b-e851-4196-a3a6-8dc4db3d135c  
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:187)  
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:122)  
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)  
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)  
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)  
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)  
at com.kms.katalon.selenium.driver.CInternetExplorerDriver.execute(CInternetExplorerDriver.java:21)  
at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:285)  
at org.openqa.selenium.remote.RemoteWebElement.click(RemoteWebElement.java:84)  
at org.openqa.selenium.support.events.EventFiringWebDriver$EventFiringWebElement.lambda$new$0(EventFiringWebDriver.java:404)  
at com.sun.proxy.$Proxy9.click(Unknown Source)  
at org.openqa.selenium.support.events.EventFiringWebDriver$EventFiringWebElement.click(EventFiringWebDriver.java:417)  
at org.openqa.selenium.support.ui.Select.setSelected(Select.java:311)  
at org.openqa.selenium.support.ui.Select.setSelectedByIndex(Select.java:293)  
at org.openqa.selenium.support.ui.Select.selectByIndex(Select.java:172)  
at org.openqa.selenium.support.ui.ISelect$selectByIndex.call(Unknown Source)  
at Create PO.run(Create PO:71)  
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 TempTestCase1586641174573.run(TempTestCase1586641174573.groovy:23)

---

<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:** [April 11, 2020, 11:05pm UTC](https://forum.katalon.com/t/not-able-pick-a-value-from-a-drop-down-list/41400/19 "2020-04-11T23:05:19Z")

</div>

> [@upendras](#):
>
> **Executing JavaScript click function returned an unexpected error** , but no error could be returned from Internet Explorer’s JavaScript engine.

Your JavaScript code contains errors (or, maybe IE can’t understand it). The confusing this is, I don’t see any JavaScript in the code given to you by @Brandon_Hein.

When others are trying to help you, it’s important that…

1. You don’t change the code in a substantive way to create a moving target for the person trying to help you.

2. You show enough of the code you’re dealing with so the person trying to help you can consider all circumstances and potentials for error.

---

<div class="post-metadata">

**Author:** ![upendras](https://avatars.discourse-cdn.com/v4/letter/u/7ab992/32.png) [@upendras](https://forum.katalon.com/u/upendras)\
**Post date:** [April 12, 2020, 11:23am UTC](https://forum.katalon.com/t/not-able-pick-a-value-from-a-drop-down-list/41400/20 "2020-04-12T11:23:38Z")

</div>

Hi Russ,  
Sorry if my word hurts Brandon or Anybody.  
Actually my script was not able to pick a value from a drop down list , and Brandon suggested some set of code .  
So i added that set of code in my script and after running script , element was not clicked and the script failed,so i added the entire error to investigate,so that i was my aim.  
i followed the instructions given by experts in this forum.  
As i am new to katalon i am facing the difficuties and was seeking for help.  
If my word hurts to anybody i am sorry.

[Next page](https://forum.katalon.com/t/not-able-pick-a-value-from-a-drop-down-list/41400.md?page=2)
