Unable to wait for object to be visible

I was not able to select one of the options from the available dropdown. So I added the waitForElementClickable. It did not fix my error, so on top of that, I have added waitForElementVisible. But that option is still not working as expected. I am receiving the following error.

Unable to wait for object to be visible (Root cause: com.kms.katalon.core.exception.StepFailedException: Unable to wait for object to be visible

at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.stepFailed(WebUIKeywordMain.groovy:175)

Please advise, how should I fix this error?

Thanks,

2 Likes

You should check if the TestObject is correctly pointing the HTML element that you want.

If you want others in this forum to check it for you, you need to desclose much more detail information. Please show us 2 things:

  1. HTML source code of your target, especially around the “dropdown” that you are interested in
  2. the definition of the TestObject you used, espectially the Locator (xpath, or css selector)

Unless these detail information disclosed, nobody would be able to help you.

1 Like

add an explicit wait , confirm the element presence and then verify your action

1 Like

Also, what is the wait time, or timeOut, that you used. If you used 0, then that is likely your issue. If you used 10, then you are using the statement correctly-ish. :slight_smile:

WebUI.waitForElementVisible(findTestObject('…', 10))

I also had an issue with some drop-downs on an application that I am starting to test. The “waitForElementClickable” did not work at a timeOut of 10. However, the “waitForElementVisible” statement did after about half a second. Overall, my drop-down worked, so, let’s see some pathways to your objects or some HTML. It seems you have an issue there.

Let me tell you what I guess.

I would bet that @JP_LFT used one of the following keywords to implement his intention:

You may be or may not be aware, those keywords assume that the target HTML has classical fragment of

<select>
   <option>
   ...
   <option>
</select>

On the other hand, I guess, his target HTML has no <select> element but has a tree of <div> elements that are dynamically rendered by some JavaScript UI library, such as React or Vue.

In such a case, his test script would never work.

… this is just what I guess. It is a FAQ here. I may be wrong. To better understand @JP_FLT’s case, we need to see the HTML source code and the TestObject locator definition he has.

2 Likes

If you have the situation that @kazurayam suggests, you can still work your testing on this application, however, you have to change the way you are currently trying. Instead, you need to review the page below:

How to handle Web Tables in Katalon Studio | Katalon Docs

The simple way is to collect a List of web elements and then parse through the list, like the sample below. There are other ways of handling it too.

Sample:
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
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> listOptions = driver.findElements(By.xpath("//div/ul[@class='select-list']/li"));

WebUI.verifyMatch(listOptions.get(0).getText(), “Author”, false)
WebUI.verifyMatch(listOptions.get(1).getText(), “CofC”, false)
WebUI.verifyMatch(listOptions.get(2).getText(), “Correspondence”, false)

WebUI.verifyEqual(listOptions.size(), 3)

"our choice"
listOptions.get(2).click();

1 Like

You can see the HTML tag that you are working with if you right click on the object and choose “Inspect” from the pop-up. Do this a second time and your object will be highlighted center stage.
If you right click and “Inspect” is NOT on the pop-up, then use the F12 key and click on “Open Dev-Tools”. Then you can use the Inspector Tool (left most icon on top) or use CTRL + Shift + C, and select your object.

1 Like

your issue resolved?

1 Like

Can you share the HTML code for your dropdown? If it’s a regular dropdown with <select> and <option>, it should work out of the box. However, if the dropdown is dynamically populated, you may need to take a different approach.

In this case, you would first need to click on the dropdown to reveal the options. Then, wait for the options to load before selecting the desired option.

Here’s a potential solution to your issue:

1. Click the Dropdown

Since the dropdown might be dynamically populated, the first step is to click the dropdown itself to reveal the options.

// Click the dropdown to make options visible
WebUI.click(findTestObject('your_dropdown_object'))

2. Wait for the Options to Load

Next, you’ll want to wait for the options to become visible. This is necessary when options are loaded dynamically.

// Wait for the options to be visible (adjust the XPath based on your actual dropdown options)
WebUI.waitForElementVisible(findTestObject('your_dropdown_options'), 10)

3. Wait for the Option to be Clickable

Now that the options are visible, wait for the specific option to be clickable before selecting it.

// Wait for the specific option to be clickable
WebUI.waitForElementClickable(findTestObject('your_dropdown_option', [('text') : 'Option Text']), 10)

4. Click the Desired Option

Finally, click on the option that you want to select from the dropdown.

// Click the desired option
WebUI.click(findTestObject('your_dropdown_option', [('text') : 'Option Text']))

Full Example:

// Click the dropdown
WebUI.click(findTestObject('Page_YourPage/your_dropdown_object'))

// Wait for options to be visible
WebUI.waitForElementVisible(findTestObject('Page_YourPage/your_dropdown_options'), 10)

// Wait for the specific option to become clickable
WebUI.waitForElementClickable(findTestObject('Page_YourPage/your_dropdown_option', [('text') : 'Option Text']), 10)

// Click the desired option
WebUI.click(findTestObject('Page_YourPage/your_dropdown_option', [('text') : 'Option Text']))

1 Like

Hi @JP_FLT,

Have you got your issue solved? If yes, feel free to share the solution. If no, feel free to share more information or we will proceed to close this thread. Thank you

1 Like