How to select a dropdown option when the element is a (<div>)

How to select a dropdown option when the element is a ( div )

I have tried with “selectOptionByValue” and “selectOptionByLabel” methods. But these methods are not supported for the div elements.
Could someone please help me to resolve the issue.

I need to read the HTML source of the page, I need to get access to the URL you are targeting and have the page working in browser on my local machine.

It is because the page is possibly driven by JavaScript extensively so we need to repeat try-and-error a lot with the active target web page to find out how the page acts. Without acting web page in hand, I can say nothing for sure about the page with JavaScript.

Is the URL public to the internet? If so, please share the URL to us.

If the URL is NOT public, please save the target page in a MIME HTML file and share it to us here. How to? See

The following may help you get started, but it looks like for each div item, you have to move down to child elements. Since you didn’t show them, you will have to figure that out.

import org.openqa.selenium.By as By
import org.openqa.selenium.Keys as Keys
import org.openqa.selenium.WebDriver as WebDriver
import org.openqa.selenium.WebElement as WebElement
import com.kms.katalon.core.webui.driver.DriverFactory as DriverFactory

WebDriver driver = DriverFactory.getWebDriver();
List<WebElement> list = driver.findElements(By.xpath('//div[@class="rc-virtual-list-holder-inner"]/div[contains(@class, "ant-select-item ant-select-item-options")]'))
WebUI.comment("found ${list.size()} items")
println("found ${list.size()} items")

for (int cnt = 0; cnt < list.size(); cnt++) {...

Another way is to use WebUI.findWebElements like below:

Find the parent element and you can keep dropdown value as child node. play around based on your needs

I think you can use dynamic property in Katalon with proper selector.

If you are looking for selecting any div, so you can access them by this Xpath selector:

//child::div[@class=‘rc-virtual-list-holder-inner’][${position}]//div[contains(@class, ‘ant-select-item-option’]

In this case we choose any div as element from parent div, using its position in the list. ${position} here represents dynamic property.

Create test object with this selector

After that, implement this test object in your test cycle. After inserting, click on object name and write down name of your dynamic property. And now choice of number will be choice of the element. This have worked for me, I hope works for you too. :slight_smile:

I don’t understand which is parent element we are working with, so you may change selector for you special occasion.