# How to select data in select2-selection using Katalon

**URL:** <https://forum.katalon.com/t/how-to-select-data-in-select2-selection-using-katalon/20738>\
**Category:** Web Testing\
**Tags:** web-testing, katalon-studio\
**Created:** [March 7, 2019, 7:08pm UTC](https://forum.katalon.com/t/how-to-select-data-in-select2-selection-using-katalon/20738 "2019-03-07T19:08:58Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ankesh](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@Ankesh](https://forum.katalon.com/u/Ankesh)\
**Post date:** [March 7, 2019, 7:08pm UTC](https://forum.katalon.com/t/how-to-select-data-in-select2-selection-using-katalon/20738/1 "2019-03-07T19:08:58Z")

</div>

Issue:

I’m trying to enter data in a select2-selection but I can’t get it to work.

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

Any help would be highly appreciated.

---

<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 7, 2019, 8:44pm UTC](https://forum.katalon.com/t/how-to-select-data-in-select2-selection-using-katalon/20738/2 "2019-03-07T20:44:14Z")

</div>

There are multiple ways to handle select2 elements. Can you please share the HTML for one of those dropdowns, as well as the test code you are currently using to try and set the value? Thanks.

---

<div class="post-metadata">

**Author:** ![francoarebuffi](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/francoarebuffi/32/16103_2.png) [@francoarebuffi](https://forum.katalon.com/u/francoarebuffi)\
**Post date:** [March 7, 2019, 9:04pm UTC](https://forum.katalon.com/t/how-to-select-data-in-select2-selection-using-katalon/20738/3 "2019-03-07T21:04:03Z")

</div>

Try this : WebUI.selectOptionByLabel(findTestObject(‘YourPageName/YourPageObjectName’), ‘Katalon\_Template\_1’, false)

---

<div class="post-metadata">

**Author:** ![Ankesh](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@Ankesh](https://forum.katalon.com/u/Ankesh)\
**Post date:** [March 8, 2019, 7:36am UTC](https://forum.katalon.com/t/how-to-select-data-in-select2-selection-using-katalon/20738/4 "2019-03-08T07:36:06Z")

</div>

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

As of now I am using send keys method, but since the script is unable to click on dropdown arrow button it is not going through.

WebUI.click(findTestObject(‘Object Repository/Test Objects/Pages/Page\_Dashboard - Jobsparks/Job/span\_Please Select\_select2-selection\_\_arrow’))

WebUI.setText(findTestObject(‘Object Repository/Test Objects/Pages/Page\_Dashboard - Jobsparks/Job/input\_Please Select\_select2-search\_\_field (1)’),‘Stofer Smith’)

WebUI.sendKeys(findTestObject(‘Object Repository/Test Objects/Pages/Page\_Dashboard - Jobsparks/Create\_Client\_Objects/input\_Please Select\_select2-search\_\_field (1)’),Keys.chord(Keys.ENTER))

---

<div class="post-metadata">

**Author:** ![Ankesh](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@Ankesh](https://forum.katalon.com/u/Ankesh)\
**Post date:** [March 8, 2019, 7:37am UTC](https://forum.katalon.com/t/how-to-select-data-in-select2-selection-using-katalon/20738/5 "2019-03-08T07:37:20Z")

</div>

I have tried it but since it is select2 control it is not working for it.

---

<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 8, 2019, 4:48pm UTC](https://forum.katalon.com/t/how-to-select-data-in-select2-selection-using-katalon/20738/6 "2019-03-08T16:48:47Z")

</div>

The HTML snippet in your screenshot does not show the true element for the dropdown, rather, it’s showing a parent `<span>` element. Can you expand the span all the way down until you find either a `<select>` element or an `<input>` element?

Either of these will usually be the type of element you actually want to manipulate to set the field.

---

<div class="post-metadata">

**Author:** ![Ankesh](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@Ankesh](https://forum.katalon.com/u/Ankesh)\
**Post date:** [March 8, 2019, 5:28pm UTC](https://forum.katalon.com/t/how-to-select-data-in-select2-selection-using-katalon/20738/7 "2019-03-08T17:28:25Z")

</div>

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

Let me know if you need any other details

---

<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 8, 2019, 5:55pm UTC](https://forum.katalon.com/t/how-to-select-data-in-select2-selection-using-katalon/20738/8 "2019-03-08T17:55:52Z")

</div>

I would try a simple solution first:

1.) Create a test object with the following XPath:

`//label[normalize-space()='Tech']/following-sibling::div/select`

2.) Try setting this as if it were a normal select. If you successfully identify the `<select>` element using the above xpath, then @francoarebuffi’s answer might work:

`WebUI.selectOptionByLabel(findTestObject('path/to/test/object'), 'Stofer Smith', false);`

Let me know if this works. If it doesn’t we’ll try something else.

---

<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 8, 2019, 6:24pm UTC](https://forum.katalon.com/t/how-to-select-data-in-select2-selection-using-katalon/20738/10 "2019-03-08T18:24:57Z")

</div>

> [@Brandon\_Hein](#):
>
> Try setting this as if it were a normal select. If you successfully identify the `<select>` element using the above xpath, then @francoarebuffi’s answer might work:

It should, indeed. `aria-hidden` should not affect operability:

> **[Accessible Rich Internet Applications (WAI-ARIA) 1.2](https://www.w3.org/TR/wai-aria/)**
>
> Accessibility of web content requires semantic information about widgets, structures, and behaviors, in order to allow assistive technologies to convey appropriate information to persons with disabilities. This specification provides an ontology of...

And, for completeness:

> **[Accessible Rich Internet Applications (WAI-ARIA) 1.2](https://www.w3.org/TR/wai-aria/)**
>
> Accessibility of web content requires semantic information about widgets, structures, and behaviors, in order to allow assistive technologies to convey appropriate information to persons with disabilities. This specification provides an ontology of...

---

<div class="post-metadata">

**Author:** ![Ankesh](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@Ankesh](https://forum.katalon.com/u/Ankesh)\
**Post date:** [March 8, 2019, 7:06pm UTC](https://forum.katalon.com/t/how-to-select-data-in-select2-selection-using-katalon/20738/11 "2019-03-08T19:06:41Z")

</div>

Sure I will give it try and let you know. Thanks
