How to click Gantt chart bar to enable other command?

Hi All,

I tried to click below the Gantt chart bar to enable other commands. My X path is “//gantt-body//div[${index}][@id=“${dataId}”]”. I tried the methods below but none of these methods work for me. Delays also do not work. Element clickable and visible return true. How can I overcome this issue?

  • WebUI.enhancedClick(element)
  • WebUI.executeJavaScript(“arguments[0].click()”, Arrays.asList(element))
  • JavascriptExecutor executor = (JavascriptExecutor) DriverFactory.getWebDriver()
    executor.executeScript(“arguments[0].click();”, element)

How about trying clickOffset()? So, use your reference of your element like you have tried above, and put on a fair bit of the x direction, like 400 and a small y direction like 25.

WebUI.clickOffset(testObject, 400, 25)

You could even try a “for loop” to print to the console a value and see if you do something in the y direction.

for (int cnt = 5; cnt < 50; cnt++) {
    println ("moving to ${cnt.toString()}")
    WebUI.clickOffset(testObject, 400, 5 + cnt)
    WebUI.delay(2)     // check out if you get any action

Edit: or you could experiment until you get some values that you like:

for (int y = 0; y < 50; y++) {
    for (int x = 0; x < 700; x+100) {
        println ("moving to ${x.toString()} and ${y.toString()}")
        WebUI.clickOffset(testObject, 100 + x, 5 + y)
        WebUI.delay(2)     // check out if you get any action

Edit2: Additionally, you can use DevTools to display the length (clientHeight) and width (clientWidth) of your object, by copying the pathway to the Search box within the HTML and use the properties tab to review the their numbers, like (sample from one of our textarea), and then use numbers about half of their values:


If the regular methods for clicking on the Gantt chart bar are not working for you, there are a few additional approaches you can try:

  1. Scroll to the element: Sometimes, elements may not be clickable if they are not visible within the viewport. You can try scrolling to the element before clicking it using the WebUI.scrollToElement(testObject) method. This ensures that the element is in view before attempting to click it.
  2. Wait for element to be clickable: Although the element may be visible and clickable, there might be some delay or asynchronous behavior preventing it from being clicked immediately. You can use the WebUI.waitForElementClickable(testObject, timeout) method to wait for the element to become clickable before performing the click action.
  3. Simulate a mouse click: Instead of using the regular click methods, you can try simulating a mouse click on the element. Here’s an example using JavaScript execution:
WebUI.executeJavaScript("arguments[0].dispatchEvent(new MouseEvent('click'))", Arrays.asList(element))

This JavaScript code triggers a click event on the element, simulating a mouse click.

Execute JavaScript on the parent element: If clicking directly on the Gantt chart bar isn't working, you can try clicking on a parent element that encompasses the chart bar. Look for a container or wrapper element that encompasses the Gantt chart bar and execute the click action on that element using JavaScript.

JavascriptExecutor executor = (JavascriptExecutor) DriverFactory.getWebDriver()
executor.executeScript(“arguments[0].click();”, parentElement)

Replace parentElement with the appropriate element from your Gantt chart structure.

It’s worth noting that the specific solution may depend on the underlying structure and behavior of the Gantt chart component you are interacting with. Inspecting the HTML structure and considering any potential event listeners or behaviors on the Gantt chart can provide further insights on how to interact with it programmatically.

It’s working. Thanks a lot

Thank you for the reply. Tried this too. but not working. Sorted the issue by using WebUI.clickOffset()