How to Click on Highchart Elements During Automation How to Click on Highchart Elements During Automation selenium selenium

How to Click on Highchart Elements During Automation


Thank you @dangi13 for your help. However I found a solution using a different xpath structure:

sharedData.appInstance.findElement(By.xpath("//[name()='g' and @class='highcharts-legend']//[name()='text']//*[name()='tspan' and text()='Worst Inventory on Site']")).click();


You can use below code for clicking on HighChart Elements :

/**     * @param graphName Use one of below values.     * Worst Inventory On Site     * Total Ins     * Total Outs     * Inventory On Site     * Inventory On Transit     */    public void clickOnGraph(String graphName) {         WebElement graphElement = driver.findElement(By.xpath("//g[@class='highcharts-legend-item']//tspan[text()='" + graphName + "']"));         graphElement.click();    }

For further HighChart element manipulations. You can refer :

https://github.com/Ardesco/Powder-Monkey/blob/master/src/main/java/com/lazerycode/selenium/graphs/HighCharts.java

It is very helpful for HighCharts related Selenium operations.

If normal click does not work, you can try clicking using JavaScriptExecutor or Actions class.

Please do let me know if that helps you :)