Select2 drop down option can not be selected

Hi
iam new to katalon actually in our website we use select2 drop down instead of select so i can not able to click the specified options in drop down

can anyone help over that

Hi @pradeep.adaptive

From 6.3.4 you can press a combination of (Ctrl + ` ) when you hover on an object to automatically add a click on that object to the Web Recorder. The functionality is here to handle cases like this.

I recommend using the latest version. If you’re using older versions, then you can add the item through Spy Tool and add a click on that object manually in your test case.

Hope it helps !

Hello @pradeep.adaptive

Please take a look at the hint that I’ve told you about.

Hi thanh

thanks for your reply but i treid to capture the got the object too but it was clickable !but also it was

below where the image for element available on drop down select2

Hi emine as for your article i taken the li-element object but that was also not clickable

Try to use Javascript click. A very useful answer from @Russ_Thomas may be of help

You only need to pass the selector (the object’s locator) into that function, since Russ already allows the second argument to be null by default, so you can forget about it.

hi thanh

used that too passed the object locator but can not clicked iam sharing my screen for your refrence

Hi @pradeep.adaptive

You will need to create a package, then create a keyword and place the above piece of code into that keyword (class).

Suppose you created a package yourpackage and a keyword YourClass looks like this:

package yourpackage

import static com.kms.katalon.core.checkpoint.CheckpointFactory.findCheckpoint
import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase
import static com.kms.katalon.core.testdata.TestDataFactory.findTestData
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
import static com.kms.katalon.core.testobject.ObjectRepository.findWindowsObject

import com.kms.katalon.core.annotation.Keyword
import com.kms.katalon.core.checkpoint.Checkpoint
import com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords as CucumberKW
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobile
import com.kms.katalon.core.model.FailureHandling
import com.kms.katalon.core.testcase.TestCase
import com.kms.katalon.core.testdata.TestData
import com.kms.katalon.core.testobject.TestObject
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import com.kms.katalon.core.windows.keyword.WindowsBuiltinKeywords as Windows

import internal.GlobalVariable

public class YourClass {
	/**
	 * Click an element using jQuery.
	 * @param selector (String) jQuery selector to target the element.
	 * @param iFrameSelector (string) optional iframe selector.
	 */
	static void jQ_click(String selector, String iFrameSelector = null) {
		String js = "\$(arguments[0]).click();"
		if(iFrameSelector) {
			js = "\$(arguments[1]).contents().find(arguments[0]).click();"
		}
		WebUI.executeJavaScript(js, Arrays.asList(selector, iFrameSelector))
	}
}

Then in your test case, you can use it like this

import yourpackage.YourClass

//Other steps

YourClass.jQ_click("The object's locator")

Thanks @Thanh for the reply exactly followed the above scenario but got an error

Can you suggest which element must be captured wheather “li” element from drop down of drop down select span??

@pradeep.adaptive

Please don’t use Object ID as the argument into jQ_click function. It takes in a locator, in your case the locator is the value inside Selected Locator in the Test Object.

Hi thanh

i used selenium webdriver before so for xpath i used to fetch and add into it but in katalon i was unable to take the locators this was the extact element which i cought

Page_Adaptive Biz App/li_0002-DCS GLOBAL ifor pvt ltd trichy india is a lading software services

this was the extact value attribute
Session[“alert”] = “Employee " + employee.Name + " is updated.”;