How to handling select2?

How to handling select2 for register test like that
image
WebUI.openBrowser(‘’)

WebUI.navigateToUrl(‘https://idh.id/welcome’)

WebUI.click(findTestObject(‘LIHAT PRODUK TANPA LOGIN/Page_Indonesia Distribution Hub/p_Lihat Ketersediaan Produk _b6c70d’))

WebUI.click(findTestObject(‘LIHAT PRODUK TANPA LOGIN/Page_Indonesia Distribution Hub/Click_KolomKota’))

WebUI.setText(findTestObject(‘LIHAT PRODUK TANPA LOGIN/Page_Indonesia Distribution Hub/Input_Lokasi’), Kota)

WebUI.delay(3, FailureHandling.STOP_ON_FAILURE)

WebUI.click(findTestObject(‘LIHAT PRODUK TANPA LOGIN/Page_Indonesia Distribution Hub/click_kotaBogor’), FailureHandling.STOP_ON_FAILURE)

WebUI.verifyElementPresent(findTestObject(‘LIHAT PRODUK TANPA LOGIN/Page_Indonesia Distribution Hub/a_local_shippingLokasi PengirimanKOTA BOGOR’),
60)

WebUI.closeBrowser()

PLEASE HELP ME :slight_smile:

A couple of points. When you put code in this forum, you should put 3 backticks ( like ```) above and below your code. The backtick is on the same key as the tilde ( ~ ). That makes the code easier to read.

Second, it is really the HTML that we need to assist you. If you could put the selection you want assistance on, it would help us that cannot read the Indonesian language.

Third, we need to know what error you are getting when attempting to run your code. It could be that you aren’t targeting the correct element, or it could be how you are interacting with that element.

Overall, I find it best to handle any typeahead field (which is essentially what a select2 is) as follows:

WebElement element = WebUiCommonHelper.findWebElement(findTestObject("LIHAT PRODUK TANPA LOGIN/Page_Indonesia Distribution Hub/Input_Lokasi"), 30);
element.sendKeys("BOGOR");
element.sendKeys(Keys.ENTER);

WebUI.openBrowser(’’)

WebUI.navigateToUrl(‘https://idh.id/welcome’)

WebUI.click(findTestObject(‘LIHAT PRODUK TANPA LOGIN/Page_Indonesia Distribution Hub/p_Lihat Ketersediaan Produk _b6c70d’))

WebUI.click(findTestObject(‘LIHAT PRODUK TANPA LOGIN/Page_Indonesia Distribution Hub/Click_KolomKota’))

WebUI.setText(findTestObject(‘LIHAT PRODUK TANPA LOGIN/Page_Indonesia Distribution Hub/Input_Lokasi’), Kota)

WebUI.delay(5)

WebUI.selectOptionByLabel(findTestObject(‘LIHAT PRODUK TANPA LOGIN/Page_Indonesia Distribution Hub/li_KOTA BOGOR’), Keys.chord(
Keys.ENTER), true)

WebUI.verifyElementPresent(findTestObject(‘LIHAT PRODUK TANPA LOGIN/Page_Indonesia Distribution Hub/a_local_shippingLokasi PengirimanKOTA BOGOR’),
60)

WebUI.closeBrowser()

Is it like this?

You need to import those libraries.

Press ctrl + shift + o on your keyboard.

It’s clear that you are not familiar with programming basics. I would spend some time learning how imports work. This will not be the only time you’ll need to import a library that isn’t available by default. Also, you haven’t shared your original error yet.